Skip to content

Commit

Permalink
Quote test names before they are used within the regex to rerun
Browse files Browse the repository at this point in the history
  • Loading branch information
noBlubb committed Jun 14, 2023
1 parent 6d53517 commit dd19271
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/rerunfails.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"regexp"
"sort"

"gotest.tools/gotestsum/testjson"
Expand Down Expand Up @@ -137,9 +138,9 @@ func (r *failureRecorder) count() int {
func goTestRunFlagForTestCase(test testjson.TestName) string {
if test.IsSubTest() {
root, sub := test.Split()
return "-test.run=^" + root + "$/^" + sub + "$"
return "-test.run=^" + regexp.QuoteMeta(root) + "$/^" + regexp.QuoteMeta(sub) + "$"
}
return "-test.run=^" + test.Name() + "$"
return "-test.run=^" + regexp.QuoteMeta(test.Name()) + "$"
}

func writeRerunFailsReport(opts *options, exec *testjson.Execution) error {
Expand Down

0 comments on commit dd19271

Please sign in to comment.