discourse/bin/turbo_rspec

65 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
# frozen_string_literal: true
require './lib/turbo_tests'
require 'optparse'
requires = []
formatters = []
verbose = false
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
opts.on("-v", "--verbose", "More output") do
verbose = true
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
2019-07-09 03:51:23 -04:00
success =
TurboTests::Runner.run(
formatters: formatters,
files: ARGV.empty? ? ["spec"] : ARGV,
verbose: verbose
)
if success
exit 0
else
exit 1
end