Commit 41e5c398 authored by Russ Cox's avatar Russ Cox

cmd/go: fix 'go test foo_test.go'

Fixes race build.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/100410044
parent 26ad5d4f
......@@ -783,6 +783,12 @@ fi
rm -f testdata/err.out
unset GOPATH
TEST 'go test foo_test.go works'
if ! ./testgo test testdata/standalone_test.go; then
echo "go test testdata/standalone_test.go failed"
ok=false
fi
# clean up
if $started; then stop; fi
rm -rf testdata/bin testdata/bin1
......
......@@ -661,11 +661,14 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
build: &build.Package{
ImportPos: p.build.XTestImportPos,
},
imports: append(ximports, ptest),
imports: ximports,
pkgdir: testDir,
fake: true,
Stale: true,
}
if ptest != p {
pxtest.imports = append(pxtest.imports, ptest)
}
}
// Action for building pkg.test.
......@@ -675,13 +678,15 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
GoFiles: []string{"_testmain.go"},
ImportPath: "testmain",
Root: p.Root,
imports: []*Package{ptest},
build: &build.Package{Name: "main"},
pkgdir: testDir,
fake: true,
Stale: true,
omitDWARF: !testC && !testNeedBinary,
}
if ptest != p {
pmain.imports = append(pmain.imports, ptest)
}
if pxtest != nil {
pmain.imports = append(pmain.imports, pxtest)
}
......
package standalone_test
import "testing"
func Test(t *testing.T) {
}
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