Skip to content

Commit

Permalink
Don't attempt to format a non-format string
Browse files Browse the repository at this point in the history
It can lead to strange output when the string containts a %
  • Loading branch information
dnephin committed May 15, 2020
1 parent 7a39237 commit 471a59a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ func Errorf(format string, args ...interface{}) {
out.WriteString(fmt.Sprintf(format, args...))
out.WriteString("\n")
}

// Error prints the message to stderr, with a red ERROR prefix.
func Error(msg string) {
if level < ErrorLevel {
return
}
out.WriteString(color.RedString("ERROR "))
out.WriteString(msg)
out.WriteString("\n")
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
// the same status code
os.Exit(ExitCodeWithDefault(err))
default:
log.Errorf(err.Error())
log.Error(err.Error())
os.Exit(3)
}
}
Expand Down
2 changes: 1 addition & 1 deletion testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func isGoModuleOutput(scannerText string) bool {
func parseEvent(raw []byte) (TestEvent, error) {
// TODO: this seems to be a bug in the `go test -json` output
if bytes.HasPrefix(raw, []byte("FAIL")) {
log.Warnf(string(raw))
log.Warnf("invalid TestEvent: %v", string(raw))
return TestEvent{}, errBadEvent
}

Expand Down

0 comments on commit 471a59a

Please sign in to comment.