summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/test/unit.rb45
-rw-r--r--lib/test/unit/parallel.rb16
2 files changed, 38 insertions, 23 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 89cb93a678..5b62774f44 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -429,7 +429,12 @@ module Test
# Array of workers.
launch_worker = Proc.new {
- worker = Worker.launch(@options[:ruby],@args)
+ begin
+ worker = Worker.launch(@options[:ruby],@args)
+ rescue => e
+ warn "ERROR: Failed to launch job process - #{e.class}: #{e.message}"
+ exit 1
+ end
worker.hook(:dead) do |w,info|
after_worker_quit w
after_worker_down w, *info if !info.empty? && !worker.quit_called
@@ -536,25 +541,29 @@ module Test
end
end
end
- @workers.each do |worker|
+
+ if @workers
+ @workers.each do |worker|
+ begin
+ timeout(1) do
+ worker.quit
+ end
+ rescue Errno::EPIPE
+ rescue Timeout::Error
+ end
+ worker.close
+ end
+
begin
- timeout(1) do
- worker.quit
+ timeout(0.2*@workers.size) do
+ Process.waitall
end
- rescue Errno::EPIPE
rescue Timeout::Error
- end
- worker.close
- end
- begin
- timeout(0.2*@workers.size) do
- Process.waitall
- end
- rescue Timeout::Error
- @workers.each do |worker|
- begin
- Process.kill(:KILL,worker.pid)
- rescue Errno::ESRCH; end
+ @workers.each do |worker|
+ begin
+ Process.kill(:KILL,worker.pid)
+ rescue Errno::ESRCH; end
+ end
end
end
@@ -565,7 +574,7 @@ module Test
@errors += rep.map{|x| x[:result][0] }.inject(:+)
@failures += rep.map{|x| x[:result][1] }.inject(:+)
@skips += rep.map{|x| x[:result][2] }.inject(:+)
- else
+ elsif @workers
puts ""
puts "Retrying..."
puts ""
diff --git a/lib/test/unit/parallel.rb b/lib/test/unit/parallel.rb
index 049b470e40..522447c63b 100644
--- a/lib/test/unit/parallel.rb
+++ b/lib/test/unit/parallel.rb
@@ -88,8 +88,14 @@ module Test
@old_loadpath = []
begin
- @stdout = increment_io(STDOUT)
- @stdin = increment_io(STDIN)
+ begin
+ @stdout = increment_io(STDOUT)
+ @stdin = increment_io(STDIN)
+ rescue
+ exit 2
+ end
+ exit 2 unless @stdout && @stdin
+
@stdout.sync = true
@stdout.puts "ready!"
while buf = @stdin.gets
@@ -130,12 +136,12 @@ module Test
rescue Errno::EPIPE
rescue Exception => e
begin
- @stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}"
+ @stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}" if @stdout
rescue Errno::EPIPE;end
exit
ensure
- @stdin.close
- @stdout.close
+ @stdin.close if @stdin
+ @stdout.close if @stdout
end
end
end