1
0
Fork 0

Wait for command to exit before testing the exit status o.o

This commit is contained in:
Sebastian Schulze 2022-03-04 20:16:32 +01:00
parent 86d77a0cee
commit f2c80f1a2d
Signed by: bascht
GPG Key ID: 5BCB1D3B4D38A35A
2 changed files with 6 additions and 7 deletions

View File

@ -41,6 +41,6 @@ func (command *Command) NewScanner() *bufio.Scanner {
return bufio.NewScanner(merged)
}
func (command *Command) ExitCode() int {
return command.cmd.ProcessState.ExitCode()
func (command *Command) RanSuccessful() bool {
return command.cmd.ProcessState.ExitCode() == 0
}

View File

@ -30,12 +30,11 @@ func TestCommandOutput(t *testing.T) {
t.Logf("Found correct output of %v", text)
}
}
t.Logf("COMMAND %v", command.cmd.ProcessState.ExitCode())
// TODO: Find out why this is always -1
// if command.ExitCode() != 0 {
// t.Error("Didn't run successfully", command.ExitCode())
// }
command.Wait()
if ! command.RanSuccessful() {
t.Error("Didn't run successfully: ")
}
}
func TestCommandFailure(t *testing.T) {