[前][次][番号順一覧][スレッド一覧]

ruby-changes:35856

From: akr <ko1@a...>
Date: Wed, 15 Oct 2014 18:00:07 +0900 (JST)
Subject: [ruby-changes:35856] akr:r47938 (trunk): * test/ruby/envutil.rb (assert_pattern_list) Renamed from

akr	2014-10-15 17:59:46 +0900 (Wed, 15 Oct 2014)

  New Revision: 47938

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47938

  Log:
    * test/ruby/envutil.rb (assert_pattern_list) Renamed from
      assert_regexp_list.
      Show multiline string in multi lines.
    
    * test/-ext-/bug_reporter/test_bug_reporter.rb: Use
      assert_pattern_list.

  Modified files:
    trunk/ChangeLog
    trunk/test/-ext-/bug_reporter/test_bug_reporter.rb
    trunk/test/ruby/envutil.rb
    trunk/test/ruby/test_rubyoptions.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47937)
+++ ChangeLog	(revision 47938)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Oct 15 17:53:28 2014  Tanaka Akira  <akr@f...>
+
+	* test/ruby/envutil.rb (assert_pattern_list) Renamed from
+	  assert_regexp_list.
+	  Show multiline string in multi lines.
+
+	* test/-ext-/bug_reporter/test_bug_reporter.rb: Use
+	  assert_pattern_list.
+
 Wed Oct 15 12:26:58 2014  Tanaka Akira  <akr@f...>
 
 	* test/ruby/envutil.rb (assert_regexp_list): New assertion method.
Index: test/ruby/envutil.rb
===================================================================
--- test/ruby/envutil.rb	(revision 47937)
+++ test/ruby/envutil.rb	(revision 47938)
@@ -482,7 +482,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L482
       #
       # 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L495
               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
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 47937)
+++ test/ruby/test_rubyoptions.rb	(revision 47938)
@@ -562,7 +562,7 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L562
       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
Index: test/-ext-/bug_reporter/test_bug_reporter.rb
===================================================================
--- test/-ext-/bug_reporter/test_bug_reporter.rb	(revision 47937)
+++ test/-ext-/bug_reporter/test_bug_reporter.rb	(revision 47938)
@@ -4,13 +4,21 @@ require_relative "../../ruby/envutil" https://github.com/ruby/ruby/blob/trunk/test/-ext-/bug_reporter/test_bug_reporter.rb#L4
 
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]