From 040d7f6b09a76d3b0ad96366a597167cf95df428 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Sun, 13 Sep 2020 13:03:29 -0400 Subject: [PATCH] Fix rerun-fails with compiled test binary Both the compiled binary and the 'go test' command accept -test.run, but only 'go test' accepts -run. Change the flag so that rerun works with a compiled binary. --- README.md | 2 +- rerunfails.go | 4 ++-- rerunfails_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b5c91a7..48cd9eca 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ Note that using `--rerun-fails` may require the use of other flags, depending on how you specify args to `go test`: * when used with `--raw-command` the re-run will pass additional arguments to - the command. The first arg is a `-run` flag with a regex that matches the test to re-run, + the command. The first arg is a `-test.run` flag with a regex that matches the test to re-run, and second is the name of a go package. These additional args can be passed to `go test`, or a test binary. * when used with any `go test` args (anything after `--` on the command line), the list of diff --git a/rerunfails.go b/rerunfails.go index cf222397..56845a5d 100644 --- a/rerunfails.go +++ b/rerunfails.go @@ -126,9 +126,9 @@ func (r *failureRecorder) count() int { func goTestRunFlagForTestCase(name string) string { root, sub := testjson.SplitTestName(name) if sub == "" { - return "-run=^" + name + "$" + return "-test.run=^" + name + "$" } - return "-run=^" + root + "$/^" + sub + "$" + return "-test.run=^" + root + "$/^" + sub + "$" } func writeRerunFailsReport(opts *options, exec *testjson.Execution) error { diff --git a/rerunfails_test.go b/rerunfails_test.go index 225d431f..242e77ba 100644 --- a/rerunfails_test.go +++ b/rerunfails_test.go @@ -49,11 +49,11 @@ func TestGoTestRunFlagFromTestCases(t *testing.T) { var testCases = map[string]testCase{ "root test case": { input: "TestOne", - expected: "-run=^TestOne$", + expected: "-test.run=^TestOne$", }, "sub test case": { input: "TestOne/SubtestA", - expected: "-run=^TestOne$/^SubtestA$", + expected: "-test.run=^TestOne$/^SubtestA$", }, } for name := range testCases {