diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-01 22:20:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-01 22:20:23 +0000 |
commit | 5f37d6902a4d3ac75f76218ff97799fb75193cb6 (patch) | |
tree | bc0aa859eeaf690b3d310e743232576ea9cf5a35 /lib/test | |
parent | 64740adcffbb18b298086ebff4d41c512fbc9435 (diff) | |
download | ruby-5f37d6902a4d3ac75f76218ff97799fb75193cb6.tar.gz |
* 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
Diffstat (limited to 'lib/test')
-rw-r--r-- | lib/test/unit.rb | 27 |
1 files changed, 27 insertions, 0 deletions
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 |