This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main: do not print *exec.ExitError for -run (#61)
Instead, rely on the program to output something sensible on stdout/stderr. Exit with the exit code from the program we ran. For this we use a local version of *os.ProcessState.ExitStatus() https://go-review.googlesource.com/c/go/+/125443/ which is due to land in Go 1.12
- Loading branch information
Showing
6 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// ExitCode returns the exit code of the exited process, or -1 | ||
// if the process hasn't exited or was terminated by a signal. | ||
func ExitCode(p *os.ProcessState) int { | ||
// return -1 if the process hasn't started. | ||
if p == nil { | ||
return -1 | ||
} | ||
return p.Sys().(syscall.WaitStatus).ExitStatus() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// ExitCode returns the exit code of the exited process, or -1 | ||
// if the process hasn't exited or was terminated by a signal. | ||
func ExitCode(p *os.ProcessState) int { | ||
// return -1 if the process hasn't started. | ||
if p == nil { | ||
return -1 | ||
} | ||
return p.Sys().(syscall.WaitStatus).ExitStatus() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
! gobin -run example.com/fail | ||
stdout '^This will fail$' | ||
stderr '^exit status 42$' | ||
stderr '^It''s bad$' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters