This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +13
-11
lines changed Expand file tree Collapse file tree 6 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,9 @@ Proc:
101
101
RedundantReturn :
102
102
AllowMultipleReturnValues : true
103
103
104
- # We have to rescue Exception in the `raise_error` matcher for it to work properly.
104
+ # Exceptions should be rescued with `Support::AllExceptionsExceptOnesWeMustNotRescue`
105
105
RescueException :
106
- Enabled : false
106
+ Enabled : true
107
107
108
108
# We haven't adopted the `fail` to signal exceptions vs `raise` for re-raises convention.
109
109
SignalException :
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ Enhancements:
24
24
(Jon Rowe, #2052 )
25
25
* Append the root ` cause ` of a failure or error to the printed failure
26
26
output when a ` cause ` is available. (Adam Magan)
27
+ * Stop rescuing ` NoMemoryError ` , ` SignalExcepetion ` , ` Interrupt ` and
28
+ ` SystemExit ` . It is dangerous to interfere with these. (Myron Marston, #2063 )
27
29
28
30
Bug Fixes:
29
31
Original file line number Diff line number Diff line change @@ -1754,7 +1754,7 @@ def define_built_in_hooks
1754
1754
around ( :example , :aggregate_failures => true ) do |procsy |
1755
1755
begin
1756
1756
aggregate_failures ( nil , :hide_backtrace => true , &procsy )
1757
- rescue Exception => exception
1757
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => exception
1758
1758
procsy . example . set_aggregate_failures_exception ( exception )
1759
1759
end
1760
1760
end
Original file line number Diff line number Diff line change @@ -227,14 +227,14 @@ def run(example_group_instance, reporter)
227
227
rescue Pending ::SkipDeclaredInExample
228
228
# no-op, required metadata has already been set by the `skip`
229
229
# method.
230
- rescue Exception => e
230
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
231
231
set_exception ( e )
232
232
ensure
233
233
run_after_example
234
234
end
235
235
end
236
236
end
237
- rescue Exception => e
237
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
238
238
set_exception ( e )
239
239
ensure
240
240
@example_group_instance = nil # if you love something... let it go
@@ -400,7 +400,7 @@ def hooks
400
400
401
401
def with_around_example_hooks
402
402
hooks . run ( :around , :example , self ) { yield }
403
- rescue Exception => e
403
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
404
404
set_exception ( e )
405
405
end
406
406
@@ -457,7 +457,7 @@ def run_after_example
457
457
458
458
def verify_mocks
459
459
@example_group_instance . verify_mocks_for_rspec if mocks_need_verification?
460
- rescue Exception => e
460
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
461
461
set_exception ( e )
462
462
end
463
463
@@ -476,7 +476,7 @@ def assign_generated_description
476
476
477
477
def generate_description
478
478
RSpec ::Matchers . generated_description
479
- rescue Exception => e
479
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
480
480
location_description + " (Got an error when generating description " \
481
481
"from matcher: #{ e . class } : #{ e . message } -- #{ e . backtrace . first } )"
482
482
end
Original file line number Diff line number Diff line change @@ -524,7 +524,7 @@ def self.run(reporter=RSpec::Core::NullReporter)
524
524
rescue Pending ::SkipDeclaredInExample => ex
525
525
for_filtered_examples ( reporter ) { |example | example . skip_with_exception ( reporter , ex ) }
526
526
true
527
- rescue Exception => ex
527
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => ex
528
528
RSpec . world . wants_to_quit = true if fail_fast?
529
529
for_filtered_examples ( reporter ) { |example | example . fail_with_exception ( reporter , ex ) }
530
530
false
Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ def run(example)
362
362
class AfterHook < Hook
363
363
def run ( example )
364
364
example . instance_exec ( example , &block )
365
- rescue Exception => ex
365
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => ex
366
366
example . set_exception ( ex )
367
367
end
368
368
end
@@ -371,7 +371,7 @@ def run(example)
371
371
class AfterContextHook < Hook
372
372
def run ( example )
373
373
example . instance_exec ( example , &block )
374
- rescue Exception => e
374
+ rescue Support :: AllExceptionsExceptOnesWeMustNotRescue => e
375
375
# TODO: Come up with a better solution for this.
376
376
RSpec . configuration . reporter . message <<-EOS
377
377
You can’t perform that action at this time.
0 commit comments