ruby-changes:59212
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 12 Dec 2019 11:14:17 +0900 (JST)
Subject: [ruby-changes:59212] 12de92a368 (master): implement make test-all TESTS=--gc-compact
https://git.ruby-lang.org/ruby.git/commit/?id=12de92a368 From 12de92a3682f7a54941c511e6394068df2adefb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 12 Dec 2019 11:11:39 +0900 Subject: implement make test-all TESTS=--gc-compact 79eb5e1acac2339c6ec71db723298bdfcd92b233 implemented RUBY_TEST_GC_COMPACT=1 so why not make it also possible via the command line argument. diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 928c896..42d1d83 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -922,13 +922,16 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L922 end end - module GCStressOption # :nodoc: all + module GCOption # :nodoc: all def setup_options(parser, options) super parser.separator "GC options:" parser.on '--[no-]gc-stress', 'Set GC.stress as true' do |flag| options[:gc_stress] = flag end + parser.on '--[no-]gc-compact', 'GC.compact every time' do |flag| + options[:gc_compact] = flag + end end def non_options(files, options) @@ -945,6 +948,18 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L948 end end end + if options.delete(:gc_compact) + MiniTest::Unit::TestCase.class_eval do + oldrun = instance_method(:run) + define_method(:run) do |runner| + begin + oldrun.bind_call(self, runner) + ensure + GC.compact + end + end + end + end super end end @@ -1080,7 +1095,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L1095 include Test::Unit::GlobOption include Test::Unit::RepeatOption include Test::Unit::LoadPathOption - include Test::Unit::GCStressOption + include Test::Unit::GCOption include Test::Unit::ExcludesOption include Test::Unit::TimeoutOption include Test::Unit::RunCount -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/