lib/parallel_tests/gherkin/runner.rb in parallel_tests-3.8.1 vs lib/parallel_tests/gherkin/runner.rb in parallel_tests-3.9.0
- old
+ new
@@ -1,8 +1,7 @@
# frozen_string_literal: true
require "parallel_tests/test/runner"
-require 'shellwords'
module ParallelTests
module Gherkin
class Runner < ParallelTests::Test::Runner
class << self
@@ -14,21 +13,17 @@
combined_scenarios = grouped.map do |file, files_and_lines|
"#{file}:#{files_and_lines.map(&:last).join(':')}"
end
end
- sanitized_test_files = combined_scenarios.map { |val| WINDOWS ? "\"#{val}\"" : Shellwords.escape(val) }
-
options[:env] ||= {}
options[:env] = options[:env].merge({ 'AUTOTEST' => '1' }) if $stdout.tty?
- cmd = [
- executable,
- (runtime_logging if File.directory?(File.dirname(runtime_log))),
- *sanitized_test_files,
- cucumber_opts(options[:test_options])
- ].compact.reject(&:empty?).join(' ')
+ cmd = executable
+ cmd += runtime_logging if File.directory?(File.dirname(runtime_log))
+ cmd += combined_scenarios
+ cmd += cucumber_opts(options[:test_options])
execute_command(cmd, process_number, num_processes, options)
end
def test_file_name
@test_file_name || 'feature'
@@ -65,21 +60,21 @@
"#{sums[0]} (#{sums[1..-1].join(", ")})"
end.compact.join("\n")
end
def cucumber_opts(given)
- if given =~ (/--profile/) || given =~ (/(^|\s)-p /)
+ if given&.include?('--profile') || given&.include?('-p')
given
else
- [given, profile_from_config].compact.join(" ")
+ [*given, *profile_from_config]
end
end
def profile_from_config
# copied from https://github.com/cucumber/cucumber/blob/master/lib/cucumber/cli/profile_loader.rb#L85
config = Dir.glob("{,.config/,config/}#{name}{.yml,.yaml}").first
- "--profile parallel" if config && File.read(config) =~ /^parallel:/
+ ['--profile', 'parallel'] if config && File.read(config) =~ /^parallel:/
end
def tests_in_groups(tests, num_groups, options = {})
@test_file_name = "scenario" if options[:group_by] == :scenarios
method = "by_#{options[:group_by]}"
@@ -89,25 +84,25 @@
super
end
end
def runtime_logging
- "--format ParallelTests::Gherkin::RuntimeLogger --out #{runtime_log}"
+ ['--format', 'ParallelTests::Gherkin::RuntimeLogger', '--out', runtime_log]
end
def runtime_log
"tmp/parallel_runtime_#{name}.log"
end
def determine_executable
if File.exist?("bin/#{name}")
ParallelTests.with_ruby_binary("bin/#{name}")
elsif ParallelTests.bundler_enabled?
- "bundle exec #{name}"
+ ["bundle", "exec", name]
elsif File.file?("script/#{name}")
ParallelTests.with_ruby_binary("script/#{name}")
else
- name.to_s
+ [name.to_s]
end
end
end
end
end