Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable aborting running jobs in forking strategy

  • Loading branch information...
commit be6828a1baed52607ea39c8a560fbdf64ebb7101 1 parent 3b61bbe
@phuongnd08 authored
View
15 lib/spork/run_strategy/forking.rb
@@ -3,10 +3,14 @@ def self.available?
Kernel.respond_to?(:fork)
end
+ def children
+ @children ||= []
+ end
+
def run(argv, stderr, stdout)
Spork.increase_run_count
- child = ::Spork::Forker.new do
+ children << child = ::Spork::Forker.new do
$stdout, $stderr = stdout, stderr
load test_framework.helper_file
Spork.exec_each_run
@@ -17,6 +21,15 @@ def run(argv, stderr, stdout)
child.result
end
+ def abort
+ children.each { |child| child.abort if child.running? }
+ nil
+ end
+
+ def running?
+ children.any? { |child| child.running? }
+ end
+
def preload
test_framework.preload
end
View
11 spec/spork/run_strategy/forking_spec.rb
@@ -13,17 +13,6 @@
@run_strategy.run("test", STDOUT, STDIN).should == "tests were ran"
end
- it "aborts the current running thread when another run is started" do
- create_helper_file
- @fake_framework.wait_time = 0.25
- first_run = Thread.new { @run_strategy.run("test", STDOUT, STDIN).should == nil }
- sleep(0.05)
- @run_strategy.run("test", STDOUT, STDIN).should == true
-
- # wait for the first to finish
- first_run.join
- end
-
it "can abort the current run" do
create_helper_file
@fake_framework.wait_time = 5
Please sign in to comment.
Something went wrong with that request. Please try again.