Fix up the package test harness to avoid errors of the form
go_test.go:NNN: internal testsuite error: path(".") with no tempdir
when the "-testwork" flag is passed when running "go test".
Fixes #55874.
Change-Id: I76cc39902f51a62cb4cd0da8794b97d620fb4873
Reviewed-on: https://go-review.googlesource.com/c/go/+/434455
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
}
if !*testWork {
defer removeAll(topTmpdir)
+ } else {
+ fmt.Fprintf(os.Stderr, "TESTWORK: preserving top level tempdir %s\n", topTmpdir)
}
os.Setenv(tempEnvName(), topTmpdir)
func (tg *testgoData) cleanup() {
tg.t.Helper()
if *testWork {
- tg.t.Logf("TESTWORK=%s\n", tg.path("."))
+ if tg.tempdir != "" {
+ tg.t.Logf("TESTWORK=%s\n", tg.path("."))
+ }
return
}
for _, path := range tg.temps {