]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.4] go/build: build $GOOS_test.go always
authorRuss Cox <rsc@golang.org>
Tue, 25 Nov 2014 03:00:01 +0000 (22:00 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 25 Nov 2014 03:00:01 +0000 (22:00 -0500)
««« CL 176290043 / 8025b7d1e6c9
go/build: build $GOOS_test.go always

We decided to build $GOOS.go always
but forgot to test $GOOS_test.go.

Fixes #9159.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/176290043
»»»

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/182740043

src/go/build/build.go
src/go/build/build_test.go

index 7a51cf3c0607617fb746ae0c3315da5ba128c5d4..311ecb01f4adeab4ea7a44d3f5a12e66b01341bd 100644 (file)
@@ -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" {
index 43d09cbd145164676d146af0d215125a1ec32d33..a40def0fa0ec575073a3dd1741e978a82765fdd7 100644 (file)
@@ -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},
 }