aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-11 10:37:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-22 00:33:19 +0900
commit5b959e238e5b7c18d6a1a5f5d9b4b2063de628fe (patch)
tree4a43a7133e16bac2c105915960a642dc10f969c7 /test/ruby
parent1f0888ab3e699a1083cddad84b0d8cb28e15ad8e (diff)
downloadruby-5b959e238e5b7c18d6a1a5f5d9b4b2063de628fe.tar.gz
[Bug #19016] re-order error handling at cleanup
Build and store the error message with `#detailed_message` before terminating all Ractors, then show the message later.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_exception.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 3a2aeeab80..1d3ff6ac18 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1459,19 +1459,20 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end
def test_syntax_error_detailed_message
- Tempfile.create(%w[detail .rb]) do |lib|
- lib.print "#{<<~"begin;"}\n#{<<~'end;'}"
+ Dir.mktmpdir do |dir|
+ File.write(File.join(dir, "detail.rb"), "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class SyntaxError
def detailed_message(**)
- Thread.start {}.join
- "#{super}\n""<#{File.basename(__FILE__)}>"
+ Thread.new {}.join
+ "<#{super}>\n""<#{File.basename(__FILE__)}>"
+ rescue ThreadError => e
+ e.message
end
end
end;
- lib.close
- pattern = /^<#{Regexp.quote(File.basename(lib.path))}>/
- assert_in_out_err(%W[-r#{lib.path} -], "1+", [], pattern)
+ pattern = /^<detail\.rb>/
+ assert_in_out_err(%W[-r#{dir}/detail -], "1+", [], pattern)
end
end
end