You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
When testing components that might be expected to call Kernel.exit in the normal course of operations, a SystemExit is raised. The policy of not rescuing SystemExit in this case means any tests that were supposed to run after that point will not run -- and will not report a failure. The only indication is that the number of tests executed is lower than it should be.
In automated test runs, this is almost impossible to catch - and even in local runs when the difference is a matter of just a handful of tests not being run, it's easy to miss.
Simple repro:
describe "a scenario that should run two tests and fail one" do
it "should report this as failed and keep running" do
Kernel.exit 1
end
it "does not do either, and I see a succesful exit with one test passed" do
end
end
Result:
rspec test_spec.rb
Finished in 0.00039 seconds (files took 0.06405 seconds to load)
1 example, 0 failures
The easy answer is to also handle SystemExit, but that would re-introduce #2063. That led me to consider submitting a patch where a SystemExit handling option could be specified via configuration., and handled similarly to:
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
...
rescue Support::AnyExceptionWeMustNotRescue => ex
raise unless RSpec.configuration.allow_exceptions.include?(ex.class)
Another option would be a final check of number of executed tests against the number we expected to execute, failing on a mismatch. This may not catch scenarios related to nested runs though.
Before submitting a patch, I wanted to open this issue for feedback and discussion of best approach.