diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/bug_reporter/test_bug_reporter.rb | 20 | ||||
-rw-r--r-- | test/ruby/envutil.rb | 17 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 2 |
3 files changed, 30 insertions, 9 deletions
diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb index 2e5e332074..3f804a633a 100644 --- a/test/-ext-/bug_reporter/test_bug_reporter.rb +++ b/test/-ext-/bug_reporter/test_bug_reporter.rb @@ -4,13 +4,21 @@ require_relative "../../ruby/envutil" class TestBugReporter < Test::Unit::TestCase def test_bug_reporter_add - expected_stderr = /Sample bug reporter: 12345/ + expected_stderr = [ + :*, + /\[BUG\]\sSegmentation\sfault.*\n/, + /#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n/, + :*, + /Sample bug reporter: 12345/, + :* + ] tmpdir = Dir.mktmpdir - assert_in_out_err(["--disable-gems", "-r-test-/bug_reporter/bug_reporter", - "-C", tmpdir], - "register_sample_bug_reporter(12345); Process.kill :SEGV, $$", - [], - expected_stderr, nil) + + args = ["--disable-gems", "-r-test-/bug_reporter/bug_reporter", + "-C", tmpdir] + stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$" + _, stderr, status = EnvUtil.invoke_ruby(args, stdin, false, true) + assert_pattern_list(expected_stderr, stderr) ensure FileUtils.rm_rf(tmpdir) if tmpdir end diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index ab07289876..62f90648c8 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -482,7 +482,7 @@ eom # # pattern_list is anchored. # Use [:*, regexp, :*] for non-anchored match. - def assert_regexp_list(pattern_list, actual, message=nil) + def assert_pattern_list(pattern_list, actual, message=nil) rest = actual anchored = true pattern_list.each {|pattern| @@ -495,7 +495,20 @@ eom match = pattern.match(rest) end unless match - msg = message(msg) { "Expected #{mu_pp pattern}\nto match #{mu_pp rest}" } + msg = message(msg) { + expect_msg = "Expected #{mu_pp pattern}\n" + if /\n[^\n]+\n/ =~ rest + actual_mesg = "to match\n" + prefix = " " + rest.scan(/.*\n+/) { + actual_mesg << ' ' << $&.inspect << "+\n" + } + actual_mesg.sub!(/\+\n\z/, '') + else + actual_mesg = "to match #{mu_pp rest}" + end + expect_msg + actual_mesg + } assert false, msg end rest = match.post_match diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index f94bbb3459..61e11a43fd 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -562,7 +562,7 @@ class TestRubyOptions < Test::Unit::TestCase EnvUtil.diagnostic_reports(Signal.signame(signo), EnvUtil.rubybin, status.pid, Time.now) end - assert_regexp_list(SEGVTest::ExpectedStderrList, stderr, message) + assert_pattern_list(SEGVTest::ExpectedStderrList, stderr, message) status end |