class ParallelTests::Test::Runner
def self.execute_command_and_capture_output(env, cmd, silence)
def self.execute_command_and_capture_output(env, cmd, silence) # make processes descriptive / visible in ps -ef exports = env.map do |k,v| "#{k}=#{v};export #{k}" end.join(";") cmd = "#{exports};#{cmd}" output, errput, exitstatus = nil if RUBY_ENGINE == "jruby" # - JRuby's popen3 doesn't pass arguments correctly to the shell, so we use stdin # - JRuby's open cannot handle local variables properly so we would have to use instance variables Open3.popen3("sh -") do |stdin, stdout, stderr, thread| stdin.puts cmd stdin.close output, errput = capture_output(stdout, stderr, silence) end exitstatus = $?.exitstatus elsif RUBY_VERSION =~ /^1\.8/ or ENV["TEAMCITY_RAKE_RUNNER_MODE"] # fix #207 open("|#{cmd}", "r") do |output| output, errput = capture_output(output, nil, silence) end exitstatus = $?.exitstatus else Open3.popen3(cmd) do |stdin, stdout, stderr, thread| stdin.close output, errput = capture_output(stdout, stderr, silence) exitstatus = thread.value.exitstatus end end {:stdout => output, :stderr => errput, :exit_status => exitstatus} end