From 3a613ef1b2c16c1e41d8e672978374e8cf118a5f Mon Sep 17 00:00:00 2001 From: Arturo Pie Date: Wed, 1 Jun 2011 16:45:31 -0400 Subject: [PATCH] Removed the class methods --- lib/hydra/runner.rb | 19 ++++++++----------- test/fixtures/runner_listeners.rb | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index 432d77b..696a232 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -16,7 +16,6 @@ module Hydra #:nodoc: # Boot up a runner. It takes an IO object (generally a pipe from its # parent) to send it messages on which files to execute. def initialize(opts = {}) - Runner.runner_instance = self # save Runner to make sure it stop at_exit @io = opts.fetch(:io) { raise "No IO Object" } @verbose = opts.fetch(:verbose) { false } @event_listeners = Array( opts.fetch( :runner_listeners ) { nil } ) @@ -25,6 +24,8 @@ module Hydra #:nodoc: runner_begin + reg_exit_hook + trace 'Booted. Sending Request for file' @io.write RequestFile.new begin @@ -40,12 +41,11 @@ module Hydra #:nodoc: @event_listeners.each {|l| l.runner_begin( self ) } end - def self.runner_instance=( runner ) - @runner_instance = runner - end - - def self.runner_instance - @runner_instance + def reg_exit_hook + at_exit do + # NOTE: do not use trace here + stop + end end # Run a test file and report the results @@ -71,6 +71,7 @@ module Hydra #:nodoc: # Stop running def stop + # NOTE: do not use trace here runner_end if @running @running = false end @@ -288,8 +289,4 @@ module Hydra #:nodoc: end.compact end end - - at_exit do - Runner.runner_instance.stop if Runner.runner_instance - end end diff --git a/test/fixtures/runner_listeners.rb b/test/fixtures/runner_listeners.rb index 49f8e81..fb4b12d 100644 --- a/test/fixtures/runner_listeners.rb +++ b/test/fixtures/runner_listeners.rb @@ -10,6 +10,7 @@ module HydraExtension class RunnerEndTest < Hydra::RunnerListener::Abstract # Fired by the runner just after stoping def runner_end( runner ) + # NOTE: do not use trace here FileUtils.touch File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt')) end end