Skip to content

Commit

Permalink
add Signaled field to Report
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Dec 18, 2017
1 parent ad7a0cd commit cc23d22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion horenso.go
Expand Up @@ -32,6 +32,7 @@ type Report struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode *int `json:"exitCode,omitempty"`
Signaled bool `json:"signaled"`
Result string `json:"result"`
Hostname string `json:"hostname"`
Pid *int `json:"pid,omitempty"`
Expand Down Expand Up @@ -112,8 +113,14 @@ func (o *opts) run(args []string) (Report, error) {
r.EndAt = now()
ex := wrapcommander.ResolveExitCode(err)
r.ExitCode = &ex
r.Result = fmt.Sprintf("command exited with code: %d", *r.ExitCode)
if *r.ExitCode > 128 {
w, ok := wrapcommander.ErrorToWaitStatus(err)
if ok {
r.Signaled = w.Signaled()
}
}
r.Result = fmt.Sprintf("command exited with code: %d", *r.ExitCode)
if r.Signaled {
r.Result = fmt.Sprintf("command died with signal: %d", *r.ExitCode&127)
}
r.Stdout = bufStdout.String()
Expand Down
3 changes: 2 additions & 1 deletion horenso_test.go
Expand Up @@ -193,5 +193,6 @@ func deepEqual(r1, r2 Report) bool {
*r1.ExitCode == *r2.ExitCode &&
r1.Result == r2.Result &&
*r1.Pid == *r2.Pid &&
r1.Hostname == r2.Hostname
r1.Hostname == r2.Hostname &&
r1.Signaled == r2.Signaled
}

0 comments on commit cc23d22

Please sign in to comment.