Commit 8581d48c authored by Rahul Chaudhry's avatar Rahul Chaudhry Committed by Minux Ma

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/3812Reviewed-by: default avatarMinux Ma <minux@golang.org>
parent d81cc374
// run
// +build !nacl
// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......
// run
// +build !nacl
// run
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment