discourse/bin/turbo_rspec
Daniel Waterworth e18ce56f4b DEV: Add a new way to run specs in parallel with better output (#7778)
* DEV: Add a new way to run specs in parallel with better output

This commit:

 1. adds a new executable, `bin/interleaved_rspec` which works much like
    `rspec`, but runs the tests in parallel.

 2. adds a rake task, `rake interleaved:spec` which runs the whole test
    suite.

 3. makes autospec use this new wrapper by default. You can disable this
    by running `PARALLEL_SPEC=0 rake autospec`.

It works much like the `parallel_tests` gem (and relies on it), but
makes each subprocess use a machine-readable formatter and parses this
output in order to provide a better overall summary.

(It's called interleaved, because parallel was taken and naming is
hard).

* Make popen3 invocation safer

* Use FileUtils instead of shelling out

* DRY up reporter

* Moved summary logic into Reporter

* s/interleaved/turbo/g

* Move Reporter into its own file

* Moved run into its own class

* Moved Runner into its own file

* Move JsonRowsFormatter under TurboTests

* Join on threads at the end

* Acted on feedback from eviltrout
2019-06-21 10:59:01 +10:00

48 lines
896 B
Ruby
Executable File

#!/usr/bin/env ruby
require './lib/turbo_tests'
require 'optparse'
requires = []
formatters = []
OptionParser.new do |opts|
opts.on("-r", "--require PATH", "Require a file.") do |filename|
requires << filename
end
opts.on("-f", "--format FORMATTER", "Choose a formatter.") do |name|
formatters << {
name: name,
outputs: []
}
end
opts.on("-o", "--out FILE", "Write output to a file instead of $stdout") do |filename|
if formatters.empty?
formatters << {
name: "progress",
outputs: []
}
end
formatters.last[:outputs] << filename
end
end.parse!(ARGV)
requires.each { |f| require(f) }
if formatters.empty?
formatters << {
name: "progress",
outputs: []
}
end
formatters.each do |formatter|
if formatter[:outputs].empty?
formatter[:outputs] << '-'
end
end
TurboTests::Runner.run(formatters, ARGV)