parallel_tests 3.7.3 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,22 +3,14 @@ require 'parallel_tests/rspec/logger_base'
3
3
  require 'parallel_tests/rspec/runner'
4
4
 
5
5
  class ParallelTests::RSpec::FailuresLogger < ParallelTests::RSpec::LoggerBase
6
- if RSPEC_2
7
- def dump_failures(*args); end
8
- else
9
- RSpec::Core::Formatters.register self, :dump_summary
10
- end
6
+ RSpec::Core::Formatters.register(self, :dump_summary)
11
7
 
12
8
  def dump_summary(*args)
13
9
  lock_output do
14
- if RSPEC_2
15
- dump_commands_to_rerun_failed_examples
16
- else
17
- notification = args.first
18
- unless notification.failed_examples.empty?
19
- colorizer = ::RSpec::Core::Formatters::ConsoleCodes
20
- output.puts notification.colorized_rerun_commands(colorizer)
21
- end
10
+ notification = args.first
11
+ unless notification.failed_examples.empty?
12
+ colorizer = ::RSpec::Core::Formatters::ConsoleCodes
13
+ output.puts notification.colorized_rerun_commands(colorizer)
22
14
  end
23
15
  end
24
16
  @output.flush
@@ -7,8 +7,6 @@ end
7
7
  require 'rspec/core/formatters/base_text_formatter'
8
8
 
9
9
  class ParallelTests::RSpec::LoggerBase < RSpec::Core::Formatters::BaseTextFormatter
10
- RSPEC_2 = RSpec::Core::Version::STRING.start_with?('2')
11
-
12
10
  def initialize(*args)
13
11
  super
14
12
 
@@ -7,8 +7,7 @@ module ParallelTests
7
7
  DEV_NULL = (WINDOWS ? "NUL" : "/dev/null")
8
8
  class << self
9
9
  def run_tests(test_files, process_number, num_processes, options)
10
- exe = executable # expensive, so we cache
11
- cmd = [exe, options[:test_options], color, spec_opts, *test_files].compact.join(" ")
10
+ cmd = [*executable, *options[:test_options], *color, *spec_opts, *test_files]
12
11
  execute_command(cmd, process_number, num_processes, options)
13
12
  end
14
13
 
@@ -16,9 +15,9 @@ module ParallelTests
16
15
  if File.exist?("bin/rspec")
17
16
  ParallelTests.with_ruby_binary("bin/rspec")
18
17
  elsif ParallelTests.bundler_enabled?
19
- "bundle exec rspec"
18
+ ["bundle", "exec", "rspec"]
20
19
  else
21
- "rspec"
20
+ ["rspec"]
22
21
  end
23
22
  end
24
23
 
@@ -34,8 +33,10 @@ module ParallelTests
34
33
  "spec"
35
34
  end
36
35
 
36
+ # used to find all _spec.rb files
37
+ # supports also feature files used by rspec turnip extension
37
38
  def test_suffix
38
- /_spec\.rb$/
39
+ /(_spec\.rb|\.feature)$/
39
40
  end
40
41
 
41
42
  def line_is_result?(line)
@@ -48,8 +49,8 @@ module ParallelTests
48
49
  # --order rand:1234
49
50
  # --order random:1234
50
51
  def command_with_seed(cmd, seed)
51
- clean = cmd.sub(/\s--(seed\s+\d+|order\s+rand(om)?(:\d+)?)\b/, '')
52
- "#{clean} --seed #{seed}"
52
+ clean = remove_command_arguments(cmd, '--seed', '--order')
53
+ [*clean, '--seed', seed]
53
54
  end
54
55
 
55
56
  # Summarize results from threads and colorize results based on failure and pending counts.
@@ -71,19 +72,13 @@ module ParallelTests
71
72
 
72
73
  private
73
74
 
74
- # so it can be stubbed....
75
- def run(cmd)
76
- `#{cmd}`
77
- end
78
-
79
75
  def color
80
- '--color --tty' if $stdout.tty?
76
+ ['--color', '--tty'] if $stdout.tty?
81
77
  end
82
78
 
83
79
  def spec_opts
