diff --git a/testscript/cmd.go b/testscript/cmd.go index e04d26e..b694311 100644 --- a/testscript/cmd.go +++ b/testscript/cmd.go @@ -578,6 +578,7 @@ func (ts *TestScript) waitBackgroundOne(bgName string) { } // Note: ignore bg.neg, which only takes effect on the non-specific // wait command. + println(ts.file, bg.cmd.ProcessState.Success(), bg.cmd.ProcessState.Exited(), bg.cmd.ProcessState.ExitCode()) if bg.cmd.ProcessState.Success() { if bg.neg { ts.Fatalf("unexpected command success") @@ -634,6 +635,7 @@ func (ts *TestScript) waitBackground(checkStatus bool) { if !checkStatus { continue } + println(ts.file, bg.cmd.ProcessState.Success(), bg.cmd.ProcessState.Exited(), bg.cmd.ProcessState.ExitCode()) if bg.cmd.ProcessState.Success() { if bg.neg { ts.Fatalf("unexpected command success") diff --git a/testscript/testdata/interrupt_implicit.txt b/testscript/testdata/interrupt_implicit.txt new file mode 100644 index 0000000..6ea1c39 --- /dev/null +++ b/testscript/testdata/interrupt_implicit.txt @@ -0,0 +1,4 @@ +# Let testscript stop signalcatcher at the end of the testscript. + +signalcatcher & +waitfile catchsignal diff --git a/testscript/testscript.go b/testscript/testscript.go index 3fe5189..1e671d9 100644 --- a/testscript/testscript.go +++ b/testscript/testscript.go @@ -651,7 +651,12 @@ func (ts *TestScript) run() { for _, bg := range ts.background { interruptProcess(bg.cmd.Process) } - ts.cmdWait(false, nil) + func() { + defer catchFailNow(func() { + failed = true + }) + ts.cmdWait(false, nil) + }() // If we reached here but we've failed (probably because ContinueOnError // was set), don't wipe the log and print "PASS".