mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
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 = []
|
requires = []
|
||||||
formatters = []
|
formatters = []
|
||||||
|
verbose = false
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.on("-r", "--require PATH", "Require a file.") do |filename|
|
opts.on("-r", "--require PATH", "Require a file.") do |filename|
|
||||||
@ -28,6 +29,10 @@ OptionParser.new do |opts|
|
|||||||
end
|
end
|
||||||
formatters.last[:outputs] << filename
|
formatters.last[:outputs] << filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("-v", "--verbose", "More output") do
|
||||||
|
verbose = true
|
||||||
|
end
|
||||||
end.parse!(ARGV)
|
end.parse!(ARGV)
|
||||||
|
|
||||||
requires.each { |f| require(f) }
|
requires.each { |f| require(f) }
|
||||||
@ -45,4 +50,8 @@ formatters.each do |formatter|
|
|||||||
end
|
end
|
||||||
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|
|
task 'turbo:spec' => :test do |t|
|
||||||
require './lib/turbo_tests'
|
require './lib/turbo_tests'
|
||||||
|
|
||||||
TurboTests::Runner.run([{ name: 'progress', outputs: ['-'] }], ['spec'])
|
TurboTests::Runner.run(
|
||||||
|
formatters: [{ name: 'progress', outputs: ['-'] }],
|
||||||
|
files: ['spec']
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
@ -2,15 +2,30 @@
|
|||||||
|
|
||||||
module TurboTests
|
module TurboTests
|
||||||
class Runner
|
class Runner
|
||||||
def self.run(formatter_config, files, start_time = Time.now)
|
def self.run(opts = {})
|
||||||
reporter = Reporter.from_config(formatter_config, start_time)
|
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
|
||||||
|
|
||||||
|
reporter = Reporter.from_config(formatters, start_time)
|
||||||
|
|
||||||
|
new(
|
||||||
|
reporter: reporter,
|
||||||
|
files: files,
|
||||||
|
verbose: verbose
|
||||||
|
).run
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(reporter, files)
|
def initialize(opts)
|
||||||
@reporter = reporter
|
@reporter = opts[:reporter]
|
||||||
@files = files
|
@files = opts[:files]
|
||||||
|
@verbose = opts[:verbose]
|
||||||
|
|
||||||
@messages = Queue.new
|
@messages = Queue.new
|
||||||
@threads = []
|
@threads = []
|
||||||
end
|
end
|
||||||
@ -61,14 +76,24 @@ module TurboTests
|
|||||||
rescue Errno::EEXIST
|
rescue Errno::EEXIST
|
||||||
end
|
end
|
||||||
|
|
||||||
_stdin, stdout, stderr, _wait_thr =
|
env = { 'TEST_ENV_NUMBER' => process_num.to_s }
|
||||||
Open3.popen3(
|
command = [
|
||||||
{ 'TEST_ENV_NUMBER' => process_num.to_s },
|
"bundle", "exec", "rspec",
|
||||||
"bundle", "exec", "rspec",
|
"-f", "TurboTests::JsonRowsFormatter",
|
||||||
"-f", "TurboTests::JsonRowsFormatter",
|
"-o", "tmp/test-pipes/subprocess-#{process_num}",
|
||||||
"-o", "tmp/test-pipes/subprocess-#{process_num}",
|
*tests
|
||||||
*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 <<
|
@threads <<
|
||||||
Thread.new do
|
Thread.new do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user