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
Add timeout support #491
Add timeout support #491
Conversation
Fixed the errors reported by the CI. Sorry about that. All the 178 Tests are now passing on my machine. I don't think I fixed the contribution error, but I'm not sure how to do it to be honest EDIT: Test didn't pass on Ubuntu / Windows, I have no idea why... Any help welcomed |
97d0d2c
to
18fe1af
Compare
Using SIGPIPE might interfere with some user scripts. I would propose to use SIGALRM or SIGUSR1/2. Furthermore, I think we should name the variable BATS_TEST_TIMEOUT to allow for other kinds of timeouts later on (like setup/setup_file,....) |
18fe1af
to
ef7c281
Compare
Thanks a lot for the review.
I spent a few hours today trying to do so but wasn't successful. My trap was either never called or without a trap, I got some error message corresponding to the trap call. Will potentially invest more time later :)
Good idea will do! |
I already have some local changes for that. I am not sure how to proceed with the traps but will try my own solution |
ad43ed2
to
16e1db1
Compare
6dc4685
to
25cc072
Compare
Sigh, Windows does not support SIGUSR1/2. SIGALRM interferes with |
2d22b97
to
a1bf687
Compare
the debug trap would run one more time with the wrong line before the trace is printed.
SIGALRM and sleep are no good match
SIGUSR1/2 is not supported there
Use different color for timeout failures
c7dd91b
to
b1e7fed
Compare
Hi,
The PR tries to fix #396. It adds a global timeout options (
-E <second>
) to./bin/bats
.This option adds a timeout to each test. If a test takes longer than the timeout, it will be killed and will exit with an error code set at
141
. In the case of the--tap
formater, a# timetout
will be printed in the terminal (similar to the#skip
behavior)Technical detail
The implementation is inspired by the great work of https://github.com/MountainField/bash-timeout.
I did tweak it a little bit so it works on my SUSE system. The main idea is to spawn a subprocess who will sleep and kill himself and his parents when waking up.
Summary
I'm not a bash expert, nor a
bats
one. But I implemented a version of timeout that worked for my use case, and maybe also useful for other people.Please don't hesitate if you have any feedback, I will be happy to do any modification to the PR to make it more "professional",
Hope this help,
Regards@