From 21e858e518c4cec31f4c56caa37682db38bac6a3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 8 Oct 2013 15:56:01 +0000 Subject: load.c: display backtrace to $stderr * load.c (load_lock): display backtrace to $stderr at circular require. * vm_backtrace.c (rb_backtrace_print_to): new function to print backtrace to the given output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_require.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'test/ruby/test_require.rb') diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 34c5fde96f..ad08bf85de 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -399,6 +399,7 @@ class TestRequire < Test::Unit::TestCase def test_race_exception bug5754 = '[ruby-core:41618]' path = nil + stderr = $stderr Tempfile.create(%w"bug5754 .rb") {|tmp| path = tmp.path tmp.print %{\ @@ -416,12 +417,11 @@ class TestRequire < Test::Unit::TestCase } tmp.close - # "circular require" warnings to $stderr, but backtraces to stderr - # in C-level. And redirecting stderr to a pipe seems to change - # some blocking timings and causes a deadlock, so run in a - # separated process for the time being. - assert_separately(["-w", "-", path, bug5754], <<-'end;', ignore_stderr: true) - path, bug5754 = *ARGV + class << (output = "") + alias write concat + end + $stderr = output + start = false scratch = [] @@ -454,9 +454,12 @@ class TestRequire < Test::Unit::TestCase assert_equal(true, (t1_res ^ t2_res), bug5754 + " t1:#{t1_res} t2:#{t2_res}") assert_equal([:pre, :post], scratch, bug5754) - end; + + assert_match(/circular require/, output) + assert_match(/in #{__method__}'$/o, output) } ensure + $stderr = stderr $".delete(path) end -- cgit v1.2.3