Module: Test::Unit::GCStressOption

Included in:
Runner
Defined in:
lib/test/unit.rb

Instance Method Summary collapse

Instance Method Details

#non_options(files, options) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/test/unit.rb', line 193

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

#setup_options(parser, options) ⇒ Object



186
187
188
189
190
191
# File 'lib/test/unit.rb', line 186

def setup_options(parser, options)
  super
  parser.on '--[no-]gc-stress', 'Set GC.stress as true' do |flag|
    options[:gc_stress] = flag
  end
end