Add environment variable to keep data for failed tests

Useful to keep command output and maybe-still-relevant checkpoints around.
This commit is contained in:
Matthew Riley 2018-01-06 21:05:42 -08:00
parent 594ccf755a
commit ff10b65f3a

View file

@ -301,8 +301,15 @@ func testLifeCycleInitAndDestroy(
defer func() {
if t.Failed() {
// Keep temp dir around
// Test failed -- keep temporary files around for debugging.
// Maybe also copy to "failed tests" directory.
failedTestsDir := os.Getenv("PULUMI_FAILED_TESTS_DIR")
if failedTestsDir != "" {
dest := filepath.Join(failedTestsDir, t.Name()+uniqueSuffix())
contract.IgnoreError(fsutil.CopyFile(dest, dir, nil))
}
} else {
// Test passed -- delete temporary files.
contract.IgnoreError(os.RemoveAll(dir))
}
}()