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: interrupted background process should not cause a test to fail #260

Closed
rogpeppe opened this issue Jun 13, 2024 · 1 comment · Fixed by #265
Closed

testscript: interrupted background process should not cause a test to fail #260

rogpeppe opened this issue Jun 13, 2024 · 1 comment · Fixed by #265
Assignees
Labels
bug Something isn't working

Comments

@rogpeppe
Copy link
Owner

It is usual and expected for processes to return a non-zero exit code when they
are terminated with a signal. At the end of a test, testscript kills all background
processes and then fails if any of them terminate with a non-zero exit code.
This doesn't seem right. (It's even more wrong that it panics with an error code
that should be internal-only - see issue #228).

Instead, at the end of a test, testscript should check if any background processes
have already exited with a non-zero exit code and fail then, but otherwise
it should interrupt them and ignore any non-zero exit codes from processes
killed as a result.

@rogpeppe rogpeppe added the bug Something isn't working label Jun 13, 2024
@mvdan
Copy link
Collaborator

mvdan commented Jun 25, 2024

I'm currently looking into this, e.g. #261 to also test Windows.

@mvdan mvdan self-assigned this Jun 25, 2024
mvdan added a commit to mvdan/go-internal that referenced this issue Jul 9, 2024
When an entire script runs and the end is reached, any background
processes begun with a '&' command get interrupted or killed,
depending on the platform and timeout, and we wait for them to finish.

We also checked their resulting status code and failed if they didn't
exit with a status code of 0. However, as explained in the comment,
this would always fail on Windows, given that it doesn't have interrupt
signals so we would kill directly, causing a "signal: killed" error.

Worse, any failures here caused a `panic: fail now!` as that is how
we bubble up errors when a script command is being run, but such panics
were not being recovered once we reached the end of a script.
Now that we don't check the result anymore here, the panics are gone.

Fixes rogpeppe#228.
Fixes rogpeppe#260.
mvdan added a commit to mvdan/go-internal that referenced this issue Jul 9, 2024
When an entire script runs and the end is reached, any background
processes begun with a '&' command get interrupted or killed,
depending on the platform and timeout, and we wait for them to finish.

We also checked their resulting status code and failed if they didn't
exit with a status code of 0. However, as explained in the comment,
this would always fail on Windows, given that it doesn't have interrupt
signals so we would kill directly, causing a "signal: killed" error.

Worse, any failures here caused a `panic: fail now!` as that is how
we bubble up errors when a script command is being run, but such panics
were not being recovered once we reached the end of a script.
Now that we don't check the result anymore here, the panics are gone.

Fixes rogpeppe#228.
Fixes rogpeppe#260.
@mvdan mvdan closed this as completed in #265 Jul 9, 2024
@mvdan mvdan closed this as completed in ccf4b43 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants