parallel_tests 3.5.1 → 3.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8539140ebc96ac00552e9f1e51f63789f1007a997829d86e79a786a71400b7b
4
- data.tar.gz: be0f3f0785cd3b05882f9928a9fe83a6e10203a95e931b40f89566f1398e0691
3
+ metadata.gz: 9bef11937f866ff4dad761906b41261246e9b5bf5bba2baa4a2c0019da0b3d42
4
+ data.tar.gz: 5241a08bd2bd0a273347fa044b12e973b5f40ab899b750e5f00364a2db1b3e72
5
5
  SHA512:
6
- metadata.gz: 3bd0cfd72dd3a48b491198a5d2be73bb353dbdd5d1cd23cfac58f2429d44fe6b1ce6121c2ba6caed76c4b3c4aa4646fde9ef030dfd1d0a38fe30499e1a2ea38d
7
- data.tar.gz: 10493da0d865c2e3987c8c11edb8a8605349d23a754bcb70ba05e1579a5f9a8693e9e80730b5c8d601b66efe4406bdf14b50a3ec3ce305a339d07075f5c77d51
6
+ metadata.gz: fd2d6eeb089dae8a9925d94b70de446bd9c58e9342d8602be671aea38e521577d01273d677e8b3f278c307715cf11bce4e9a661326e75a4f484de0f798f48040
7
+ data.tar.gz: a14fcbccdcca6b1870af02ad24be6a316b504a6b14f8e37678c3b81894bbd7aac9a0403e7f45b37501c35c4be7e499a509b8b14bb288b139f43853c4c861fd26
data/Readme.md CHANGED
@@ -182,19 +182,24 @@ Setup for non-rails
182
182
 
183
183
  gem install parallel_tests
184
184
  # go to your project dir
185
- parallel_test test/
186
- parallel_rspec spec/
187
- parallel_cucumber features/
188
- parallel_spinach features/
185
+ parallel_test
186
+ parallel_rspec
187
+ parallel_cucumber
188
+ parallel_spinach
189
189
 
190
- - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc.
191
- - Only run selected files & folders:
190
+ - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc. (docker compose: expose it)
192
191
 
192
+ - Only run a subset of files / folders:
193
+
193
194
  `parallel_test test/bar test/baz/foo_text.rb`
194
195
 
195
196
  - Pass test-options and files via `--`:
196
-
197
- `parallel_test -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
197
+
198
+ `parallel_rspec -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
199
+
200
+ - Pass in test options, by using the -o flag (wrap everything in quotes):
201
+
202
+ `parallel_cucumber -n 2 -o '-p foo_profile --tags @only_this_tag or @only_that_tag --format summary'`
198
203
 
199
204
  Options are:
200
205
  <!-- copy output from bundle exec ./bin/parallel_test -h -->
@@ -202,22 +207,21 @@ Options are:
202
207
  -p, --pattern [PATTERN] run tests matching this regex pattern
203
208
  --exclude-pattern [PATTERN] exclude tests matching this regex pattern
204
209
  --group-by [TYPE] group tests by:
205
- found - order of finding files
206
- steps - number of cucumber/spinach steps
207
- scenarios - individual cucumber scenarios
208
- filesize - by size of the file
209
- runtime - info from runtime log
210
- default - runtime when runtime log is filled otherwise filesize
210
+ found - order of finding files
211
+ steps - number of cucumber/spinach steps
212
+ scenarios - individual cucumber scenarios
213
+ filesize - by size of the file
214
+ runtime - info from runtime log
215
+ default - runtime when runtime log is filled otherwise filesize
211
216
  -m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
212
217
  -s, --single [PATTERN] Run all matching files in the same process
213
- -i, --isolate Do not run any other tests in the group used by --single(-s).
214
- Automatically turned on if --isolate-n is set above 0.
215
- --isolate-n Number of processes for isolated groups. Default to 1 when --isolate is on.
218
+ -i, --isolate Do not run any other tests in the group used by --single(-s)
219
+ --isolate-n [PROCESSES] Use 'isolate' singles with number of processes, default: 1.
220
+ --highest-exit-status Exit with the highest exit status provided by test run(s)
216
221
  --specify-groups [SPECS] Use 'specify-groups' if you want to specify multiple specs running in multiple
217
222
  processes in a specific formation. Commas indicate specs in the same process,
218
- pipes indicate specs in a new process. Cannot use with --single, --isolate, or
223
+ pipes indicate specs in a new process. Cannot use with --single, --isolate, or
219
224
  --isolate-n. Ex.
