dev: hack/update-expected.sh should generate missing file

Don't treat a failure to read a file as an error, if we are supposed
to be generating that file.
This commit is contained in:
Justin Santa Barbara 2019-12-14 22:13:28 -05:00
parent c54394c0e3
commit 58dccb0c5d
1 changed files with 3 additions and 1 deletions

View File

@ -111,7 +111,9 @@ func AssertMatchesFile(t *testing.T, actual string, p string) {
expectedBytes, err := ioutil.ReadFile(p)
if err != nil {
t.Fatalf("error reading file %q: %v", p, err)
if !os.IsNotExist(err) || os.Getenv("HACK_UPDATE_EXPECTED_IN_PLACE") == "" {
t.Fatalf("error reading file %q: %v", p, err)
}
}
expected := strings.TrimSpace(string(expectedBytes))