mirror of
https://github.com/golang/go
synced 2024-11-23 19:00:04 -07:00
cmd/go: convert TestCacheVet to a script
This test was failing when GOROOT was read-only. (I'm not sure why that was the case, but it's simpler to convert to to a script than to try to debug the non-script test.) Updates #28387 Change-Id: I9943e28d990e5d8b01da10e70531f3ab99e319a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/206897 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
4d0ed149ff
commit
a3ffb8a1ac
@ -5214,38 +5214,6 @@ func TestCacheCoverage(t *testing.T) {
|
|||||||
tg.run("test", "-cover", "-short", "math", "strings")
|
tg.run("test", "-cover", "-short", "math", "strings")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheVet(t *testing.T) {
|
|
||||||
skipIfGccgo(t, "gccgo has no standard packages")
|
|
||||||
tg := testgo(t)
|
|
||||||
defer tg.cleanup()
|
|
||||||
tg.parallel()
|
|
||||||
|
|
||||||
if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") {
|
|
||||||
t.Skip("GODEBUG gocacheverify")
|
|
||||||
}
|
|
||||||
if testing.Short() {
|
|
||||||
// In short mode, reuse cache.
|
|
||||||
// Test failures may be masked if the cache has just the right entries already
|
|
||||||
// (not a concern during all.bash, which runs in a clean cache).
|
|
||||||
if cfg.Getenv("GOCACHE") == "off" {
|
|
||||||
tooSlow(t)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tg.makeTempdir()
|
|
||||||
tg.setenv("GOCACHE", tg.path("cache"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that second vet reuses cgo-derived inputs.
|
|
||||||
// The first command could be build instead of vet,
|
|
||||||
// except that if the cache is empty and there's a net.a
|
|
||||||
// in GOROOT/pkg, the build will not bother to regenerate
|
|
||||||
// and cache the cgo outputs, whereas vet always will.
|
|
||||||
tg.run("vet", "os/user")
|
|
||||||
tg.run("vet", "-x", "os/user")
|
|
||||||
tg.grepStderrNot(`^(clang|gcc)`, "should not have run compiler")
|
|
||||||
tg.grepStderrNot(`[\\/]cgo `, "should not have run cgo")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIssue22588(t *testing.T) {
|
func TestIssue22588(t *testing.T) {
|
||||||
// Don't get confused by stderr coming from tools.
|
// Don't get confused by stderr coming from tools.
|
||||||
tg := testgo(t)
|
tg := testgo(t)
|
||||||
|
@ -292,6 +292,17 @@ Script:
|
|||||||
}).(bool)
|
}).(bool)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(cond.tag, "GODEBUG:") {
|
||||||
|
value := strings.TrimPrefix(cond.tag, "GODEBUG:")
|
||||||
|
parts := strings.Split(os.Getenv("GODEBUG"), ",")
|
||||||
|
for _, p := range parts {
|
||||||
|
if strings.TrimSpace(p) == value {
|
||||||
|
ok = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
if !imports.KnownArch[cond.tag] && !imports.KnownOS[cond.tag] && cond.tag != "gc" && cond.tag != "gccgo" {
|
if !imports.KnownArch[cond.tag] && !imports.KnownOS[cond.tag] && cond.tag != "gc" && cond.tag != "gccgo" {
|
||||||
ts.fatalf("unknown condition %q", cond.tag)
|
ts.fatalf("unknown condition %q", cond.tag)
|
||||||
}
|
}
|
||||||
|
1
src/cmd/go/testdata/script/README
vendored
1
src/cmd/go/testdata/script/README
vendored
@ -77,6 +77,7 @@ should only run when the condition is satisfied. The available conditions are:
|
|||||||
- [root] for os.Geteuid() == 0
|
- [root] for os.Geteuid() == 0
|
||||||
- [symlink] for testenv.HasSymlink()
|
- [symlink] for testenv.HasSymlink()
|
||||||
- [exec:prog] for whether prog is available for execution (found by exec.LookPath)
|
- [exec:prog] for whether prog is available for execution (found by exec.LookPath)
|
||||||
|
- [GODEBUG:value] for whether value is one of the comma-separated entries in the GODEBUG variable
|
||||||
|
|
||||||
A condition can be negated: [!short] means to run the rest of the line
|
A condition can be negated: [!short] means to run the rest of the line
|
||||||
when testing.Short() is false. Multiple conditions may be given for a single
|
when testing.Short() is false. Multiple conditions may be given for a single
|
||||||
|
22
src/cmd/go/testdata/script/cache_vet.txt
vendored
Normal file
22
src/cmd/go/testdata/script/cache_vet.txt
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
env GO111MODULE=off
|
||||||
|
|
||||||
|
[short] skip
|
||||||
|
[GODEBUG:gocacheverify] skip
|
||||||
|
[gccgo] skip # gccgo has no standard packages
|
||||||
|
|
||||||
|
# Start with a clean build cache:
|
||||||
|
# test failures may be masked if the cache has just the right entries already.
|
||||||
|
env GOCACHE=$WORK/cache
|
||||||
|
|
||||||
|
# Run 'go vet os/user' once to warm up the cache.
|
||||||
|
go vet os/user
|
||||||
|
|
||||||
|
# Check that second vet reuses cgo-derived inputs.
|
||||||
|
# The first command could be build instead of vet,
|
||||||
|
# except that if the cache is empty and there's a net.a
|
||||||
|
# in GOROOT/pkg, the build will not bother to regenerate
|
||||||
|
# and cache the cgo outputs, whereas vet always will.
|
||||||
|
|
||||||
|
go vet -x os/user
|
||||||
|
! stderr '^(clang|gcc)' # should not have run compiler
|
||||||
|
! stderr '[\\/]cgo ' # should not have run cgo
|
Loading…
Reference in New Issue
Block a user