From 60de4967411fba6270c36e9ad8c2f792130939d2 Mon Sep 17 00:00:00 2001 From: Elliot Chance Date: Mon, 14 Aug 2017 21:15:06 +1000 Subject: [PATCH] Fix a bug where exit code 101 and 102 would not cause go test to fail --- main_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main_test.go b/main_test.go index 532ad23fc..ebf4eaac8 100644 --- a/main_test.go +++ b/main_test.go @@ -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.