Method: QUnited::Driver::Base#run

Defined in:
lib/qunited/driver/base.rb

#runObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/qunited/driver/base.rb', line 48

def run
  @tests_file = Tempfile.new(['tests_page', '.html'])
  @tests_file.write(tests_page_content)
  @tests_file.close
  puts @tests_file.path

  send_to_formatter(:start)

  @results = []

  Open3.popen3(command) do |stdin, stdout, stderr|
    results_collector = ResultsCollector.new(stdout)

    results_collector.on_test_result do |result|
      @results << result
      method = result.passed? ? :test_passed : :test_failed
      send_to_formatter(method, result)
    end

    results_collector.on_non_test_result_line do |line|
      # Drivers sometimes print error messages to stdout. If we are not reading
      # a test result then redirect any output to stderr
      $stderr.puts(line)
    end

    results_collector.collect_results

    err = stderr.read
    $stderr.puts(err) if err && !err.empty?
  end

  send_to_formatter(:stop)
  send_to_formatter(:summarize)

  @results
end