Allow failure to cleanup

This commit is contained in:
Ian Wahbe 2021-08-31 00:25:50 -07:00
parent 703104e412
commit 59f88030b7
4 changed files with 10 additions and 3 deletions

View file

@ -123,6 +123,13 @@ func (e *Environment) DeleteEnvironment() {
assert.NoErrorf(e, err, "cleaning up test directory %q", e.RootPath)
}
// DeleteEnvironment deletes the environment's RootPath, and everything
// underneath it. It tolerates failing to delete the environment.
func (e *Environment) DeleteEnviromentFallible() error {
e.Helper()
return os.RemoveAll(e.RootPath)
}
// DeleteIfNotFailed deletes the environment's RootPath if the test hasn't failed. Otherwise
// keeps the files around for aiding debugging.
func (e *Environment) DeleteIfNotFailed() {

View file

@ -581,7 +581,7 @@ func TestAboutDotnet(t *testing.T) {
e := ptesting.NewEnvironment(t)
defer func() {
if !t.Failed() {
e.DeleteEnvironment()
e.DeleteEnvironmentFallible()
}
}()
e.ImportDirectory(dir)

View file

@ -748,7 +748,7 @@ func TestAboutGo(t *testing.T) {
e := ptesting.NewEnvironment(t)
defer func() {
if !t.Failed() {
e.DeleteEnvironment()
e.DeleteEnvironmentFallible()
}
}()
e.ImportDirectory(dir)

View file

@ -1132,7 +1132,7 @@ func TestAboutPython(t *testing.T) {
e := ptesting.NewEnvironment(t)
defer func() {
if !t.Failed() {
e.DeleteEnvironment()
e.DeleteEnvironmentFallible()
}
}()
e.ImportDirectory(dir)