Permalink
Browse files

Executer composes a useful and descriptive error message if zombie se…

…rver is not alive
  • Loading branch information...
1 parent a94e87a commit b794e45a96c9f1192429e01722d222d402231b9e Daniel Vartanov committed with josevalim Apr 18, 2011
Showing with 33 additions and 2 deletions.
  1. +33 −2 lib/capybara/zombie/executer.rb
View
35 lib/capybara/zombie/executer.rb
@@ -8,9 +8,24 @@ def animate!
unless self.process
# puts "starting zombie..."
self.process = ChildProcess.new("env node #{executer_path}")
+
+ stderr_reader, stderr_writer = IO::pipe
+ stdout_reader, stdout_writer = IO::pipe
+ self.process.io.stderr = stderr_writer
+ self.process.io.stdout = stdout_writer
+
self.process.start
sleep 0.5
- raise("Zombie is not running") unless self.process.alive?
+
+ stderr_writer.close
+ stdout_writer.close
+
+ begin
+ raise compose_error_message(stdout_reader, stderr_reader) unless self.process.alive?
+ ensure
+ stdout_reader.close
+ stderr_reader.close
+ end
end
end
@@ -30,7 +45,23 @@ def kill
def executer_path
@executer_path ||= File.join(File.expand_path(File.dirname(__FILE__)), "executer.js")
end
+
+ def compose_error_message(stdout_reader, stderr_reader)
+ <<ERR
+Zombie is not running.
+executer.js died with exit code #{self.process.exit_code}
+
+--- start of process STDOUT ---
+#{stdout_reader.readlines.join}
+--- end of process STDOUT ---
+
+
+--- start of process STDERR ---
+#{stderr_reader.readlines.join}
+--- end of process STDERR ---
+ERR
+ end
end
end
-end
+end

1 comment on commit b794e45

@apolzon

Why is this project "dead"?

Currently depends on childprocess a pretty old version of childprocess...

Please sign in to comment.