parallel_tests 3.10.1 → 3.12.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 777189ca793239a4c1f468a50d69c3518047cb5ea72432521fd99ab8b9a7b61c
4
- data.tar.gz: 47b6fad3f42ab691d29ed8037cb0025d318ef791b90769aafc86edf8ca88cb1f
3
+ metadata.gz: 43b7f3d9cbea0ac1e60e570c94794ce1e6c5dc341c07beadea2c967a2504b284
4
+ data.tar.gz: cccd254b7ea61a2d718590647d8f4fb6166603bf5207de0dffc8ab359400d3a1
5
5
  SHA512:
6
- metadata.gz: a473918b8acb6391550a1a2a5d4f7a261994aea2937b37ad927b73282b4c9a9d61a3d9a656ce429abeb76321ae9a2a3ee084fb962c4bb026e8692712b9b8b9ce
7
- data.tar.gz: 75d3625ec3b6f89cdd3b8a7463b156de059cabd5da49b3bbd4797b413e35ee0cd9955f0274a289f09d82293b19ae9ae084a371b67cba3c2a2cc22fc5e3a52057
6
+ metadata.gz: 7f1a3d2a5644d801647d6650257c59fc2b33f9de9eb23d4475a9e53d6b9f14573a445c5dbf56d4af8f9066a9d9315380fe656cfccd1bbb796254bd66e49277ae
7
+ data.tar.gz: f60aebf5e1156f0fe05822c0c2e18f29469d2897a9b8db90963f257b93a4f8f79ea54f655447ec43b09127c69647d3081ad860a5a04b5f67ee014276c9366c0e
data/Readme.md CHANGED
@@ -403,6 +403,7 @@ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rs
403
403
  - [Joshua Pinter](https://github.com/joshuapinter)
404
404
  - [Zach Dennis](https://github.com/zdennis)
405
405
  - [Jon Dufresne](https://github.com/jdufresne)
406
+ - [Eric Kessler](https://github.com/enkessler)
406
407
 
407
408
  [Michael Grosser](http://grosser.it)<br/>
408
409
  michael@grosser.it<br/>
@@ -61,20 +61,15 @@ module ParallelTests
61
61
  groups = @runner.tests_in_groups(options[:files], num_processes, options)
62
62
  groups.reject!(&:empty?)
63
63
 
64
- test_results = if options[:only_group]
65
- groups_to_run = options[:only_group].map { |i| groups[i - 1] }.compact
66
- report_number_of_tests(groups_to_run) unless options[:quiet]
67
- execute_in_parallel(groups_to_run, groups_to_run.size, options) do |group|
68
- run_tests(group, groups_to_run.index(group), 1, options)
69
- end
70
- else
71
- report_number_of_tests(groups) unless options[:quiet]
72
-
73
- execute_in_parallel(groups, groups.size, options) do |group|
74
- run_tests(group, groups.index(group), num_processes, options)
75
- end
64
+ if options[:only_group]
65
+ groups = options[:only_group].map { |i| groups[i - 1] }.compact
66
+ num_processes = 1
76
67
  end
77
68
 
69
+ report_number_of_tests(groups) unless options[:quiet]
70
+ test_results = execute_in_parallel(groups, groups.size, options) do |group|
71
+ run_tests(group, groups.index(group), num_processes, options)
72
+ end
78
73
  report_results(test_results, options) unless options[:quiet]
79
74
  end
80
75
 
@@ -228,7 +223,7 @@ module ParallelTests
228
223
  processes in a specific formation. Commas indicate specs in the same process,
229
224
  pipes indicate specs in a new process. Cannot use with --single, --isolate, or
230
225
  --isolate-n. Ex.
231
- $ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
226
+ $ parallel_test -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
232
227
  Process 1 will contain 1_spec.rb and 2_spec.rb
233
228
  Process 2 will contain 3_spec.rb
234
229
  Process 3 will contain all other specs
@@ -396,7 +391,7 @@ module ParallelTests
396
391
  def simulate_output_for_ci(simulate)
397
392
  if simulate
398
393
  progress_indicator = Thread.new do
399
- interval = Float(ENV.fetch('PARALLEL_TEST_HEARTBEAT_INTERVAL', 60))
394
+ interval = Float(ENV['PARALLEL_TEST_HEARTBEAT_INTERVAL'] || 60)
400
395
  loop do
401
396
  sleep interval
402
397
  print '.'
@@ -52,7 +52,9 @@ module ParallelTests
52
52
  feature_tags = feature.tags.map(&:name)
53
53
 
54
54
  # We loop on each children of the feature
55
- feature.tests.each do |test|
55
+ test_models = feature.tests
56
+ test_models += feature.rules.flat_map(&:tests) if feature.respond_to?(:rules) # cuke_modeler >= 3.2 supports rules
57
+ test_models.each do |test|
56
58
  # It's a scenario, we add it to the scenario_line_logger
57
59
  scenario_line_logger.visit_feature_element(document.path, test, feature_tags, line_numbers: test_lines)
58
60
  end
@@ -102,6 +102,29 @@ module ParallelTests
102
102
  end
103
103
  end
104
104
 
105
+ def build_run_command(type, args)
106
+ count, pattern, options, pass_through = ParallelTests::Tasks.parse_args(args)
107
+ test_framework = {
108
+ 'spec' => 'rspec',
109
+ 'test' => 'test',
110
+ 'features' => 'cucumber',
111
+ 'features-spinach' => 'spinach'
112
+ }.fetch(type)
113
+
114
+ type = 'features' if test_framework == 'spinach'
115
+
116
+ # Using the relative path to find the binary allow to run a specific version of it
117
+ executable = File.expand_path('../../bin/parallel_test', __dir__)
118
+ executable = ParallelTests.with_ruby_binary(executable)
119
+
120
+ command = [*executable, type, '--type', test_framework]
121
+ command += ['-n', count.to_s] if count
122
+ command += ['--pattern', pattern] if pattern
123
+ command += ['--test-options', options] if options
124
+ command += Shellwords.shellsplit pass_through if pass_through
125
+ command
126
+ end
127
+
105
128
  private
106
129
 
107
130
  def rails_7_or_greater?
@@ -237,24 +260,7 @@ namespace :parallel do
237
260
  task type, [:count, :pattern, :options, :pass_through] do |_t, args|
238
261
  ParallelTests::Tasks.check_for_pending_migrations
239
262
  ParallelTests::Tasks.load_lib
240
-
241
- count, pattern, options, pass_through = ParallelTests::Tasks.parse_args(args)
242
- test_framework = {
243
- 'spec' => 'rspec',
244
- 'test' => 'test',
245
- 'features' => 'cucumber',
246
- 'features-spinach' => 'spinach'
247
- }.fetch(type)
248
-
249
- type = 'features' if test_framework == 'spinach'
250
- # Using the relative path to find the binary allow to run a specific version of it
251
- executable = File.expand_path('../../bin/parallel_test', __dir__)
252
-
253
- command = [*ParallelTests.with_ruby_binary(executable), type, '--type', test_framework]
254
- command += ['-n', count.to_s] if count
255
- command += ['--pattern', pattern] if pattern
256
- command += ['--test-options', options] if options
257
- command += Shellwords.shellsplit pass_through if pass_through
263
+ command = ParallelTests::Tasks.build_run_command(type, args)
258
264
 
259
265
  abort unless system(*command) # allow to chain tasks e.g. rake parallel:spec parallel:features
260
266
  end
@@ -5,6 +5,8 @@ require 'parallel_tests'
5
5
  module ParallelTests
6
6
  module Test
7
7
  class Runner
8
+ RuntimeLogTooSmallError = Class.new(StandardError)
9
+
8
10
  class << self
9
11
  # --- usually overwritten by other runners
10
12
 
@@ -84,13 +86,17 @@ module ParallelTests
84
86
  end
85
87
 
86
88
  def execute_command(cmd, process_number, num_processes, options)
89
+ number = test_env_number(process_number, options).to_s
87
90
  env = (options[:env] || {}).merge(
88
- "TEST_ENV_NUMBER" => test_env_number(process_number, options).to_s,
91
+ "TEST_ENV_NUMBER" => number,
89
92
  "PARALLEL_TEST_GROUPS" => num_processes.to_s,
90
93
  "PARALLEL_PID_FILE" => ParallelTests.pid_file_path
91
94
  )
92
95
  cmd = ["nice", *cmd] if options[:nice]
93
96
 
97
+ # being able to run with for example `-output foo-$TEST_ENV_NUMBER` worked originally and is convenient
98
+ cmd.map! { |c| c.gsub("$TEST_ENV_NUMBER", number).gsub("${TEST_ENV_NUMBER}", number) }
99
+
94
100
  puts Shellwords.shelljoin(cmd) if report_process_command?(options) && !options[:serialize_stdout]
95
101
 
96
102
  execute_command_and_capture_output(env, cmd, options)
@@ -147,8 +153,8 @@ module ParallelTests
147
153
  protected
148
154
 
149
155
  def executable
150
- if ENV.include?('PARALLEL_TESTS_EXECUTABLE')
151
- [ENV['PARALLEL_TESTS_EXECUTABLE']]
156
+ if (executable = ENV['PARALLEL_TESTS_EXECUTABLE'])
157
+ [executable]
152
158
  else
153
159
  determine_executable
154
160
  end
@@ -199,7 +205,7 @@ module ParallelTests
199
205
  allowed_missing -= 1 unless time = runtimes[test]
200
206
  if allowed_missing < 0
201
207
  log = options[:runtime_log] || runtime_log
202
- raise "Runtime log file '#{log}' does not contain sufficient data to sort #{tests.size} test files, please update or remove it."
208
+ raise RuntimeLogTooSmallError, "Runtime log file '#{log}' does not contain sufficient data to sort #{tests.size} test files, please update or remove it."
203
209
  end
204
210
  [test, time]
205
211
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ParallelTests
3
- VERSION = '3.10.1'
3
+ VERSION = '3.12.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.1
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-24 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -68,8 +68,8 @@ licenses:
68
68
  - MIT
69
69
  metadata:
70
70
  bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
71
- documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.10.1/Readme.md
72
- source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.10.1
71
+ documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.12.0/Readme.md
72
+ source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.12.0
73
73
  wiki_uri: https://github.com/grosser/parallel_tests/wiki
74
74
  post_install_message:
75
75
  rdoc_options: []