Skip to content
Browse files

Send the result of run_tests back to the parent, so the result can be…

… relayed to the drb client
  • Loading branch information...
1 parent ca2c845 commit 52975166dc587b70dbf6bd49b7dd72a8764a675d @timcharper timcharper committed May 30, 2009
Showing with 15 additions and 4 deletions.
  1. +7 −4 lib/spork/server.rb
  2. +8 −0 spec/spork/server_spec.rb
View
11 lib/spork/server.rb
@@ -93,15 +93,18 @@ def helper_file
def run(argv, stderr, stdout)
return false if running?
- $stdout = stdout
- $stderr = stderr
+ $stdout, $stderr = stdout, stderr
+
+ child_io, server_io = UNIXSocket::socketpair
@child_pid = Kernel.fork do
+ server_io.close
Spork.exec_each_run(helper_file)
- run_tests(argv, stderr, stdout)
+ child_io << Marshal.dump(run_tests(argv, stderr, stdout))
end
+ child_io.close
Process.wait(@child_pid)
@child_pid = nil
- true
+ Marshal.load(server_io.read)
end
def running?
View
8 spec/spork/server_spec.rb
@@ -20,6 +20,7 @@ def puts(string)
def run_tests(argv, input, output)
sleep(@wait_time || 0.5)
+ true
end
end
@@ -122,5 +123,12 @@ def create_helper_file
(Time.now - started_at).should < @fake.wait_time
end
+
+ it "returns the result of the run_tests method from the forked child" do
+ create_helper_file
+ @fake.wait_time = 5
+ @fake.stub!(:run_tests).and_return("tests were ran")
+ @fake.run("test", STDOUT, STDIN).should == "tests were ran"
+ end
end
end

0 comments on commit 5297516

Please sign in to comment.
Something went wrong with that request. Please try again.