Skip to content

Commit

Permalink
Makes CmdOpts.timeout public
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jun 27, 2019
1 parent 04d9e03 commit 362b93e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func RunCommandExt(cmd *exec.Cmd, opts CmdOpts) (string, error) {

select {
//noinspection ALL
case <- timoutCh:
case <-timoutCh:
_ = cmd.Process.Kill()
output := stdout.String()
logCtx.WithFields(log.Fields{"duration": time.Since(start)}).Debug(output)
Expand Down
2 changes: 1 addition & 1 deletion exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRunCommandTimeout(t *testing.T) {
log.SetLevel(log.DebugLevel)
defer log.SetLevel(log.InfoLevel)

output, err := RunCommand("sh", CmdOpts{timeout: 500 * time.Millisecond}, "-c", "echo my-output && echo my-error >&2 && sleep 2")
output, err := RunCommand("sh", CmdOpts{Timeout: 500 * time.Millisecond}, "-c", "echo my-output && echo my-error >&2 && sleep 2")
assert.Equal(t, output, "my-output")
assert.EqualError(t, err, "`sh -c echo my-output && echo my-error >&2 && sleep 2` timeout after 500ms")

Expand Down

0 comments on commit 362b93e

Please sign in to comment.