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

Defer at exit io close #1458

Merged
merged 9 commits into from
Aug 19, 2020
Merged

Defer at exit io close #1458

merged 9 commits into from
Aug 19, 2020

Conversation

aslakhellesoy
Copy link
Contributor

Prior to this change, all IO objects created by ensure_io would be flushed and closed when Ruby exits.

This turned out to be a problem for the new --publish functionality if Cucumber raised an exception.

One case where Cucumber will raise an exception (and not run anything) is when it's passed a non-existent feature file. It might also raise exceptions in other cases, for example when a feature file has syntax errors.

In those cases (where cucumber doesn't run anything), we don't want to publish any reports! However, since formatters (and their streams) are created before the exceptions described above are raised, it would already have registered the at_exit hooks that flush and close the streams (which in the case of --publish will publish a report).

The fix is to defer the registration of the at_exit hook which flushes and closes until we can be sure Cucumber isn't going to raise an error. If Cucumber raises an exception, the at_exit hook won't have been registered.

This change should preserve backwards compatibility.

cbliard and others added 4 commits August 19, 2020 11:16
…ister an event listener to close io in a at_exit hook

Co-authored-by: Aslak Hellesøy <aslak.hellesoy@smartbear.com>
Co-authored-by: vincent.capicotto <vincent.capicotto@hiptest.net>
@aslakhellesoy aslakhellesoy added the 🐛 bug Defect / Bug label Aug 19, 2020
@aslakhellesoy aslakhellesoy merged commit f4fcc89 into master Aug 19, 2020
@aslakhellesoy aslakhellesoy deleted the defer-at-exit-io-close branch August 19, 2020 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants