testing: Don't cleanup tempfiles if the test failed

As suggestion by Paul Brousseau, It might be useful to leave the directory in
place if the test fails.

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
pull/8829/head
Li Zhijian 5 years ago
parent 3350760d85
commit 6230cb94a9

@ -45,7 +45,11 @@ func TempDir(t *testing.T) string {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.RemoveAll(d) })
t.Cleanup(func() {
if !t.Failed() {
os.RemoveAll(d)
}
})
return d
}

Loading…
Cancel
Save