lib/parallel_tests/cli.rb in parallel_tests-3.8.1 vs lib/parallel_tests/cli.rb in parallel_tests-3.9.0
- old
+ new
@@ -18,11 +18,11 @@
num_processes *= (options[:multiply] || 1)
options[:first_is_1] ||= first_is_1?
if options[:execute]
- execute_shell_command_in_parallel(options[:execute], num_processes, options)
+ execute_command_in_parallel(options[:execute], num_processes, options)
else
run_tests_in_parallel(num_processes, options)
end
end
@@ -98,11 +98,11 @@
end
end
def run_tests(group, process_number, num_processes, options)
if group.empty?
- { stdout: '', exit_status: 0, command: '', seed: nil }
+ { stdout: '', exit_status: 0, command: nil, seed: nil }
else
@runner.run_tests(group, process_number, num_processes, options)
end
end
@@ -138,13 +138,12 @@
if options[:verbose] || options[:verbose_rerun_command]
puts "\n\nTests have failed for a parallel_test group. Use the following command to run the group again:\n\n"
failing_sets.each do |failing_set|
command = failing_set[:command]
- command = command.gsub(/;export [A-Z_]+;/, ' ') # remove ugly export statements
command = @runner.command_with_seed(command, failing_set[:seed]) if failing_set[:seed]
- puts command
+ puts Shellwords.shelljoin(command)
end
end
end
def report_number_of_tests(groups)
@@ -236,12 +235,12 @@
TEXT
) { |groups| options[:specify_groups] = groups }
opts.on("--only-group INT[,INT]", Array) { |groups| options[:only_group] = groups.map(&:to_i) }
- opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |path| options[:execute] = path }
- opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg.lstrip }
+ opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
+ opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = Shellwords.shellsplit(arg) }
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
@runner = load_runner(type)
rescue NameError, LoadError => e
puts "Runner for `#{type}` type has not been found! (#{e})"
abort
@@ -332,21 +331,21 @@
def append_test_options(options, argv)
new_opts = extract_test_options(argv)
return if new_opts.empty?
- prev_and_new = [options[:test_options], new_opts.shelljoin]
- options[:test_options] = prev_and_new.compact.join(' ')
+ options[:test_options] ||= []
+ options[:test_options] += new_opts
end
def load_runner(type)
require "parallel_tests/#{type}/runner"
runner_classname = type.split("_").map(&:capitalize).join.sub("Rspec", "RSpec")
klass_name = "ParallelTests::#{runner_classname}::Runner"
klass_name.split('::').inject(Object) { |x, y| x.const_get(y) }
end
- def execute_shell_command_in_parallel(command, num_processes, options)
+ def execute_command_in_parallel(command, num_processes, options)
runs = if options[:only_group]
options[:only_group].map { |g| g - 1 }
else
(0...num_processes).to_a
end