diff options
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/envutil.rb | 30 | ||||
| -rw-r--r-- | test/ruby/test_rubyoptions.rb | 14 |
2 files changed, 34 insertions, 10 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 81b982cc70..ab07289876 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -477,6 +477,36 @@ eom AssertFile end + # pattern_list is an array which contains regexp and :*. + # :* means any sequence. + # + # pattern_list is anchored. + # Use [:*, regexp, :*] for non-anchored match. + def assert_regexp_list(pattern_list, actual, message=nil) + rest = actual + anchored = true + pattern_list.each {|pattern| + if pattern == :* + anchored = false + else + if anchored + match = /\A#{pattern}/.match(rest) + else + match = pattern.match(rest) + end + unless match + msg = message(msg) { "Expected #{mu_pp pattern}\nto match #{mu_pp rest}" } + assert false, msg + end + rest = match.post_match + anchored = true + end + } + if anchored + assert_equal("", rest) + end + end + class << (AssertFile = Struct.new(:failure_message).new) include Assertions def assert_file_predicate(predicate, *args) diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 25e5fe6d96..7967415ec5 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -536,7 +536,9 @@ class TestRubyOptions < Test::Unit::TestCase --\sC\slevel\sbacktrace\sinformation\s-------------------------------------------\n (?:(?:.*\s)?\[0x\h+\]\n)*\n )? - (?m:.*) + )x, + :*, + %r( \[NOTE\]\n You\smay\shave\sencountered\sa\sbug\sin\sthe\sRuby\sinterpreter\sor\sextension\slibraries.\n Bug\sreports\sare\swelcome.\n @@ -559,15 +561,7 @@ class TestRubyOptions < Test::Unit::TestCase EnvUtil.diagnostic_reports(Signal.signame(signo), EnvUtil.rubybin, status.pid, Time.now) end - str = stderr - SEGVTest::ExpectedStderrList.each {|regexp| - r = /\A#{regexp}/ - unless r =~ str - assert_match(r, str, message) - end - str = $' - } - assert_equal('', str) + assert_regexp_list(SEGVTest::ExpectedStderrList, stderr, message) status end |
