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

ruby-changes:29298

From: naruse <ko1@a...>
Date: Mon, 17 Jun 2013 16:08:16 +0900 (JST)
Subject: [ruby-changes:29298] naruse:r41350 (trunk): Use assert_separately to inspect test failure of TestJSONGenerate#test_broken_bignum

naruse	2013-06-17 16:08:00 +0900 (Mon, 17 Jun 2013)

  New Revision: 41350

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

  Log:
    Use assert_separately to inspect test failure of TestJSONGenerate#test_broken_bignum
    
    http://fbsd.rubyci.org/~chkbuild/ruby-trunk/log/20130617T010202Z.log.html.gz#test%2F-ext-

  Modified files:
    trunk/test/json/test_json_generate.rb

Index: test/json/test_json_generate.rb
===================================================================
--- test/json/test_json_generate.rb	(revision 41349)
+++ test/json/test_json_generate.rb	(revision 41350)
@@ -3,6 +3,7 @@ https://github.com/ruby/ruby/blob/trunk/test/json/test_json_generate.rb#L3
 
 require 'test/unit'
 require File.join(File.dirname(__FILE__), 'setup_variant')
+require_relative '../ruby/envutil.rb'
 
 class TestJSONGenerate < Test::Unit::TestCase
   include JSON
@@ -215,15 +216,14 @@ EOT https://github.com/ruby/ruby/blob/trunk/test/json/test_json_generate.rb#L216
   end
 
   def test_gc
-    require_relative '../ruby/envutil.rb'
-    assert_in_out_err(%w[-rjson --disable-gems], <<-EOS, [], [])
+    assert_separately %w[-rjson --disable-gems], <<-EOS, timeout: 5
       bignum_too_long_to_embed_as_string = 1234567890123456789012345
       expect = bignum_too_long_to_embed_as_string.to_s
       GC.stress = true
 
       10.times do |i|
         tmp = bignum_too_long_to_embed_as_string.to_json
-        raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
+        assert_equal expect, tmp
       end
     EOS
   end if GC.respond_to?(:stress=)
@@ -252,27 +252,15 @@ EOT https://github.com/ruby/ruby/blob/trunk/test/json/test_json_generate.rb#L252
     assert_equal '5', state2.array_nl
   end
 
-  if defined?(JSON::Ext::Generator)
-    def test_broken_bignum # [ruby-core:38867]
-      pid = fork do
-        Bignum.class_eval do
-          def to_s
-          end
-        end
-        begin
-          JSON::Ext::Generator::State.new.generate(1<<64)
-          exit 1
-        rescue TypeError
-          exit 0
+  def test_broken_bignum # [ruby-core:38867]
+    assert_separately %w[-rjson --disable-gems], <<-EOS, timeout: 5
+      Bignum.class_eval do
+        def to_s
         end
       end
-      _, status = Process.waitpid2(pid)
-      assert status.success?
-    rescue NotImplementedError
-      # forking to avoid modifying core class of a parent process and
-      # introducing race conditions of tests are run in parallel
-    end
-  end
+      assert_raise(TypeError){ JSON::Ext::Generator::State.new.generate(1<<64) }
+    EOS
+  end if defined?(JSON::Ext::Generator)
 
   def test_hash_likeness_set_symbol
     state = JSON.state.new

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

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