Skip to content

Commit

Permalink
summary: only filter out framing messages that match the test name
Browse files Browse the repository at this point in the history
Previously the summary would filter out all messages which include
a '--- FAIL' or '--- SKIP'. With this change only the framing
message for the test case will be removed.

This change is in preparation for working around the test2json
output misattribution bug, which will result in the summary
including the output for all subtests in some cases.

After that bug is fixed, and the workaround is removed, it may still
be valuable to be more strict about this filtering.
  • Loading branch information
dnephin committed Apr 21, 2020
1 parent 1233c41 commit 2403f71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions testjson/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func writeTestCaseSummary(out io.Writer, execution executionSummary, conf testCa
tc.Test,
FormatDurationAsSeconds(tc.Elapsed, 2))
for _, line := range execution.OutputLines(tc.Package, tc.Test) {
if isRunLine(line) || conf.filter(line) {
if isRunLine(line) || conf.filter(tc.Test, line) {
continue
}
fmt.Fprint(out, line)
Expand All @@ -186,7 +186,7 @@ func writeTestCaseSummary(out io.Writer, execution executionSummary, conf testCa
type testCaseFormatConfig struct {
header string
prefix string
filter func(string) bool
filter func(testName string, line string) bool
getter func(executionSummary) []TestCase
}

Expand All @@ -195,8 +195,8 @@ func formatFailed() testCaseFormatConfig {
return testCaseFormatConfig{
header: withColor("Failed"),
prefix: withColor("FAIL"),
filter: func(line string) bool {
return strings.HasPrefix(line, "--- FAIL: Test")
filter: func(testName string, line string) bool {
return strings.HasPrefix(line, "--- FAIL: "+testName+" ")
},
getter: func(execution executionSummary) []TestCase {
return execution.Failed()
Expand All @@ -209,8 +209,8 @@ func formatSkipped() testCaseFormatConfig {
return testCaseFormatConfig{
header: withColor("Skipped"),
prefix: withColor("SKIP"),
filter: func(line string) bool {
return strings.HasPrefix(line, "--- SKIP: Test")
filter: func(testName string, line string) bool {
return strings.HasPrefix(line, "--- SKIP: "+testName+" ")
},
getter: func(execution executionSummary) []TestCase {
return execution.Skipped()
Expand Down
4 changes: 2 additions & 2 deletions testjson/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ func TestPrintSummary_WithFailures(t *testing.T) {
output: map[string]map[string][]string{
"TestFileDo": multiLine(`=== RUN TestFileDo
Some stdout/stderr here
--- FAIL: TestFailDo (1.41s)
--- FAIL: TestFileDo (1.41s)
do_test.go:33 assertion failed
`),
"TestFileDoError": multiLine(`=== RUN TestFileDoError
--- FAIL: TestFailDoError (0.01s)
--- FAIL: TestFileDoError (0.01s)
do_test.go:50 assertion failed: expected nil error, got WHAT!
`),
"": multiLine("FAIL\n"),
Expand Down

0 comments on commit 2403f71

Please sign in to comment.