84
80
  options_file = ['.rspec_parallel', 'spec/parallel_spec.opts', 'spec/spec.opts'].detect { |f| File.file?(f) }
85
- return unless options_file
86
- "-O #{options_file}"
81
+ ["-O", options_file] if options_file
87
82
  end
88
83
  end
89
84
  end
@@ -9,7 +9,7 @@ class ParallelTests::RSpec::RuntimeLogger < ParallelTests::RSpec::LoggerBase
9
9
  @group_nesting = 0
10
10
  end
11
11
 
12
- RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished, :start_dump unless RSPEC_2
12
+ RSpec::Core::Formatters.register(self, :example_group_started, :example_group_finished, :start_dump)
13
13
 
14
14
  def example_group_started(example_group)
15
15
  @time = ParallelTests.now if @group_nesting == 0
@@ -20,8 +20,7 @@ class ParallelTests::RSpec::RuntimeLogger < ParallelTests::RSpec::LoggerBase
20
20
  def example_group_finished(notification)
21
21
  @group_nesting -= 1
22
22
  if @group_nesting == 0
23
- path = (RSPEC_2 ? notification.file_path : notification.group.file_path)
24
- @example_times[path] += ParallelTests.now - @time
23
+ @example_times[notification.group.file_path] += ParallelTests.now - @time
25
24
  end
26
25
  super if defined?(super)
27
26
  end
@@ -37,9 +36,11 @@ class ParallelTests::RSpec::RuntimeLogger < ParallelTests::RSpec::LoggerBase
37
36
  def start_dump(*)
38
37
  return unless ENV['TEST_ENV_NUMBER'] # only record when running in parallel
39
38
  lock_output do
39
+ # Order the output from slowest to fastest
40
+ @example_times = @example_times.sort_by(&:last).reverse
40
41
  @example_times.each do |file, time|
