Skip to content
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

Merged
merged 2 commits into from
Nov 19, 2022
Merged

Conversation

frankban
Copy link
Owner

Only suppress got/want arguments for CmpEquals (and derived checkers) if the pretty printed representation is small enough and -v is not provided.

Copy link
Contributor

@rogpeppe rogpeppe left a 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
Comment on lines 76 to 78
if !testingVerbose() && strings.Count(v, "\n") >= longValueLines {
v = "<suppressed because too long, use -v for the full output>"
}
Copy link
Contributor

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?

Suggested change
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)
}
}

Copy link
Owner Author

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 {
Copy link
Contributor

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?

@frankban frankban merged commit 1ab87ea into master Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants