Commit 834d2244 authored by LE Manh Cuong's avatar LE Manh Cuong Committed by Ian Lance Taylor

cm/go/internal/test: make vet run when using go test -c

Fixes #26451

Change-Id: Icd8d6d55dc42adb5c8953787eec7eb29ba46b2aa
Reviewed-on: https://go-review.googlesource.com/125215Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 59699aa1
......@@ -381,12 +381,13 @@ func (c *config) checkRuntime() (skip bool, err error) {
return false, err
}
cmd.Args = append(cmd.Args, "-dM", "-E", "../../../src/runtime/cgo/libcgo.h")
cmdStr := strings.Join(cmd.Args, " ")
out, err := cmd.CombinedOutput()
if err != nil {
return false, fmt.Errorf("%#q exited with %v\n%s", strings.Join(cmd.Args, " "), err, out)
return false, fmt.Errorf("%#q exited with %v\n%s", cmdStr, err, out)
}
if !bytes.Contains(out, []byte("#define CGO_TSAN")) {
return true, fmt.Errorf("%#q did not define CGO_TSAN")
return true, fmt.Errorf("%#q did not define CGO_TSAN", cmdStr)
}
return false, nil
}
......
......@@ -892,8 +892,10 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
}
runAction = installAction // make sure runAction != nil even if not running test
}
var vetRunAction *work.Action
if testC {
printAction = &work.Action{Mode: "test print (nop)", Package: p, Deps: []*work.Action{runAction}} // nop
vetRunAction = printAction
} else {
// run test
c := new(runCache)
......@@ -906,12 +908,7 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
TryCache: c.tryCache,
Objdir: testDir,
}
if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 {
addTestVet(b, ptest, runAction, installAction)
}
if pxtest != nil {
addTestVet(b, pxtest, runAction, installAction)
}
vetRunAction = runAction
cleanAction = &work.Action{
Mode: "test clean",
Func: builderCleanTest,
......@@ -928,6 +925,14 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
IgnoreFail: true, // print even if test failed
}
}
if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 {
addTestVet(b, ptest, vetRunAction, installAction)
}
if pxtest != nil {
addTestVet(b, pxtest, vetRunAction, installAction)
}
if installAction != nil {
if runAction != installAction {
installAction.Deps = append(installAction.Deps, runAction)
......
! go test -c compile_binary/...
stderr 'build comment'
-- compile_binary/foo_test.go --
//+build foo
package foo
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