-
Notifications
You must be signed in to change notification settings - Fork 440
Print the current command when aborting a test via CTRL-C #368
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
Print the current command when aborting a test via CTRL-C #368
Conversation
This looks to be really useful. I merged master, which gives a few test failures, could you rebase or merge in master so I can test again @martin-schulze-vireso? There appears to be a race condition (?) running the tests in parallel (the below error text), which is fixed by turning
Randomly hammering ctrl-c during bats own execution occasionally (1 in 100?!) misses, perhaps that could say "not in function" or whatever the equivalent may be?
I managed to break it with a typo that broke a regex. In the event that an error occurs internal to bats, the exit code handler hangs: $ bin/bats --formatter tap test/ --jobs 10--no-tempdir-cleanup
1..149
/usr/local/src/tmp/1611504215-bats-core.5JONGJ2/libexec/bats-core/bats-exec-suite: line 130: [[: 10--no-tempdir-cleanup: syntax error in expression (error token is "--no-tempdir-cleanup")
/usr/local/src/tmp/1611504215-bats-core.5JONGJ2/lib/bats-core/semaphore.bash: line 98: 10--no-tempdir-cleanup: syntax error in expression (error token is "--no-tempdir-cleanup")
^C/usr/local/src/tmp/1611504215-bats-core.5JONGJ2/lib/bats-core/semaphore.bash: line 98: 10--no-tempdir-cleanup: syntax error in expression (error token is "--no-tempdir-cleanup")
rm: cannot remove '/tmp/bats-run-3371479/semaphores/slot-': No such file or directory
^Cok 1 no arguments prints message and usage instructions Notably this doesn't work in Docker right now as there is no exit code handler, we just get
Overall looks great! |
fc2fc6a
to
53ba644
Compare
Thanks for the review @sublimino.
I rebased onto current master.
That should not be part of this PR. I think #413 already has a fix for that.
I reworked the message to this format which is more agnostic to the current execution progress:
So the
bats still exits non null in this case!
I could not reproduce that with the current code. Could you give more details?
I am not sure what you mean by exit code handler. Could you give more detail on how you started the container and how you sent the INT signal? |
485cfbb
to
bf39c31
Compare
Since @sublimino tried this feature before #407 , he hit the issue solved by this PR. |
GNU parallel does not let SIGINT through to its subprocesses, so we cannot abort cleanly in parallel mode
6b7a090
to
5a32e48
Compare
was removed in bats-core#413, rebase merge did not catch that
Motivation: I was working on a hanging test so I wondered how I could see where it hangs. Since I would CTRL-C the test anyways, I thought it would be nice to have a printout of the current command when I abort.
This may serve as a template for future test timeout handling, which should offer similar functionality for CI builds.
TODOs:
add changelog entry
I have reviewed the Contributor Guidelines.
I have reviewed the Code of Conduct and agree to abide by it