Skip to content

Commit 712c631

Browse files
committed
Add more comments on how errors are handled in execRunCommand
1 parent 24bd9a5 commit 712c631

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cli/run_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ func execRunCommand(envVars *[]string, arg ...string) (bytes.Buffer, error) {
144144
}
145145

146146
// Wait for the command to finish or for the context to timeout
147+
// We use Wait() instead of Run() so that we can capture the error
148+
// For example:
149+
// FOO=bar ./build/darwin/amd64/dispatch run -- printenv FOO
150+
// This will exit with
151+
// Error: command 'printenv FOO' exited unexpectedly
152+
// but also it will print...
153+
// printenv | bar
154+
// to the logs and that is exactly what we want to test
155+
// If context timeout occurs, than something went wrong
156+
// and `dispatch run` is running indefinitely.
147157
if err := cmd.Wait(); err != nil {
148158
// Check if the error is due to context timeout (command running too long)
149159
if ctx.Err() == context.DeadlineExceeded {

0 commit comments

Comments
 (0)