220
- Ex.
221
225
  $ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
222
226
  Process 1 will contain 1_spec.rb and 2_spec.rb
223
227
  Process 2 will contain 3_spec.rb
@@ -227,8 +231,8 @@ Options are:
227
231
  -o, --test-options '[OPTIONS]' execute test commands with those options
228
232
  -t, --type [TYPE] test(default) / rspec / cucumber / spinach
229
233
  --suffix [PATTERN] override built in test file pattern (should match suffix):
230
- '_spec.rb$' - matches rspec files
231
- '_(test|spec).rb$' - matches test or spec files
234
+ '_spec.rb$' - matches rspec files
235
+ '_(test|spec).rb$' - matches test or spec files
232
236
  --serialize-stdout Serialize stdout output, nothing will be written until everything is done
233
237
  --prefix-output-with-test-env-number
234
238
  Prefixes test env number to the output when not using --serialize-stdout
@@ -394,6 +398,7 @@ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rs
394
398
  - [Nathan Broadbent](https://github.com/ndbroadbent)
395
399
  - [Vikram B Kumar](https://github.com/v-kumar)
396
400
  - [Joshua Pinter](https://github.com/joshuapinter)
401
+ - [Zach Dennis](https://github.com/zdennis)
397
402
 
398
403
  [Michael Grosser](http://grosser.it)<br/>
399
404
  michael@grosser.it<br/>
@@ -23,16 +23,14 @@ module ParallelTests
23
23
 
24
24
  def with_pid_file
25
25
  Tempfile.open('parallel_tests-pidfile') do |f|
26
- begin
27
- ENV['PARALLEL_PID_FILE'] = f.path
28
- # Pids object should be created before threads will start adding pids to it
29
- # Otherwise we would have to use Mutex to prevent creation of several instances
30
- @pids = pids
31
- yield
32
- ensure
33
- ENV['PARALLEL_PID_FILE'] = nil
34
- @pids = nil
35
- end
26
+ ENV['PARALLEL_PID_FILE'] = f.path
27
+ # Pids object should be created before threads will start adding pids to it
28
+ # Otherwise we would have to use Mutex to prevent creation of several instances
29
+ @pids = pids
30
+ yield
31
+ ensure
32
+ ENV['PARALLEL_PID_FILE'] = nil
33
+ @pids = nil
36
34
  end
37
35
  end
38
36
 
@@ -84,7 +84,18 @@ module ParallelTests
84
84
  report_time_taken(&run_tests_proc)
85
85
  end
86
86
 
87
- abort final_fail_message if any_test_failed?(test_results)
87
+ if any_test_failed?(test_results)
88
+ warn final_fail_message
89
+
90
+ # return the highest exit status to allow sub-processes to send things other than 1
91
+ exit_status = if options[:highest_exit_status]
92
+ test_results.map { |data| data.fetch(:exit_status) }.max
93
+ else
94
+ 1
95
+ end
96
+
97
+ exit exit_status
98
+ end
88
99
  end
89
100
 
90
101
  def run_tests(group, process_number, num_processes, options)
@@ -105,13 +116,11 @@ module ParallelTests
105
116
 
106
117
  def lock(lockfile)
107
118
  File.open(lockfile) do |lock|
108
- begin
109
- lock.flock File::LOCK_EX
110
- yield
111
- ensure
112
- # This shouldn't be necessary, but appears to be
113
- lock.flock File::LOCK_UN
114
- end
119
+ lock.flock File::LOCK_EX
120
+ yield
121
+ ensure
122
+ # This shouldn't be necessary, but appears to be
123
+ lock.flock File::LOCK_UN
115
124
  end
116
125
  end
117
126
 
@@ -209,6 +218,10 @@ module ParallelTests
209
218
  "Use 'isolate' singles with number of processes, default: 1."
210
219
  ) { |n| options[:isolate_count] = n }
211
220
 
221
+ opts.on("--highest-exit-status", "Exit with the highest exit status provided by test run(s)") do
222
+ options[:highest_exit_status] = true
223
+ end
224
+
212
225
  opts.on(
213
226
  "--specify-groups [SPECS]",
214
227
  <<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
@@ -228,12 +241,10 @@ module ParallelTests
228
241
  opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |path| options[:execute] = path }
229
242
  opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg.lstrip }
230
243
  opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
231
- begin
232
- @runner = load_runner(type)
233
- rescue NameError, LoadError => e
234
- puts "Runner for `#{type}` type has not been found! (#{e})"
235
- abort
236
- end
244
+ @runner = load_runner(type)
245
+ rescue NameError, LoadError => e
246
+ puts "Runner for `#{type}` type has not been found! (#{e})"
247
+ abort
237
248
  end
238
249
  opts.on(
239
250
  "--suffix [PATTERN]",
@@ -278,7 +289,14 @@ module ParallelTests
278
289
 
279
290
  files, remaining = extract_file_paths(argv)
280
291
  unless options[:execute]
281
- abort "Pass files or folders to run" unless files.any?
292
+ if files.empty?
293
+ default_test_folder = @runner.default_test_folder
294
+ if File.directory?(default_test_folder)
295
+ files = [default_test_folder]
296
+ else
297
+ abort "Pass files or folders to run"
298
+ end
299
+ end
282
300
  options[:files] = files.map { |file_path| Pathname.new(file_path).cleanpath.to_s }
283
301
  end
284
302
 
@@ -12,6 +12,10 @@ module ParallelTests
12
12
  'cucumber'
13
13
  end
14
14
 
15
+ def default_test_folder
16
+ 'features'
17
+ end
18
+
15
19
  def line_is_result?(line)
16
20
  super || line =~ SCENARIO_REGEX || line =~ SCENARIOS_RESULTS_BOUNDARY_REGEX
17
21
  end
@@ -24,8 +24,8 @@ module ParallelTests
24
24
  cmd = [
25
25
  executable,
26
26
  (runtime_logging if File.directory?(File.dirname(runtime_log))),
27
- cucumber_opts(options[:test_options]),
28
- *sanitized_test_files
27
+ *sanitized_test_files,
28
+ cucumber_opts(options[:test_options])
29
29
  ].compact.reject(&:empty?).join(' ')
30
30
  execute_command(cmd, process_number, num_processes, options)
31
31
  end
@@ -34,6 +34,10 @@ module ParallelTests
34
34
  @test_file_name || 'feature'
35
35
  end
36
36
 
37
+ def default_test_folder
38
+ 'features'
39
+ end
40
+
37
41
  def test_suffix
38
42
  /\.feature$/
39
43
  end
@@ -26,6 +26,10 @@ module ParallelTests
26
26
  "tmp/parallel_runtime_rspec.log"
27
27
  end
28
28
 
29
+ def default_test_folder
30
+ "spec"
31
+ end
32
+
29
33
  def test_file_name
30
34
  "spec"
31
35
  end
@@ -9,6 +9,10 @@ module ParallelTests
9
9
  'spinach'
10
10
  end
11
11
 
12
+ def default_test_folder
13
+ 'features'
14
+ end
15
+
12
16
  def runtime_logging
13
17
  # Not Yet Supported
14
18
  ""
@@ -123,12 +123,14 @@ namespace :parallel do
123
123
  ParallelTests::Tasks.check_for_pending_migrations
124
124
  if defined?(ActiveRecord::Base) && [:ruby, :sql].include?(ActiveRecord::Base.schema_format)
125
125
  # fast: dump once, load in parallel
126
- if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
127
- Rake::Task["db:schema:dump"].invoke
128
- else
129
- type = (ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure")
130
- Rake::Task["db:#{type}:dump"].invoke
131
- end
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
132
+
133
+ Rake::Task["db:#{type}:dump"].invoke
132
134
 
133
135
  # remove database connection to prevent "database is being accessed by other users"
134
136
  ActiveRecord::Base.remove_connection if ActiveRecord::Base.configurations.any?
@@ -15,6 +15,10 @@ module ParallelTests
15
15
  /_(test|spec).rb$/
16
16
  end
17
17
 
18
+ def default_test_folder
19
+ "test"
20
+ end
21
+
18
22
  def test_file_name
19
23
  "test"
20
24
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ParallelTests
3
- VERSION = '3.5.1'
3
+ VERSION = '3.7.1'
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.5.1
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-07 00:00:00.000000000 Z
11
+ date: 2021-08-13 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.5.1/Readme.md
72
- source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.5.1
71
+ documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.7.1/Readme.md
72
+ source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.7.1
73
73
  wiki_uri: https://github.com/grosser/parallel_tests/wiki
74
74
  post_install_message:
75
75
  rdoc_options: []
@@ -79,14 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.4.0
82
+ version: 2.5.0
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.1.3
89
+ rubygems_version: 3.2.16
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Run Test::Unit / RSpec / Cucumber / Spinach in parallel