diff options
Diffstat (limited to 'spec/ruby/core/thread/report_on_exception_spec.rb')
-rw-r--r-- | spec/ruby/core/thread/report_on_exception_spec.rb | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/spec/ruby/core/thread/report_on_exception_spec.rb b/spec/ruby/core/thread/report_on_exception_spec.rb index 9279fa1da5..d9daa041cd 100644 --- a/spec/ruby/core/thread/report_on_exception_spec.rb +++ b/spec/ruby/core/thread/report_on_exception_spec.rb @@ -61,34 +61,32 @@ describe "Thread#report_on_exception=" do }.should raise_error(RuntimeError, "Thread#report_on_exception specs") end - ruby_version_is "3.0" do - it "prints a backtrace on $stderr in the regular backtrace order" do - line_raise = __LINE__ + 2 - def foo - raise RuntimeError, "Thread#report_on_exception specs backtrace order" - end - - line_call_foo = __LINE__ + 5 - go = false - t = Thread.new { - Thread.current.report_on_exception = true - Thread.pass until go - foo - } + it "prints a backtrace on $stderr in the regular backtrace order" do + line_raise = __LINE__ + 2 + def foo + raise RuntimeError, "Thread#report_on_exception specs backtrace order" + end - -> { - go = true - Thread.pass while t.alive? - }.should output("", <<ERR) -#{t.inspect} terminated with exception (report_on_exception is true): -#{__FILE__}:#{line_raise}:in `foo': Thread#report_on_exception specs backtrace order (RuntimeError) -\tfrom #{__FILE__}:#{line_call_foo}:in `block (5 levels) in <top (required)>' -ERR + line_call_foo = __LINE__ + 5 + go = false + t = Thread.new { + Thread.current.report_on_exception = true + Thread.pass until go + foo + } - -> { - t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception specs backtrace order") - end + -> { + go = true + Thread.pass while t.alive? + }.should output("", /\A +#{Regexp.quote(t.inspect)}\sterminated\swith\sexception\s\(report_on_exception\sis\strue\):\n +#{Regexp.quote(__FILE__)}:#{line_raise}:in\s[`']foo':\sThread\#report_on_exception\sspecs\sbacktrace\sorder\s\(RuntimeError\)\n +\tfrom\s#{Regexp.quote(__FILE__)}:#{line_call_foo}:in\s[`']block\s\(4\slevels\)\sin\s<top\s\(required\)>'\n +\z/x) + + -> { + t.join + }.should raise_error(RuntimeError, "Thread#report_on_exception specs backtrace order") end it "prints the backtrace even if the thread was killed just after Thread#raise" do |