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 360398f..1146050 100644 --- a/testscript/testscript.go +++ b/testscript/testscript.go @@ -651,7 +651,11 @@ func (ts *TestScript) run() { for _, bg := range ts.background { interruptProcess(bg.cmd.Process) } - ts.cmdWait(false, nil) + // On some platforms like Windows, we kill background commands directly + // as we can't send them an interrupt signal, so they always fail. + // Moreover, it's relatively common for a process to fail when interrupted. + // Once we've reached the end of the script, ignore the status of background commands. + ts.waitBackground(false) // If we reached here but we've failed (probably because ContinueOnError // was set), don't wipe the log and print "PASS".