From ff41fb5daa7b4c111e3f4f76be28a5ddde47c9c7 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Mon, 3 Dec 2012 09:20:52 +0400 Subject: [PATCH 1/3] #210 - magazin run strategy must return test result --- lib/spork/run_strategy/magazine.rb | 3 ++- lib/spork/run_strategy/magazine/magazine_slave.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/spork/run_strategy/magazine.rb b/lib/spork/run_strategy/magazine.rb index 5fec7e9..51b50fa 100644 --- a/lib/spork/run_strategy/magazine.rb +++ b/lib/spork/run_strategy/magazine.rb @@ -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 diff --git a/lib/spork/run_strategy/magazine/magazine_slave.rb b/lib/spork/run_strategy/magazine/magazine_slave.rb index 3b08b94..4a23989 100644 --- a/lib/spork/run_strategy/magazine/magazine_slave.rb +++ b/lib/spork/run_strategy/magazine/magazine_slave.rb @@ -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 From 6d4107536a1be6748de82f22b5063e408ce31f83 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Fri, 20 Sep 2013 13:29:35 +0400 Subject: [PATCH 2/3] Let's hide useless output/exceptions from passing specs --- spec/spork/run_strategy/forking_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/spork/run_strategy/forking_spec.rb b/spec/spork/run_strategy/forking_spec.rb index f7950a7..a64e5af 100644 --- a/spec/spork/run_strategy/forking_spec.rb +++ b/spec/spork/run_strategy/forking_spec.rb @@ -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 @@ -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? From 449d6e8280b849d5c5f4c4aee58843946c6a4444 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Fri, 20 Sep 2013 13:30:09 +0400 Subject: [PATCH 3/3] Spec for return value of MagazineSlave.run method --- .../run_strategy/magazine/magazine_slave_spec.rb | 11 +++++++++++ spec/support/fake_framework.rb | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 spec/spork/run_strategy/magazine/magazine_slave_spec.rb diff --git a/spec/spork/run_strategy/magazine/magazine_slave_spec.rb b/spec/spork/run_strategy/magazine/magazine_slave_spec.rb new file mode 100644 index 0000000..dde4f96 --- /dev/null +++ b/spec/spork/run_strategy/magazine/magazine_slave_spec.rb @@ -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 diff --git a/spec/support/fake_framework.rb b/spec/support/fake_framework.rb index 1c7ac75..08857f8 100644 --- a/spec/support/fake_framework.rb +++ b/spec/support/fake_framework.rb @@ -14,4 +14,9 @@ def run_tests(argv, input, output) sleep(@wait_time || 0.5) true end + + def preload + true + end + end