mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:49:55 +08:00
9b4aba0d39
* [WIP] - default turbo spec env to test * FEATURE: support for --fast-fail in bin/turbo_rspec * fast-fail -> fail_fast to match rspec * Moved thread killing outside of fail-fast check * Removed failure_count incrementation from fast_fail_met
75 lines
1.3 KiB
Ruby
Executable File
75 lines
1.3 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
ENV['RAILS_ENV'] ||= 'test'
|
|
|
|
require './lib/turbo_tests'
|
|
require 'optparse'
|
|
|
|
requires = []
|
|
formatters = []
|
|
verbose = false
|
|
fail_fast = nil
|
|
|
|
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
|
|
|
|
opts.on("--fail-fast=[N]") do |n|
|
|
n = Integer(n) rescue nil
|
|
fail_fast = (n.nil? || n < 1) ? 1 : n
|
|
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
|
|
|
|
success =
|
|
TurboTests::Runner.run(
|
|
formatters: formatters,
|
|
files: ARGV.empty? ? ["spec"] : ARGV,
|
|
verbose: verbose,
|
|
fail_fast: fail_fast
|
|
)
|
|
|
|
if success
|
|
exit 0
|
|
else
|
|
exit 1
|
|
end
|