Commit baed067d authored by Russ Cox's avatar Russ Cox

cmd/go: show FAIL for errors during test setup

For example, if an x_test.go file contains a syntax error,
b.test fails with an error message. But it wasn't printing
the same FAIL line that a build failure later would print.
This makes all the test failures that happen (once we
decide to start running tests) consistently say FAIL.

Fixes #4701.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13431044
parent 627d17cf
...@@ -104,6 +104,19 @@ cp -R testdata/local "testdata/$bad" ...@@ -104,6 +104,19 @@ cp -R testdata/local "testdata/$bad"
testlocal "$bad" 'with bad characters in path' testlocal "$bad" 'with bad characters in path'
rm -rf "testdata/$bad" rm -rf "testdata/$bad"
TEST error message for syntax error in test go file says FAIL
export GOPATH=$(pwd)/testdata
if ./testgo test syntaxerror 2>testdata/err; then
echo 'go test syntaxerror succeeded'
ok=false
elif ! grep FAIL testdata/err >/dev/null; then
echo 'go test did not say FAIL:'
cat testdata/err
ok=false
fi
rm -f ./testdata/err
unset GOPATH
# Test tests with relative imports. # Test tests with relative imports.
TEST relative imports '(go test)' TEST relative imports '(go test)'
if ! ./testgo test ./testdata/testimport; then if ! ./testgo test ./testdata/testimport; then
......
...@@ -423,10 +423,12 @@ func runTest(cmd *Command, args []string) { ...@@ -423,10 +423,12 @@ func runTest(cmd *Command, args []string) {
if strings.HasPrefix(str, "\n") { if strings.HasPrefix(str, "\n") {
str = str[1:] str = str[1:]
} }
failed := fmt.Sprintf("FAIL\t%s [setup failed]\n", p.ImportPath)
if p.ImportPath != "" { if p.ImportPath != "" {
errorf("# %s\n%s", p.ImportPath, str) errorf("# %s\n%s\n%s", p.ImportPath, str, failed)
} else { } else {
errorf("%s", str) errorf("%s\n%s", str, failed)
} }
continue continue
} }
......
package p
func f() (x.y, z int) {
}
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