Skip to content

Commit

Permalink
roachtest: check logger file before dereference
Browse files Browse the repository at this point in the history
Release note: none
Epic: none
  • Loading branch information
Miral Gadani committed Mar 8, 2023
1 parent b941934 commit 8a93c31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cmd/roachtest/test_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,13 @@ func (t *testImpl) addFailure(depth int, format string, args ...interface{}) {
// We don't actually log through this logger since it adds an unrelated
// file:line caller (namely ours). The error already has stack traces
// so it's better to write only it to the file to avoid confusion.
path := cl.File.Name()
if cl.File != nil {
path := cl.File.Name()
if len(path) > 0 {
_ = os.WriteFile(path, []byte(fmt.Sprintf("%+v", reportFailure.squashedErr)), 0644)
}
}
cl.Close() // we just wanted the filename
_ = os.WriteFile(path, []byte(fmt.Sprintf("%+v", reportFailure.squashedErr)), 0644)
}
}

Expand Down

0 comments on commit 8a93c31

Please sign in to comment.