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_VERSION =~ /^1\.8/
    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