Removed the class methods

This commit is contained in:
Arturo Pie 2011-06-01 16:45:31 -04:00
parent 7c001ab485
commit 3a613ef1b2
2 changed files with 9 additions and 11 deletions

View File

@ -16,7 +16,6 @@ module Hydra #:nodoc:
# Boot up a runner. It takes an IO object (generally a pipe from its # Boot up a runner. It takes an IO object (generally a pipe from its
# parent) to send it messages on which files to execute. # parent) to send it messages on which files to execute.
def initialize(opts = {}) def initialize(opts = {})
Runner.runner_instance = self # save Runner to make sure it stop at_exit
@io = opts.fetch(:io) { raise "No IO Object" } @io = opts.fetch(:io) { raise "No IO Object" }
@verbose = opts.fetch(:verbose) { false } @verbose = opts.fetch(:verbose) { false }
@event_listeners = Array( opts.fetch( :runner_listeners ) { nil } ) @event_listeners = Array( opts.fetch( :runner_listeners ) { nil } )
@ -25,6 +24,8 @@ module Hydra #:nodoc:
runner_begin runner_begin
reg_exit_hook
trace 'Booted. Sending Request for file' trace 'Booted. Sending Request for file'
@io.write RequestFile.new @io.write RequestFile.new
begin begin
@ -40,12 +41,11 @@ module Hydra #:nodoc:
@event_listeners.each {|l| l.runner_begin( self ) } @event_listeners.each {|l| l.runner_begin( self ) }
end end
def self.runner_instance=( runner ) def reg_exit_hook
@runner_instance = runner at_exit do
# NOTE: do not use trace here
stop
end end
def self.runner_instance
@runner_instance
end end
# Run a test file and report the results # Run a test file and report the results
@ -71,6 +71,7 @@ module Hydra #:nodoc:
# Stop running # Stop running
def stop def stop
# NOTE: do not use trace here
runner_end if @running runner_end if @running
@running = false @running = false
end end
@ -288,8 +289,4 @@ module Hydra #:nodoc:
end.compact end.compact
end end
end end
at_exit do
Runner.runner_instance.stop if Runner.runner_instance
end
end end

View File

@ -10,6 +10,7 @@ module HydraExtension
class RunnerEndTest < Hydra::RunnerListener::Abstract class RunnerEndTest < Hydra::RunnerListener::Abstract
# Fired by the runner just after stoping # Fired by the runner just after stoping
def runner_end( runner ) def runner_end( runner )
# NOTE: do not use trace here
FileUtils.touch File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt')) FileUtils.touch File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
end end
end end