cmd/cover, cmd/covdata: actually delete temp dirs

The code was using defer in TestMain, but was also calling os.Exit,
which meant that the deferred functions did not run.
TestMain does not require calling os.Exit, so stop doing it.

Change-Id: I25ca64c36acf65dae3dc3f46e5fa513b9460a8e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/740781
Reviewed-by: Than McIntosh <thanm@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Ian Lance Taylor 2026-01-30 15:52:19 -08:00 committed by Gopher Robot
parent 1c9abbdc8e
commit 07f7f8ca52
2 changed files with 2 additions and 2 deletions

View file

@ -50,7 +50,7 @@ func TestMain(m *testing.M) {
fmt.Fprintf(os.Stderr, "debug: preserving tmpdir %s\n", topTmpdir)
}
os.Setenv("CMDCOVDATA_TEST_RUN_MAIN", "true")
os.Exit(m.Run())
m.Run()
}
var tdmu sync.Mutex

View file

@ -87,7 +87,7 @@ func TestMain(m *testing.M) {
fmt.Fprintf(os.Stderr, "debug: preserving tmpdir %s\n", topTmpdir)
}
os.Setenv("CMDCOVER_TEST_RUN_MAIN", "normal")
os.Exit(m.Run())
m.Run()
}
var tdmu sync.Mutex