mirror of https://github.com/golang/go.git
cm/go/internal/test: make vet run when using go test -c
Fixes #26451 Change-Id: Icd8d6d55dc42adb5c8953787eec7eb29ba46b2aa Reviewed-on: https://go-review.googlesource.com/125215 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
59699aa166
commit
834d2244a0
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
! go test -c compile_binary/...
|
||||
stderr 'build comment'
|
||||
|
||||
-- compile_binary/foo_test.go --
|
||||
//+build foo
|
||||
package foo
|
||||
Loading…
Reference in New Issue