Skip to content

Commit

Permalink
Better message for suppressed output
Browse files Browse the repository at this point in the history
  • Loading branch information
frankban committed Nov 13, 2022
1 parent d1b245f commit 99512ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,15 @@ want:
}, {
about: "CmpEquals: different values, long output",
checker: qt.CmpEquals(),
got: []interface{}{cmpEqualsWant, "extra line 1", "extra line 2"},
got: []interface{}{cmpEqualsWant, "extra line 1", "extra line 2", "extra line 3"},
args: []interface{}{[]interface{}{cmpEqualsWant, "extra line 1"}},
expectedCheckFailure: fmt.Sprintf(`
error:
values are not deep equal
diff (-got +want):
%s
got:
<suppressed because too long, use -v for the full output>
<suppressed due to length (11 lines), use -v for full output>
want:
[]interface {}{
struct { Strings []interface {}; Ints []int }{
Expand All @@ -456,7 +456,7 @@ want:
},
"extra line 1",
}
`, diff([]interface{}{cmpEqualsWant, "extra line 1", "extra line 2"}, []interface{}{cmpEqualsWant, "extra line 1"})),
`, diff([]interface{}{cmpEqualsWant, "extra line 1", "extra line 2", "extra line 3"}, []interface{}{cmpEqualsWant, "extra line 1"})),
}, {
about: "CmpEquals: different values: long output and verbose",
checker: qt.CmpEquals(),
Expand Down Expand Up @@ -677,9 +677,9 @@ error:
diff (-got +want):
%s
got:
<suppressed because too long, use -v for the full output>
<suppressed due to length (15 lines), use -v for full output>
want:
<same as "got">
<suppressed due to length (16 lines), use -v for full output>
`, diff([]interface{}{cmpEqualsWant, cmpEqualsWant}, []interface{}{cmpEqualsWant, cmpEqualsWant, 42})),
}, {
about: "DeepEquals: different values: long output and verbose",
Expand Down
6 changes: 4 additions & 2 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func writeError(w io.Writer, err error, p reportParams) {
v = string(u)
} else if s, ok := value.(SuppressedIfLong); ok {
v = p.format(s.Value)
if !testingVerbose() && strings.Count(v, "\n") >= longValueLines {
v = "<suppressed because too long, use -v for the full output>"
if !testingVerbose() {
if n := strings.Count(v, "\n"); n > longValueLines {
v = fmt.Sprintf("<suppressed due to length (%d lines), use -v for full output>", n)
}
}
} else {
v = p.format(value)
Expand Down

0 comments on commit 99512ee

Please sign in to comment.