41
42
  relative_path = file.sub(%r{^#{Regexp.escape Dir.pwd}/}, '').sub(%r{^\./}, "")
42
- @output.puts "#{relative_path}:#{time > 0 ? time : 0}"
43
+ @output.puts "#{relative_path}:#{[time, 0].max}"
43
44
  end
44
45
  end
45
46
  @output.flush
@@ -2,7 +2,7 @@
2
2
  require 'parallel_tests/rspec/failures_logger'
3
3
 
4
4
  class ParallelTests::RSpec::SummaryLogger < ParallelTests::RSpec::LoggerBase
5
- RSpec::Core::Formatters.register self, :dump_failures unless RSPEC_2
5
+ RSpec::Core::Formatters.register(self, :dump_failures)
6
6
 
7
7
  def dump_failures(*args)
8
8
  lock_output { super }
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/formatters/base_text_formatter'
4
+ require 'parallel_tests/rspec/runner'
5
+
6
+ class ParallelTests::RSpec::VerboseLogger < RSpec::Core::Formatters::BaseTextFormatter
7
+ RSpec::Core::Formatters.register(
8
+ self,
9
+ :example_group_started,
10
+ :example_group_finished,
11
+ :example_started,
12
+ :example_passed,
13
+ :example_pending,
14
+ :example_failed
15
+ )
16
+
17
+ def initialize(output)
18
+ super
19
+ @line = []
20
+ end
21
+
22
+ def example_group_started(notification)
23
+ @line.push(notification.group.description)
24
+ end
25
+
26
+ def example_group_finished(_notification)
27
+ @line.pop
28
+ end
29
+
30
+ def example_started(notification)
31
+ @line.push(notification.example.description)
32
+ output_formatted_line('STARTED', :yellow)
33
+ end
34
+
35
+ def example_passed(_passed)
36
+ output_formatted_line('PASSED', :success)
37
+ @line.pop
38
+ end
39
+
40
+ def example_pending(_pending)
41
+ output_formatted_line('PENDING', :pending)
42
+ @line.pop
43
+ end
44
+
45
+ def example_failed(_failure)
46
+ output_formatted_line('FAILED', :failure)
47
+ @line.pop
48
+ end
49
+
50
+ private
51
+
52
+ def output_formatted_line(status, console_code)
53
+ prefix = ["[#{Process.pid}]"]
54
+ if ENV.include?('TEST_ENV_NUMBER')
55
+ test_env_number = ENV['TEST_ENV_NUMBER'] == '' ? 1 : Integer(ENV['TEST_ENV_NUMBER'])
56
+ prefix << "[#{test_env_number}]"
57
+ end
58
+ prefix << RSpec::Core::Formatters::ConsoleCodes.wrap("[#{status}]", console_code)
59
+
60
+ output.puts [*prefix, *@line].join(' ')
61
+ end
62
+ end
@@ -15,7 +15,7 @@ module ParallelTests
15
15
 
16
16
  def runtime_logging
17
17
  # Not Yet Supported
18
- ""
18
+ []
19
19
  end
20
20
  end
21
21
  end
@@ -9,16 +9,8 @@ module ParallelTests
9
9
  'test'
10
10
  end
11
11
 
12
- def rake_bin
13
- # Prevent 'Exec format error' Errno::ENOEXEC on Windows
14
- return "rake" if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
15
- binstub_path = File.join('bin', 'rake')
16
- return binstub_path if File.exist?(binstub_path)
17
- "rake"
18
- end
19
-
20
12
  def load_lib
21
- $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..'))
13
+ $LOAD_PATH << File.expand_path('..', __dir__)
22
14
  require "parallel_tests"
23
15
  end
24
16
 
@@ -30,12 +22,15 @@ module ParallelTests
30
22
 
31
23
  def run_in_parallel(cmd, options = {})
32
24
  load_lib
33
- count = " -n #{options[:count]}" unless options[:count].to_s.empty?
25
+
34
26
  # Using the relative path to find the binary allow to run a specific version of it
35
27
  executable = File.expand_path('../../bin/parallel_test', __dir__)
36
- non_parallel = (options[:non_parallel] ? ' --non-parallel' : '')
37
- command = "#{ParallelTests.with_ruby_binary(Shellwords.escape(executable))} --exec '#{cmd}'#{count}#{non_parallel}"
38
- abort unless system(command)
28
+ command = ParallelTests.with_ruby_binary(executable)
29
+ command += ['--exec', Shellwords.join(cmd)]
30
+ command += ['-n', options[:count]] unless options[:count].to_s.empty?
31
+ command << '--non-parallel' if options[:non_parallel]
32
+
33
+ abort unless system(*command)
39
34
  end
40
35
 
41
36
  # this is a crazy-complex solution for a very simple problem:
@@ -48,16 +43,17 @@ module ParallelTests
48
43
  # - pipefail makes pipe fail with exitstatus of first failed command
49
44
  # - pipefail is not supported in (zsh)
50
45
  # - defining a new rake task like silence_schema would force users to load parallel_tests in test env
51
- # - do not use ' since run_in_parallel uses them to quote stuff
52
46
  # - simple system "set -o pipefail" returns nil even though set -o pipefail exists with 0
53
47
  def suppress_output(command, ignore_regex)
54
48
  activate_pipefail = "set -o pipefail"
55
- remove_ignored_lines = %{(grep -v "#{ignore_regex}" || test 1)}
49
+ remove_ignored_lines = %{(grep -v #{Shellwords.escape(ignore_regex)} || true)}
56
50
 
57
- if File.executable?('/bin/bash') && system('/bin/bash', '-c', "#{activate_pipefail} 2>/dev/null && test 1")
58
- # We need to shell escape single quotes (' becomes '"'"') because
59
- # run_in_parallel wraps command in single quotes
60
- %{/bin/bash -c '"'"'#{activate_pipefail} && (#{command}) | #{remove_ignored_lines}'"'"'}
51
+ # remove nil values (ex: #purge_before_load returns nil)
52
+ command.compact!
53
+
54
+ if system('/bin/bash', '-c', "#{activate_pipefail} 2>/dev/null")
55
+ shell_command = "#{activate_pipefail} && (#{Shellwords.shelljoin(command)}) | #{remove_ignored_lines}"
56
+ ['/bin/bash', '-c', shell_command]
61
57
  else
62
58
  command
63
59
  end
@@ -90,7 +86,74 @@ module ParallelTests
90
86
  options = args.shift
91
87
  pass_through = args.shift
92
88
 
93
- [num_processes, pattern.to_s, options.to_s, pass_through.to_s]
89
+ [num_processes, pattern, options, pass_through]
90
+ end
91
+
92
+ def schema_format_based_on_rails_version
93
+ if rails_7_or_greater?
94
+ ActiveRecord.schema_format
95
+ else
96
+ ActiveRecord::Base.schema_format
97
+ end
98
+ end
99
+
100
+ def schema_type_based_on_rails_version
101
+ if rails_61_or_greater? || schema_format_based_on_rails_version == :ruby
102
+ "schema"
103
+ else
104
+ "structure"
105
+ end
106
+ end
107
+
108
+ def build_run_command(type, args)
109
+ count, pattern, options, pass_through = ParallelTests::Tasks.parse_args(args)
110
+ test_framework = {
111
+ 'spec' => 'rspec',
112
+ 'test' => 'test',
113
+ 'features' => 'cucumber',
114
+ 'features-spinach' => 'spinach'
115
+ }.fetch(type)
116
+
117
+ type = 'features' if test_framework == 'spinach'
118
+
119
+ # Using the relative path to find the binary allow to run a specific version of it
120
+ executable = File.expand_path('../../bin/parallel_test', __dir__)
121
+ executable = ParallelTests.with_ruby_binary(executable)
122
+
123
+ command = [*executable, type, '--type', test_framework]
124
+ command += ['-n', count.to_s] if count
125
+ command += ['--pattern', pattern] if pattern
126
+ command += ['--test-options', options] if options
127
+ command += Shellwords.shellsplit pass_through if pass_through
128
+ command
129
+ end
130
+
131
+ def configured_databases
132
+ return [] unless defined?(ActiveRecord) && rails_61_or_greater?
133
+
134
+ @@configured_databases ||= ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
135
+ end
136
+
137
+ def for_each_database(&block)
138
+ # Use nil to represent all databases
139
+ block&.call(nil)
140
+
141
+ # skip if not rails or old rails version
142
+ return if !defined?(ActiveRecord::Tasks::DatabaseTasks) || !ActiveRecord::Tasks::DatabaseTasks.respond_to?(:for_each)
143
+
144
+ ActiveRecord::Tasks::DatabaseTasks.for_each(configured_databases) do |name|
145
+ block&.call(name)
146
+ end
147
+ end
148
+
149
+ private
150
+
151
+ def rails_7_or_greater?
152
+ Gem::Version.new(Rails.version) >= Gem::Version.new('7.0')
153
+ end
154
+
155
+ def rails_61_or_greater?
156
+ Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
94
157
  end
95
158
  end
96
159
  end
@@ -99,36 +162,46 @@ end
99
162
  namespace :parallel do
100
163
  desc "Setup test databases via db:setup --> parallel:setup[num_cpus]"
101
164
  task :setup, :count do |_, args|
102
- command = "#{ParallelTests::Tasks.rake_bin} db:setup RAILS_ENV=#{ParallelTests::Tasks.rails_env}"
165
+ command = [$0, "db:setup", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"]
103
166
  ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
104
167
  end
105
168
 
106
- desc "Create test databases via db:create --> parallel:create[num_cpus]"
107
- task :create, :count do |_, args|
108
- ParallelTests::Tasks.run_in_parallel(
109
- "#{ParallelTests::Tasks.rake_bin} db:create RAILS_ENV=#{ParallelTests::Tasks.rails_env}", args
110
- )
169
+ ParallelTests::Tasks.for_each_database do |name|
170
+ task_name = 'create'
171
+ task_name += ":#{name}" if name
172
+ desc "Create test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
173
+ task task_name.to_sym, :count do |_, args|
174
+ ParallelTests::Tasks.run_in_parallel(
175
+ [$0, "db:#{task_name}", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
176
+ args
177
+ )
178
+ end
111
179
  end
112
180
 
113
- desc "Drop test databases via db:drop --> parallel:drop[num_cpus]"
114
- task :drop, :count do |_, args|
115
- ParallelTests::Tasks.run_in_parallel(
116
- "#{ParallelTests::Tasks.rake_bin} db:drop RAILS_ENV=#{ParallelTests::Tasks.rails_env} " \
117
- "DISABLE_DATABASE_ENVIRONMENT_CHECK=1", args
118
- )
181
+ ParallelTests::Tasks.for_each_database do |name|
182
+ task_name = 'drop'
183
+ task_name += ":#{name}" if name
184
+ desc "Drop test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
185
+ task task_name.to_sym, :count do |_, args|
186
+ ParallelTests::Tasks.run_in_parallel(
187
+ [
188
+ $0,
189
+ "db:#{task_name}",
190
+ "RAILS_ENV=#{ParallelTests::Tasks.rails_env}",
191
+ "DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
192
+ ],
193
+ args
194
+ )
195
+ end
119
196
  end
120
197
 
121
198
  desc "Update test databases by dumping and loading --> parallel:prepare[num_cpus]"
122
199
  task(:prepare, [:count]) do |_, args|
123
200
  ParallelTests::Tasks.check_for_pending_migrations
124
- if defined?(ActiveRecord::Base) && [:ruby, :sql].include?(ActiveRecord::Base.schema_format)
201
+
202
+ if defined?(ActiveRecord) && [:ruby, :sql].include?(ParallelTests::Tasks.schema_format_based_on_rails_version)
125
203
  # fast: dump once, load in parallel
126
- type =
127
- if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
128
- "schema"
129
- else
130
- ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure"
131
- end
204
+ type = ParallelTests::Tasks.schema_type_based_on_rails_version
132
205
 
133
206
  Rake::Task["db:#{type}:dump"].invoke
134
207
 
@@ -140,32 +213,51 @@ namespace :parallel do
140
213
  # slow: dump and load in in serial
141
214
  args = args.to_hash.merge(non_parallel: true) # normal merge returns nil
142
215
  task_name = Rake::Task.task_defined?('db:test:prepare') ? 'db:test:prepare' : 'app:db:test:prepare'
143
- ParallelTests::Tasks.run_in_parallel("#{ParallelTests::Tasks.rake_bin} #{task_name}", args)
216
+ ParallelTests::Tasks.run_in_parallel([$0, task_name], args)
144
217
  next
145
218
  end
146
219
  end
147
220
 
148
221
  # when dumping/resetting takes too long
149
- desc "Update test databases via db:migrate --> parallel:migrate[num_cpus]"
150
- task :migrate, :count do |_, args|
151
- ParallelTests::Tasks.run_in_parallel(
152
- "#{ParallelTests::Tasks.rake_bin} db:migrate RAILS_ENV=#{ParallelTests::Tasks.rails_env}", args
153
- )
222
+ ParallelTests::Tasks.for_each_database do |name|
223
+ task_name = 'migrate'
224
+ task_name += ":#{name}" if name
225
+ desc "Update test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
226
+ task task_name.to_sym, :count do |_, args|
227
+ ParallelTests::Tasks.run_in_parallel(
228
+ [$0, "db:#{task_name}", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
229
+ args
230
+ )
231
+ end
154
232
  end
155
233
 
156
234
  desc "Rollback test databases via db:rollback --> parallel:rollback[num_cpus]"
157
235
  task :rollback, :count do |_, args|
158
236
  ParallelTests::Tasks.run_in_parallel(
159
- "#{ParallelTests::Tasks.rake_bin} db:rollback RAILS_ENV=#{ParallelTests::Tasks.rails_env}", args
237
+ [$0, "db:rollback", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
238
+ args
160
239
  )
161
240
  end
162
241
 
163
242
  # just load the schema (good for integration server <-> no development db)
164
- desc "Load dumped schema for test databases via db:schema:load --> parallel:load_schema[num_cpus]"
165
- task :load_schema, :count do |_, args|
166
- command = "#{ParallelTests::Tasks.rake_bin} #{ParallelTests::Tasks.purge_before_load} " \
167
- "db:schema:load RAILS_ENV=#{ParallelTests::Tasks.rails_env} DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
168
- ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
243
+ ParallelTests::Tasks.for_each_database do |name|
244
+ rails_task = 'db:schema:load'
245
+ rails_task += ":#{name}" if name
246
+
247
+ task_name = 'load_schema'
248
+ task_name += ":#{name}" if name
249
+
250
+ desc "Load dumped schema for test#{" #{name}" if name} database via #{rails_task} --> parallel:#{task_name}[num_cpus]"
251
+ task task_name.to_sym, :count do |_, args|
252
+ command = [
253
+ $0,
254
+ ParallelTests::Tasks.purge_before_load,
255
+ rails_task,
256
+ "RAILS_ENV=#{ParallelTests::Tasks.rails_env}",
257
+ "DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
258
+ ]
259
+ ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
260
+ end
169
261
  end
170
262
 
171
263
  # load the structure from the structure.sql file
@@ -173,23 +265,34 @@ namespace :parallel do
173
265
  desc "Load structure for test databases via db:schema:load --> parallel:load_structure[num_cpus]"
174
266
  task :load_structure, :count do |_, args|
175
267
  ParallelTests::Tasks.run_in_parallel(
176
- "#{ParallelTests::Tasks.rake_bin} #{ParallelTests::Tasks.purge_before_load} " \
177
- "db:structure:load RAILS_ENV=#{ParallelTests::Tasks.rails_env} DISABLE_DATABASE_ENVIRONMENT_CHECK=1", args
268
+ [
269
+ $0,
270
+ ParallelTests::Tasks.purge_before_load,
271
+ "db:structure:load",
272
+ "RAILS_ENV=#{ParallelTests::Tasks.rails_env}",
273
+ "DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
274
+ ],
275
+ args
178
276
  )
179
277
  end
180
278
 
181
279
  desc "Load the seed data from db/seeds.rb via db:seed --> parallel:seed[num_cpus]"
182
280
  task :seed, :count do |_, args|
183
281
  ParallelTests::Tasks.run_in_parallel(
184
- "#{ParallelTests::Tasks.rake_bin} db:seed RAILS_ENV=#{ParallelTests::Tasks.rails_env}", args
282
+ [
283
+ $0,
284
+ "db:seed",
285
+ "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"
286
+ ],
287
+ args
185
288
  )
186
289
  end
187
290
 
188
291
  desc "Launch given rake command in parallel"
189
292
  task :rake, :command, :count do |_, args|
190
293
  ParallelTests::Tasks.run_in_parallel(
191
- "RAILS_ENV=#{ParallelTests::Tasks.rails_env} #{ParallelTests::Tasks.rake_bin} " \
192
- "#{args.command}", args
294
+ [$0, args.command, "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
295
+ args
193
296
  )
194
297
  end
195
298
 
@@ -198,26 +301,9 @@ namespace :parallel do
198
301
  task type, [:count, :pattern, :options, :pass_through] do |_t, args|
199
302
  ParallelTests::Tasks.check_for_pending_migrations
200
303
  ParallelTests::Tasks.load_lib
304
+ command = ParallelTests::Tasks.build_run_command(type, args)
201
305
 
202
- count, pattern, options, pass_through = ParallelTests::Tasks.parse_args(args)
203
- test_framework = {
204
- 'spec' => 'rspec',
205
- 'test' => 'test',
206
- 'features' => 'cucumber',
207
- 'features-spinach' => 'spinach'
208
- }[type]
209
-
210
- type = 'features' if test_framework == 'spinach'
211
- # Using the relative path to find the binary allow to run a specific version of it
212
- executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
213
-
214
- command = "#{ParallelTests.with_ruby_binary(Shellwords.escape(executable))} #{type} " \
215
- "--type #{test_framework} " \
216
- "-n #{count} " \
217
- "--pattern '#{pattern}' " \
218
- "--test-options '#{options}' " \
219
- "#{pass_through}"
220
- abort unless system(command) # allow to chain tasks e.g. rake parallel:spec parallel:features
306
+ abort unless system(*command) # allow to chain tasks e.g. rake parallel:spec parallel:features
221
307
  end
222
308
  end
223
309
  end