diff options
author | Russ Cox <rsc@golang.org> | 2014-11-24 20:18:44 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-11-24 20:18:44 -0500 |
commit | 696ed961d4a91d087200e23e028c6ff8ff35bcce (patch) | |
tree | 8aea3e4e6e40a9954bf4eff1bfe167a214f05231 | |
parent | 9cc4768f52e6c4a852f863a3a6b982ea71a4ed43 (diff) | |
download | go-696ed961d4a91d087200e23e028c6ff8ff35bcce.tar.gz |
go/build: build $GOOS_test.go always
We decided to build $GOOS.go always
but forgot to test $GOOS_test.go.
Fixes issue 9159.
LGTM=r
R=r
CC=golang-codereviews
https://codereview.appspot.com/176290043
-rw-r--r-- | src/go/build/build.go | 8 | ||||
-rw-r--r-- | src/go/build/build_test.go | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/go/build/build.go b/src/go/build/build.go index 7a51cf3c0..311ecb01f 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -1310,11 +1310,13 @@ func (ctxt *Context) goodOSArchFile(name string, allTags map[string]bool) bool { // auto-tagging to apply only to files with a non-empty prefix, so // "foo_linux.go" is tagged but "linux.go" is not. This allows new operating // sytems, such as android, to arrive without breaking existing code with - // innocuous source code in "android.go". The easiest fix: files without - // underscores are always included. - if !strings.ContainsRune(name, '_') { + // innocuous source code in "android.go". The easiest fix: cut everything + // in the name before the initial _. + i := strings.Index(name, "_") + if i < 0 { return true } + name = name[i:] // ignore everything before first _ l := strings.Split(name, "_") if n := len(l); n > 0 && l[n-1] == "test" { diff --git a/src/go/build/build_test.go b/src/go/build/build_test.go index 43d09cbd1..a40def0fa 100644 --- a/src/go/build/build_test.go +++ b/src/go/build/build_test.go @@ -189,6 +189,7 @@ var matchFileTests = []struct { {ctxtAndroid, "foo_plan9.go", "", false}, {ctxtAndroid, "android.go", "", true}, {ctxtAndroid, "plan9.go", "", true}, + {ctxtAndroid, "plan9_test.go", "", true}, {ctxtAndroid, "arm.s", "", true}, {ctxtAndroid, "amd64.s", "", true}, } |