]> Cypherpunks repositories - gostls13.git/commitdiff
test: check for build constraints only upto the first blank line
authorRahul Chaudhry <rahulchaudhry@chromium.org>
Tue, 3 Feb 2015 18:52:18 +0000 (10:52 -0800)
committerMinux Ma <minux@golang.org>
Fri, 6 Feb 2015 05:36:26 +0000 (05:36 +0000)
The main issue is that the misc/cgo/{stdio,life} tests are silently
getting skipped when invoked from run.bash.

run.go should ignore any build tags after the first blank line in
source file. It already checks for test actions only upto the first
blank line. Build tags must be specified in the same block.

See http://golang.org/cl/3675 for background.

Change-Id: Id8abf000119e3335f7250d8ef34aac7811fc9dff
Reviewed-on: https://go-review.googlesource.com/3812
Reviewed-by: Minux Ma <minux@golang.org>
test/gc2.go
test/nosplit.go
test/run.go

index 561516b8bb7a6b0508d1bc15a5fe8790cd0eaa69..b33a02780405f7787fae3d6f8a5a76e8fc096a11 100644 (file)
@@ -1,6 +1,5 @@
-// run
-
 // +build !nacl
+// run
 
 // Copyright 2011 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
index a639150511c2fa1e8776d4fa687669880cb795c6..0bd13c1db4150e8d6514531c30054f61b15bad25 100644 (file)
@@ -1,6 +1,5 @@
-// run
-
 // +build !nacl
+// run
 
 // Copyright 2014 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
index aa26061af8d9aba39e091a9697aa1e7192a738a9..6adf93cd98c43c11fe8f4d1f452825126c782384 100644 (file)
@@ -325,9 +325,6 @@ type context struct {
 // shouldTest looks for build tags in a source file and returns
 // whether the file should be used according to the tags.
 func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) {
-       if idx := strings.Index(src, "\npackage"); idx >= 0 {
-               src = src[:idx]
-       }
        for _, line := range strings.Split(src, "\n") {
                line = strings.TrimSpace(line)
                if strings.HasPrefix(line, "//") {
@@ -417,7 +414,8 @@ func (t *test) run() {
                t.err = errors.New("double newline not found")
                return
        }
-       if ok, why := shouldTest(t.src, goos, goarch); !ok {
+       // Check for build constraints only upto the first blank line.
+       if ok, why := shouldTest(t.src[:pos], goos, goarch); !ok {
                t.action = "skip"
                if *showSkips {
                        fmt.Printf("%-20s %-20s: %s\n", t.action, t.goFileName(), why)