Skip to content

Commit

Permalink
Fix -run flag building to not prefix match
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 11, 2020
1 parent 5cc60e2 commit 96d3338
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rerunfails.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ func (r *failureRecorder) count() int {

func goTestRunFlagFromTestCases(tcs []string) string {
buf := new(strings.Builder)
buf.WriteString("-run=")
buf.WriteString("-run=^(")
for i, tc := range tcs {
if i != 0 {
buf.WriteString("|")
}
buf.WriteString(tc)
}
buf.WriteString(")$")
return buf.String()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SEED: 0
--- FAIL: TestFailsOften
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky
PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
Expand Down Expand Up @@ -61,4 +63,4 @@ SEED: 2
flaky_test.go:65: not this time


DONE 9 tests, 6 failures
DONE 11 tests, 6 failures
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SEED: 0
TestFailsOften: flaky_test.go:65: not this time
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky
PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
Expand Down Expand Up @@ -61,4 +63,4 @@ SEED: 2
TestFailsOften: flaky_test.go:65: not this time


DONE 9 tests, 6 failures
DONE 11 tests, 6 failures
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SEED: 0
--- FAIL: TestFailsOften
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky
PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
Expand Down Expand Up @@ -73,4 +75,4 @@ SEED: 3
flaky_test.go:65: not this time


DONE 11 tests, 7 failures
DONE 13 tests, 7 failures
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SEED: 0
TestFailsOften: flaky_test.go:65: not this time
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky
PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
Expand Down Expand Up @@ -73,4 +75,4 @@ SEED: 3
TestFailsOften: flaky_test.go:65: not this time


DONE 11 tests, 7 failures
DONE 13 tests, 7 failures
4 changes: 4 additions & 0 deletions testdata/e2e/flaky/flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ func TestFailsOften(t *testing.T) {
t.Fatal("not this time")
}
}

func TestFailsOftenDoesNotPrefixMatch(t *testing.T) {}

func TestFailsSometimesDoesNotPrefixMatch(t *testing.T) {}

0 comments on commit 96d3338

Please sign in to comment.