From 5f37d6902a4d3ac75f76218ff97799fb75193cb6 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 Dec 2010 22:20:23 +0000 Subject: [PATCH] * lib/test/unit.rb (Test::Unit::GCStressOption): --gc-stress option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++- lib/test/unit.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d52c7a58e8..cc756f54c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Thu Dec 2 07:15:12 2010 Nobuyoshi Nakada +Thu Dec 2 07:20:20 2010 Nobuyoshi Nakada + + * lib/test/unit.rb (Test::Unit::GCStressOption): --gc-stress + option. * lib/test/unit.rb (Test::Unit::Mini#_run_suites): show the result even when interrupted on the way. diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 77f01fac15..2c2085c280 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -123,6 +123,32 @@ module Test end end + module GCStressOption + def setup_options(parser, options) + super + parser.on '--[no-]gc-stress' do |flag| + options[:gc_stress] = flag + end + end + + def non_options(files, options) + if options.delete(:gc_stress) + MiniTest::Unit::TestCase.class_eval do + oldrun = instance_method(:run) + define_method(:run) do |runner| + begin + gc_stress, GC.stress = GC.stress, true + oldrun.bind(self).call(runner) + ensure + GC.stress = gc_stress + end + end + end + end + super + end + end + module RequireFiles def non_options(files, options) super @@ -150,6 +176,7 @@ module Test class Mini < MiniTest::Unit include Test::Unit::GlobOption include Test::Unit::LoadPathOption + include Test::Unit::GCStressOption include Test::Unit::RunCount include Test::Unit::Options