Class: Spork::RunStrategy::Forking

Inherits:
Spork::RunStrategy show all
Defined in:
lib/spork/run_strategy/forking.rb

Instance Attribute Summary

Attributes inherited from Spork::RunStrategy

#test_framework

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spork::RunStrategy

#cleanup, #initialize

Constructor Details

This class inherits a constructor from Spork::RunStrategy

Class Method Details

.available?Boolean



2
3
4
# File 'lib/spork/run_strategy/forking.rb', line 2

def self.available?
  Kernel.respond_to?(:fork)
end

Instance Method Details

#abortObject



20
21
22
# File 'lib/spork/run_strategy/forking.rb', line 20

def abort
  @child && @child.abort
end

#assert_ready!Object

Raises:

  • (RuntimeError)


32
33
34
# File 'lib/spork/run_strategy/forking.rb', line 32

def assert_ready!
  raise RuntimeError, "This process hasn't loaded the environment yet by loading the prefork block" unless Spork.using_spork?
end

#preloadObject



24
25
26
# File 'lib/spork/run_strategy/forking.rb', line 24

def preload
  test_framework.preload
end

#run(argv, stderr, stdout) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/spork/run_strategy/forking.rb', line 6

def run(argv, stderr, stdout)
  abort if running?

  @child = ::Spork::Forker.new do
    $stdout, $stderr = stdout, stderr
    load test_framework.helper_file
    Spork.exec_each_run
    result = test_framework.run_tests(argv, stderr, stdout)
    Spork.exec_after_each_run
    result
  end
  @child.result
end

#running?Boolean



28
29
30
# File 'lib/spork/run_strategy/forking.rb', line 28

def running?
  @child && @child.running?
end