Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion reexec/reexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func TestCommandContext(t *testing.T) {
doc string
cmdAndArgs []string
cancel bool
timeout time.Duration
expOut string
expError error
expExit int
Expand Down Expand Up @@ -321,6 +322,7 @@ func TestCommandContext(t *testing.T) {
{
doc: "context timeout",
cmdAndArgs: []string{testReExec3},
timeout: 100 * time.Millisecond,
expOut: "Hello test-reexec3",
expError: testError,
},
Expand All @@ -334,8 +336,13 @@ func TestCommandContext(t *testing.T) {

for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
if tc.timeout != 0 {
var cancelTimeout context.CancelFunc
ctx, cancelTimeout = context.WithTimeout(ctx, tc.timeout)
defer cancelTimeout()
}

cmd := reexec.CommandContext(ctx, tc.cmdAndArgs...)
if !reflect.DeepEqual(cmd.Args, tc.cmdAndArgs) {
Expand Down
Loading