2019-06-21 08:59:01 +08:00
|
|
|
#!/usr/bin/env ruby
|
2019-06-21 09:33:22 +08:00
|
|
|
# frozen_string_literal: true
|
2019-06-21 08:59:01 +08:00
|
|
|
|
2019-10-09 22:40:06 +08:00
|
|
|
ENV['RAILS_ENV'] ||= 'test'
|
|
|
|
|
2019-06-21 08:59:01 +08:00
|
|
|
require './lib/turbo_tests'
|
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
requires = []
|
|
|
|
formatters = []
|
2019-06-27 22:48:38 +08:00
|
|
|
verbose = false
|
2019-10-09 22:40:06 +08:00
|
|
|
fail_fast = nil
|
2019-06-21 08:59:01 +08:00
|
|
|
|
|
|
|
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
|
2019-06-27 22:48:38 +08:00
|
|
|
|
|
|
|
opts.on("-v", "--verbose", "More output") do
|
|
|
|
verbose = true
|
|
|
|
end
|
2019-10-09 22:40:06 +08:00
|
|
|
|
|
|
|
opts.on("--fail-fast=[N]") do |n|
|
|
|
|
n = Integer(n) rescue nil
|
|
|
|
fail_fast = (n.nil? || n < 1) ? 1 : n
|
|
|
|
end
|
|
|
|
|
2019-06-21 08:59:01 +08:00
|
|
|
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 15:51:23 +08:00
|
|
|
success =
|
|
|
|
TurboTests::Runner.run(
|
|
|
|
formatters: formatters,
|
|
|
|
files: ARGV.empty? ? ["spec"] : ARGV,
|
2019-10-09 22:40:06 +08:00
|
|
|
verbose: verbose,
|
|
|
|
fail_fast: fail_fast
|
2019-07-09 15:51:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if success
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
end
|