mirror of
https://github.com/golang/go
synced 2024-11-11 18:51:37 -07:00
cmd/go: add sync/atomic dependency when needed by test coverage
Fixes #18486. Change-Id: I359dc4169e04b4123bd41679ea939b06fa754ac2 Reviewed-on: https://go-review.googlesource.com/34830 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
20cdb62c49
commit
3fa53f1229
@ -2247,6 +2247,28 @@ func TestCoverageImportMainLoop(t *testing.T) {
|
||||
tg.grepStderr("not an importable package", "did not detect import main")
|
||||
}
|
||||
|
||||
func TestTestEmpty(t *testing.T) {
|
||||
if !canRace {
|
||||
t.Skip("no race detector")
|
||||
}
|
||||
|
||||
wd, _ := os.Getwd()
|
||||
testdata := filepath.Join(wd, "testdata")
|
||||
|
||||
for _, dir := range []string{"pkg", "test", "xtest", "pkgtest", "pkgxtest", "pkgtestxtest", "testxtest"} {
|
||||
t.Run(dir, func(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.setenv("GOPATH", testdata)
|
||||
tg.cd(filepath.Join(testdata, "src/empty/"+dir))
|
||||
tg.run("test", "-cover", "-coverpkg=.", "-race")
|
||||
})
|
||||
if testing.Short() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDryRunWithCgo(t *testing.T) {
|
||||
if !canCgo {
|
||||
t.Skip("skipping because cgo not enabled")
|
||||
|
@ -955,6 +955,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
|
||||
if p.Name == "main" && goarch == "arm" {
|
||||
importPaths = append(importPaths, "math")
|
||||
}
|
||||
// In coverage atomic mode everything depends on sync/atomic.
|
||||
if testCoverMode == "atomic" && (!p.Standard || (p.ImportPath != "runtime/cgo" && p.ImportPath != "runtime/race" && p.ImportPath != "sync/atomic")) {
|
||||
importPaths = append(importPaths, "sync/atomic")
|
||||
}
|
||||
}
|
||||
|
||||
// Runtime and its internal packages depend on runtime/internal/sys,
|
||||
|
1
src/cmd/go/testdata/src/empty/pkg/pkg.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkg/pkg.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgtest/pkg.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgtest/pkg.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgtest/test_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgtest/test_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgtestxtest/pkg.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgtestxtest/pkg.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgtestxtest/test_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgtestxtest/test_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgtestxtest/xtest_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgtestxtest/xtest_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p_test
|
1
src/cmd/go/testdata/src/empty/pkgxtest/pkg.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgxtest/pkg.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/pkgxtest/xtest_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/pkgxtest/xtest_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p_test
|
1
src/cmd/go/testdata/src/empty/test/test_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/test/test_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/testxtest/test_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/testxtest/test_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p
|
1
src/cmd/go/testdata/src/empty/testxtest/xtest_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/testxtest/xtest_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p_test
|
1
src/cmd/go/testdata/src/empty/xtest/xtest_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/empty/xtest/xtest_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p_test
|
Loading…
Reference in New Issue
Block a user