Skip to content

Commit

Permalink
Merge pull request #382 from dnephin/fix-retry-fails-with-run-arg
Browse files Browse the repository at this point in the history
Fix append bug in --rerun-fails with -run flag
  • Loading branch information
dnephin committed Nov 4, 2023
2 parents b8d5d8f + 15b4544 commit bc98120
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func goTestCmdArgs(opts *options, rerunOpts rerunOpts) []string {
return result
}

args := opts.args
args := append([]string{}, opts.args...)
result := []string{"go", "test"}

if len(args) == 0 {
Expand Down
15 changes: 15 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,21 @@ func TestGoTestCmdArgs(t *testing.T) {
},
expected: []string{"go", "test", "-json", "-run=TestOne|TestTwo", "-count", "1", "-run", "./fails"},
})
t.Run("rerun with -run flag", func(t *testing.T) {
tc := testCase{
opts: &options{
args: []string{"-run", "TestExample", "-tags", "some", "-json"},
packages: []string{"./pkg"},
},
rerunOpts: rerunOpts{
runFlag: "-run=TestOne|TestTwo",
pkg: "./fails",
},
expected: []string{"go", "test", "-run=TestOne|TestTwo", "-tags", "some", "-json", "./fails"},
}
run(t, "first", tc)
run(t, "second", tc)
})
}

func runCase(t *testing.T, name string, fn func(t *testing.T)) {
Expand Down

0 comments on commit bc98120

Please sign in to comment.