keep .got.svg files for e2ereport.sh after #310

This commit is contained in:
Gavin Nishizawa 2022-12-14 19:10:39 -08:00
parent 6337274c3d
commit 2bd3ce6c3f
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
2 changed files with 9 additions and 1 deletions

View file

@ -3,6 +3,7 @@ set -eu
export REPORT_OUTPUT="out/e2e_report.html"
rm -f $REPORT_OUTPUT
export E2E_REPORT=1
FORCE_COLOR=1 DEBUG=1 go run ./e2etests/report/main.go "$@";

View file

@ -131,7 +131,11 @@ func run(t *testing.T, tc testCase) {
assert.Success(t, err)
err = ioutil.WriteFile(pathGotSVG, svgBytes, 0600)
assert.Success(t, err)
defer os.Remove(pathGotSVG)
// if running from e2ereport.sh, we want to keep .got.svg on a failure
forReport := os.Getenv("E2E_REPORT") != ""
if !forReport {
defer os.Remove(pathGotSVG)
}
var xmlParsed interface{}
err = xml.Unmarshal(svgBytes, &xmlParsed)
@ -143,6 +147,9 @@ func run(t *testing.T, tc testCase) {
err = diff.Testdata(filepath.Join(dataPath, "sketch"), ".svg", svgBytes)
assert.Success(t, err)
}
if forReport {
os.Remove(pathGotSVG)
}
}
}