Upgrade littlecheck to print all error lines

In #7459, asan printed error output. However, because we had a failure
on stdout already, littlecheck would only print the first unmatched
line from stderr, leading to output like

```
additional output on stderr:1:

    =================================================================
```

Which is of course entirely useless.

So in that case we just let it print *all* unmatched stderr lines, so
you'd get the full asan output, which presumably is of more use.

This upgrades littlecheck to 5f7deafcea4e58dd3d369eae069a3781bb6ce75e.
This commit is contained in:
Fabian Homborg 2020-11-14 13:15:33 +01:00
parent 3e3a42c127
commit 64b5a22274

View file

@ -156,7 +156,7 @@ class TestFailure(object):
self.line = line
self.check = check
self.testrun = testrun
self.error_annotation_line = None
self.error_annotation_lines = None
# The output that comes *after* the failure.
self.after = after
self.before = before
@ -209,28 +209,29 @@ class TestFailure(object):
" {BOLD}{output_line}{RESET}",
"",
]
if self.error_annotation_line:
fields["error_annotation"] = self.error_annotation_line.text
fields["error_annotation_lineno"] = self.error_annotation_line.number
if self.error_annotation_lines:
fields["error_annotation"] = " ".join([x.text for x in self.error_annotation_lines])
fields["error_annotation_lineno"] = str(self.error_annotation_lines[0].number)
if len(self.error_annotation_lines) > 1:
fields["error_annotation_lineno"] += ":" + str(self.error_annotation_lines[-1].number)
fmtstrs += [
" additional output on stderr:{error_annotation_lineno}:",
" {BOLD}{error_annotation}{RESET}",
]
if self.before or self.after:
fmtstrs += [" Context:"]
if self.before:
fields["before_output"] = " ".join(self.before)
fields["additional_output"] = " ".join(self.after[:afterlines])
fields["before_output"] = " ".join(self.before)[:-1]
fmtstrs += [" {BOLD}{before_output}"]
fmtstrs += [
" Context:",
" {BOLD}{before_output} {RED}{output_line}{RESET} <= does not match '{LIGHTBLUE}{input_line}{RESET}'",
" {BOLD}{additional_output}{RESET}",
]
elif self.after:
fields["additional_output"] = " ".join(self.after[:afterlines])
fmtstrs += [
" Context:",
" {RED}{output_line}{RESET} <= does not match '{LIGHTBLUE}{input_line}{RESET}'",
" {BOLD}{additional_output}{RESET}"
]
if self.after is not None:
fields["additional_output"] = " ".join(self.after[:afterlines])
fmtstrs += [" {BOLD}{additional_output}{RESET}"]
fmtstrs += [" when running command:", " {subbed_command}"]
return "\n".join(fmtstrs).format(**fields)
@ -358,7 +359,10 @@ class TestRun(object):
# non-matching or unmatched stderr text, then annotate the outfail
# with it.
if outfail and errfail and errfail.line:
outfail.error_annotation_line = errfail.line
outfail.error_annotation_lines = errlines[errfail.line.number - 1:]
# Trim a trailing newline
if outfail.error_annotation_lines[-1].text == "\n":
del outfail.error_annotation_lines[-1]
return outfail if outfail else errfail