From: Rahul Chaudhry Date: Tue, 3 Feb 2015 18:52:18 +0000 (-0800) Subject: test: check for build constraints only upto the first blank line X-Git-Tag: go1.5beta1~2117 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8581d48c150a5f0197a591bf8ef8b1ece7218585;p=gostls13.git test: check for build constraints only upto the first blank line 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 --- diff --git a/test/gc2.go b/test/gc2.go index 561516b8bb..b33a027804 100644 --- a/test/gc2.go +++ b/test/gc2.go @@ -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 diff --git a/test/nosplit.go b/test/nosplit.go index a639150511..0bd13c1db4 100644 --- a/test/nosplit.go +++ b/test/nosplit.go @@ -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 diff --git a/test/run.go b/test/run.go index aa26061af8..6adf93cd98 100644 --- a/test/run.go +++ b/test/run.go @@ -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)