Skip to content

Commit

Permalink
Merge pull request #235 from ashanbrown/asb/ignore-warnings
Browse files Browse the repository at this point in the history
Ensure we still rerun tests when there are warnings
  • Loading branch information
dnephin authored Mar 30, 2022
2 parents d9cd222 + bba51ac commit 528a3fd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/main_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,33 @@ 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/",
"--format=testname",
"--", "-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())
}
20 changes: 20 additions & 0 deletions cmd/testdata/e2e/expected/TestE2E_IgnoresWarnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== RUN TestIgnoreWarnings
--- FAIL: TestIgnoreWarnings
FAIL cmd/testdata/e2e/ignore_warnings.TestIgnoreWarnings
coverage: [no statements]
FAIL cmd/testdata/e2e/ignore_warnings

DONE 1 tests, 1 failure

=== RUN TestIgnoreWarnings
--- FAIL: TestIgnoreWarnings
FAIL cmd/testdata/e2e/ignore_warnings.TestIgnoreWarnings (re-run 1)
coverage: [no statements]
FAIL 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 528a3fd

Please sign in to comment.