-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of verbose testing #147
Conversation
3a81c24
to
d1b245f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general, with a couple of minor suggestions, thanks!
report.go
Outdated
if !testingVerbose() && strings.Count(v, "\n") >= longValueLines { | ||
v = "<suppressed because too long, use -v for the full output>" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"because too long" reads a bit awkwardly. Also, maybe it might be nice to say just how long it is.
Something like this maybe?
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 omitted)>", n) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
report.go
Outdated
@@ -58,6 +71,11 @@ func writeError(w io.Writer, err error, p reportParams) { | |||
var v string | |||
if u, ok := value.(Unquoted); ok { | |||
v = string(u) | |||
} else if s, ok := value.(SuppressedIfLong); ok { | |||
v = p.format(s.Value) | |||
if !testingVerbose() && strings.Count(v, "\n") >= longValueLines { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than calling through the global variable (something we've been quite careful to avoid in other tests, cf WithVerbosity
), could we not maybe add the verbosity to reportParams
somehow?
Only suppress got/want arguments for CmpEquals (and derived checkers) if the pretty printed representation is small enough and
-v
is not provided.