Skip to content

Commit

Permalink
Ensure we still rerun tests when there are warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ashanbrown authored and dnephin committed Mar 30, 2022
1 parent d9cd222 commit 90a5a10
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cmd/main_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,29 @@ func TestE2E_MaxFails_EndTestRun(t *testing.T) {
)
golden.Assert(t, out, "e2e/expected/"+t.Name())
}

func TestE2E_IgnoresWarnings(t *testing.T) {
if testing.Short() {
t.Skip("too slow for short run")
}

flags, opts := setupFlags("gotestsum")
args := []string{"--rerun-fails=1", "--packages=./testdata/e2e/ignore_warnings/", "--", "-tags=testdata",
"-cover", "-coverpkg=github.com/pkg/errors"}
assert.NilError(t, flags.Parse(args))
opts.args = flags.Args()

bufStdout := new(bytes.Buffer)
opts.stdout = bufStdout
bufStderr := new(bytes.Buffer)
opts.stderr = bufStderr

err := run(opts)
assert.Error(t, err, "exit status 1")
out := text.ProcessLines(t, bufStdout,
text.OpRemoveSummaryLineElapsedTime,
text.OpRemoveTestElapsedTime,
filepath.ToSlash, // for windows
)
golden.Assert(t, out, "e2e/expected/"+t.Name())
}
12 changes: 12 additions & 0 deletions cmd/testdata/e2e/expected/TestE2E_IgnoresWarnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
✖ cmd/testdata/e2e/ignore_warnings

DONE 1 tests, 1 failure

✖ cmd/testdata/e2e/ignore_warnings

=== Failed
=== FAIL: cmd/testdata/e2e/ignore_warnings TestIgnoreWarnings

=== FAIL: cmd/testdata/e2e/ignore_warnings TestIgnoreWarnings (re-run 1)

DONE 2 runs, 2 tests, 2 failures
1 change: 1 addition & 0 deletions cmd/testdata/e2e/ignore_warnings/ignore_warnings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package ignore_warnings
7 changes: 7 additions & 0 deletions cmd/testdata/e2e/ignore_warnings/ignore_warnings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ignore_warnings

import "testing"

func TestIgnoreWarnings(t *testing.T) {
t.Fail()
}
3 changes: 3 additions & 0 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ func readStderr(config ScanConfig, execution *Execution) error {
if isGoModuleOutput(line) {
continue
}
if strings.HasPrefix(line, "warning:") {
continue
}
execution.addError(line)
}
if err := scanner.Err(); err != nil {
Expand Down

0 comments on commit 90a5a10

Please sign in to comment.