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

Ensure we still rerun tests when there are warnings #235

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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