ruby-changes:17988
From: nobu <ko1@a...>
Date: Thu, 2 Dec 2010 07:32:48 +0900 (JST)
Subject: [ruby-changes:17988] Ruby:r30009 (trunk): * lib/test/unit.rb (Test::Unit::GCStressOption): --gc-stress
nobu 2010-12-02 07:20:23 +0900 (Thu, 02 Dec 2010) New Revision: 30009 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30009 Log: * lib/test/unit.rb (Test::Unit::GCStressOption): --gc-stress option. Modified files: trunk/ChangeLog trunk/lib/test/unit.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30008) +++ ChangeLog (revision 30009) @@ -1,5 +1,8 @@ -Thu Dec 2 07:15:12 2010 Nobuyoshi Nakada <nobu@r...> +Thu Dec 2 07:20:20 2010 Nobuyoshi Nakada <nobu@r...> + * 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. Index: lib/test/unit.rb =================================================================== --- lib/test/unit.rb (revision 30008) +++ lib/test/unit.rb (revision 30009) @@ -123,6 +123,32 @@ 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 @@ class Mini < MiniTest::Unit include Test::Unit::GlobOption include Test::Unit::LoadPathOption + include Test::Unit::GCStressOption include Test::Unit::RunCount include Test::Unit::Options -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/