URL
                    https://opencores.org/ocsvn/openrisc/openrisc/trunk
                
            Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [go/] [build/] [build_test.go] - Rev 752
Go to most recent revision | Compare with Previous | Blame | View Log
// Copyright 2011 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package buildimport ("path/filepath""reflect""runtime""sort""testing")func sortstr(x []string) []string {sort.Strings(x)return x}var buildPkgs = []struct {dir stringinfo *DirInfo}{{"go/build/pkgtest",&DirInfo{GoFiles: []string{"pkgtest.go"},SFiles: []string{"sqrt_" + runtime.GOARCH + ".s"},Package: "pkgtest",Imports: []string{"bytes"},TestImports: []string{"fmt", "pkgtest"},TestGoFiles: sortstr([]string{"sqrt_test.go", "sqrt_" + runtime.GOARCH + "_test.go"}),XTestGoFiles: []string{"xsqrt_test.go"},},},{"go/build/cmdtest",&DirInfo{GoFiles: []string{"main.go"},Package: "main",Imports: []string{"go/build/pkgtest"},TestImports: []string{},},},{"go/build/cgotest",&DirInfo{CgoFiles: ifCgo([]string{"cgotest.go"}),CFiles: []string{"cgotest.c"},HFiles: []string{"cgotest.h"},Imports: []string{"C", "unsafe"},TestImports: []string{},Package: "cgotest",},},}func ifCgo(x []string) []string {if DefaultContext.CgoEnabled {return x}return nil}func TestBuild(t *testing.T) {for _, tt := range buildPkgs {tree := Path[0] // Gorootdir := filepath.Join(tree.SrcDir(), tt.dir)info, err := ScanDir(dir)if err != nil {t.Errorf("ScanDir(%#q): %v", tt.dir, err)continue}// Don't bother testing import positions.tt.info.ImportPos, tt.info.TestImportPos = info.ImportPos, info.TestImportPosif !reflect.DeepEqual(info, tt.info) {t.Errorf("ScanDir(%#q) = %#v, want %#v\n", tt.dir, info, tt.info)continue}}}func TestMatch(t *testing.T) {ctxt := DefaultContextwhat := "default"match := func(tag string) {if !ctxt.match(tag) {t.Errorf("%s context should match %s, does not", what, tag)}}nomatch := func(tag string) {if ctxt.match(tag) {t.Errorf("%s context should NOT match %s, does", what, tag)}}match(runtime.GOOS + "," + runtime.GOARCH)match(runtime.GOOS + "," + runtime.GOARCH + ",!foo")nomatch(runtime.GOOS + "," + runtime.GOARCH + ",foo")what = "modified"ctxt.BuildTags = []string{"foo"}match(runtime.GOOS + "," + runtime.GOARCH)match(runtime.GOOS + "," + runtime.GOARCH + ",foo")nomatch(runtime.GOOS + "," + runtime.GOARCH + ",!foo")match(runtime.GOOS + "," + runtime.GOARCH + ",!bar")nomatch(runtime.GOOS + "," + runtime.GOARCH + ",bar")}
Go to most recent revision | Compare with Previous | Blame | View Log

