Skip to content

Commit

Permalink
Fix append bug in --rerun-fails with -run flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Nov 3, 2023
1 parent b8d5d8f commit 2d52d37
Show file tree
Hide file tree
Showing 2 changed files with 17 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
16 changes: 16 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ 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 2d52d37

Please sign in to comment.