DEV: Add a verbose option to ./bin/turbo_rspec
This commit is contained in:
parent
ed936bcb01
commit
d6aa92e98e
|
@ -6,6 +6,7 @@ require 'optparse'
|
|||
|
||||
requires = []
|
||||
formatters = []
|
||||
verbose = false
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.on("-r", "--require PATH", "Require a file.") do |filename|
|
||||
|
@ -28,6 +29,10 @@ OptionParser.new do |opts|
|
|||
end
|
||||
formatters.last[:outputs] << filename
|
||||
end
|
||||
|
||||
opts.on("-v", "--verbose", "More output") do
|
||||
verbose = true
|
||||
end
|
||||
end.parse!(ARGV)
|
||||
|
||||
requires.each { |f| require(f) }
|
||||
|
@ -45,4 +50,8 @@ formatters.each do |formatter|
|
|||
end
|
||||
end
|
||||
|
||||
TurboTests::Runner.run(formatters, ARGV.empty? ? ["spec"] : ARGV)
|
||||
TurboTests::Runner.run(
|
||||
formatters: formatters,
|
||||
files: ARGV.empty? ? ["spec"] : ARGV,
|
||||
verbose: verbose
|
||||
)
|
||||
|
|
|
@ -3,5 +3,8 @@
|
|||
task 'turbo:spec' => :test do |t|
|
||||
require './lib/turbo_tests'
|
||||
|
||||
TurboTests::Runner.run([{ name: 'progress', outputs: ['-'] }], ['spec'])
|
||||
TurboTests::Runner.run(
|
||||
formatters: [{ name: 'progress', outputs: ['-'] }],
|
||||
files: ['spec']
|
||||
)
|
||||
end
|
||||
|
|
|
@ -2,15 +2,30 @@
|
|||
|
||||
module TurboTests
|
||||
class Runner
|
||||
def self.run(formatter_config, files, start_time = Time.now)
|
||||
reporter = Reporter.from_config(formatter_config, start_time)
|
||||
def self.run(opts = {})
|
||||
files = opts[:files]
|
||||
formatters = opts[:formatters]
|
||||
start_time = opts.fetch(:start_time) { Time.now }
|
||||
verbose = opts.fetch(:verbose, false)
|
||||
|
||||
new(reporter, files).run
|
||||
if verbose
|
||||
STDERR.puts "VERBOSE"
|
||||
end
|
||||
|
||||
def initialize(reporter, files)
|
||||
@reporter = reporter
|
||||
@files = files
|
||||
reporter = Reporter.from_config(formatters, start_time)
|
||||
|
||||
new(
|
||||
reporter: reporter,
|
||||
files: files,
|
||||
verbose: verbose
|
||||
).run
|
||||
end
|
||||
|
||||
def initialize(opts)
|
||||
@reporter = opts[:reporter]
|
||||
@files = opts[:files]
|
||||
@verbose = opts[:verbose]
|
||||
|
||||
@messages = Queue.new
|
||||
@threads = []
|
||||
end
|
||||
|
@ -61,14 +76,24 @@ module TurboTests
|
|||
rescue Errno::EEXIST
|
||||
end
|
||||
|
||||
_stdin, stdout, stderr, _wait_thr =
|
||||
Open3.popen3(
|
||||
{ 'TEST_ENV_NUMBER' => process_num.to_s },
|
||||
env = { 'TEST_ENV_NUMBER' => process_num.to_s }
|
||||
command = [
|
||||
"bundle", "exec", "rspec",
|
||||
"-f", "TurboTests::JsonRowsFormatter",
|
||||
"-o", "tmp/test-pipes/subprocess-#{process_num}",
|
||||
*tests
|
||||
)
|
||||
]
|
||||
|
||||
if @verbose
|
||||
command_str = [
|
||||
env.map { |k, v| "#{k}=#{v}" }.join(' '),
|
||||
command.join(' ')
|
||||
].join(' ')
|
||||
|
||||
STDERR.puts "Process #{process_num}: #{command_str}"
|
||||
end
|
||||
|
||||
_stdin, stdout, stderr, _wait_thr = Open3.popen3(env, *command)
|
||||
|
||||
@threads <<
|
||||
Thread.new do
|
||||
|
|
Loading…
Reference in New Issue