Commit c8f90979 authored by Alex Brainman's avatar Alex Brainman

cmd/go: always build package during "go test" command

even when there are no *_test.go files present.
rsc suggested this change

Fixes #7108

LGTM=r, adg
R=golang-codereviews, r, adg
CC=golang-codereviews
https://golang.org/cl/84300043
parent 4abbd4a4
......@@ -700,6 +700,14 @@ if ! ./testgo list -f "GOARCH: {{context.GOARCH}}"; then
ok=false
fi
TEST 'Issue 7108: cmd/go: "go test" should fail if package does not build'
export GOPATH=$(pwd)/testdata
if ./testgo test notest >/dev/null 2>&1; then
echo 'go test notest succeeded, but should fail'
ok=false
fi
unset GOPATH
# clean up
if $started; then stop; fi
rm -rf testdata/bin testdata/bin1
......
......@@ -524,7 +524,7 @@ func contains(x []string, s string) bool {
func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, err error) {
if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
build := &action{p: p}
build := b.action(modeBuild, modeBuild, p)
run := &action{p: p, deps: []*action{build}}
print := &action{f: (*builder).notest, p: p, deps: []*action{run}}
return build, run, print, nil
......
package notest
func hello() {
println("hello world")
}
Hello world
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