Skip to content

Commit

Permalink
e2e: show command output on failure
Browse files Browse the repository at this point in the history
When a command fails, it's nice to have the full output, as it contains
diagnostic information. The status code isn't sufficient for debugging.
  • Loading branch information
Mahmood Ali authored and backspace committed Jan 22, 2021
1 parent 92d4154 commit d96991b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions e2e/e2eutil/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import (
// Command sends a command line argument to Nomad and returns the unbuffered
// stdout as a string (or, if there's an error, the stderr)
func Command(cmd string, args ...string) (string, error) {
out, err := exec.Command(cmd, args...).CombinedOutput()
return string(out), err
bytes, err := exec.Command(cmd, args...).CombinedOutput()
out := string(bytes)
if err != nil {
return out, fmt.Errorf("command %v %v failed: %v\nOutput: %v", cmd, args, err, out)
}
return out, err
}

// GetField returns the value of an output field (ex. the "Submit Date" field
Expand Down

0 comments on commit d96991b

Please sign in to comment.