Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testscript: ignore result when interrupting background processes #265

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions testscript/testdata/interrupt_implicit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Let testscript stop signalcatcher at the end of the testscript.

signalcatcher &
waitfile catchsignal
6 changes: 5 additions & 1 deletion testscript/testscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down