Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #210 - magazin run strategy must return test result #240

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/spork/run_strategy/magazine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def run(argv, stderr, stdout)

puts "(#{slave.id_num}); slave.run..."; $stdout.flush
begin
slave.run(argv,stderr,stdout)
result = slave.run(argv,stderr,stdout)
puts " -- (#{slave.id_num});run done"; $stdout.flush
result
ensure
restart_slave(id)
end
Expand Down
4 changes: 3 additions & 1 deletion lib/spork/run_strategy/magazine/magazine_slave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def run(argv, stderr, stdout)
$stdout, $stderr = stdout, stderr
Spork.exec_each_run
load @test_framework.helper_file
@test_framework.run_tests(argv, stderr, stdout)
result = @test_framework.run_tests(argv, stderr, stdout)
Spork.exec_after_each_run
puts " <-- Slave(#{@id_num}) run done!"; stdout.flush
result
end

def preload
Expand Down
8 changes: 4 additions & 4 deletions spec/spork/run_strategy/forking_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
it "returns the result of the run_tests method from the forked child" do
create_helper_file
@fake_framework.stub!(:run_tests).and_return("tests were ran")
@run_strategy.run("test", STDOUT, STDIN).should == "tests were ran"
@run_strategy.run("test", StringIO.new, StringIO.new).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 }
first_run = Thread.new { @run_strategy.run("test", StringIO.new, StringIO.new).should == nil }
sleep(0.05)
@run_strategy.run("test", STDOUT, STDIN).should == true
@run_strategy.run("test", StringIO.new, StringIO.new).should == true

# wait for the first to finish
first_run.join
Expand All @@ -28,7 +28,7 @@
create_helper_file
@fake_framework.wait_time = 5
started_at = Time.now
first_run = Thread.new { @run_strategy.run("test", STDOUT, STDIN).should == true }
first_run = Thread.new { @run_strategy.run("test", StringIO.new, StringIO.new).should == true }
sleep(0.05)
@run_strategy.send(:abort)
sleep(0.01) while @run_strategy.running?
Expand Down
11 changes: 11 additions & 0 deletions spec/spork/run_strategy/magazine/magazine_slave_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe MagazineSlave do
it '#run returns test result' do
fake_framework = FakeFramework.new
create_helper_file(fake_framework)
fake_framework.stub!(:run_tests).and_return(true)
slave = MagazineSlave.new(1, fake_framework.short_name)
slave.run('test', StringIO.new, StringIO.new).should be true
end
end
5 changes: 5 additions & 0 deletions spec/support/fake_framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ def run_tests(argv, input, output)
sleep(@wait_time || 0.5)
true
end

def preload
true
end

end