Fix a bug where exit code 101 and 102 would not cause go test to fail
@@ -92,6 +92,14 @@ func TestIntegrationScripts(t *testing.T) {
err = cmd.Run()
cProgram.isZero = err == nil
+ // Check for special exit codes that signal that tests have failed.
+ if exitError, ok := err.(*exec.ExitError); ok {
+ exitStatus := exitError.Sys().(syscall.WaitStatus).ExitStatus()
+ if exitStatus == 101 || exitStatus == 102 {
+ t.Fatal(cProgram.stdout.String())
+ }
+ }
+
mainFileName = "main_test.go"
programArgs := ProgramArgs{
@@ -136,14 +144,6 @@ func TestIntegrationScripts(t *testing.T) {
err = cmd.Run()
goProgram.isZero = err == nil
- // Check for special exit codes that signal that tests have failed.
- if exitError, ok := err.(*exec.ExitError); ok {
- exitStatus := exitError.Sys().(syscall.WaitStatus).ExitStatus()
- if exitStatus == 101 || exitStatus == 102 {
- t.Fatal(goProgram.stdout.String())
- }
- }
-
// Check stderr. "go test" will produce warnings when packages are
// not referenced as dependencies. We need to strip out these
// warnings so it doesn't effect the comparison.
