parallel_tests 1.3.7 → 3.7.3

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
- SHA1:
3
- metadata.gz: 1646c6d92a16b6c2f141d2cfd20af1dcdf491141
4
- data.tar.gz: 2265ae4f1843166e30f11b7b4855b6dea98a58bf
2
+ SHA256:
3
+ metadata.gz: 042cf590688332180e07fcf6472cc9b88b740276df0511677cf77f7fe649fa2e
4
+ data.tar.gz: cb4fd166b030e16574bf5d4790e5d1e0a3d57001d5474ab81c3d54613af976e2
5
5
  SHA512:
6
- metadata.gz: d303d05c5dd6a5ad7985b18aca984c07cb501f4c07b5b0ca75fd944cbf8cd20ca89535a90d4ef1b0e6259fadcb206ea0325a8dcec5b830cf71569f6ae218d419
7
- data.tar.gz: 516172942dd242cc622c4ac013fe7a74091c05c588b1d20b81282aadfe65153008dcf59e367d465d711ea049efb84978194c7f36a4e51ca473e9f104980e797f
6
+ metadata.gz: 98e679733a74273ac77e71db47bc3af3f0f5a928dab351be9419644a0e7fe2bc004a81c929928ef0bd98ea2b8e5b63d1ab9fadcf75e22d098a65c5164343fe0b
7
+ data.tar.gz: 2ce2dd070733cd0bb61d0cb610f886a5590d5e267cc43613ab7d08fc251d989ebd4a58ad2f0a9c88478499fe55ff4cb7386fabc2eba8ee7fb3440d4899594654
data/Readme.md CHANGED
@@ -1,3 +1,9 @@
1
+ # parallel_tests
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/parallel_tests.svg)](https://rubygems.org/gems/parallel_tests)
4
+ [![Build Status](https://travis-ci.org/grosser/parallel_tests.svg)](https://travis-ci.org/grosser/parallel_tests/builds)
5
+ [![Build status](https://github.com/grosser/parallel_tests/workflows/windows/badge.svg)](https://github.com/grosser/parallel_tests/actions?query=workflow%3Awindows)
6
+
1
7
  Speedup Test::Unit + RSpec + Cucumber + Spinach by running parallel on multiple CPU cores.<br/>
2
8
  ParallelTests splits tests into even groups (by number of lines or runtime) and runs each group in a single process with its own database.
3
9
 
@@ -6,10 +12,10 @@ Setup for Rails
6
12
  [RailsCasts episode #413 Fast Tests](http://railscasts.com/episodes/413-fast-tests)
7
13
 
8
14
  ### Install
15
+ `Gemfile`:
9
16
 
10
17
  ```ruby
11
- # Gemfile
12
- gem "parallel_tests", :group => :development
18
+ gem 'parallel_tests', group: [:development, :test]
13
19
  ```
14
20
 
15
21
  ### Add to `config/database.yml`
@@ -17,7 +23,7 @@ gem "parallel_tests", :group => :development
17
23
  ParallelTests uses 1 database per test-process.
18
24
  <table>
19
25
  <tr><td>Process number</td><td>1</td><td>2</td><td>3</td></tr>
20
- <tr><td>`ENV['TEST_ENV_NUMBER']`</td><td>''</td><td>'2'</td><td>'3'</td></tr>
26
+ <tr><td>ENV['TEST_ENV_NUMBER']</td><td>''</td><td>'2'</td><td>'3'</td></tr>
21
27
  </table>
22
28
 
23
29
  ```yaml
@@ -31,6 +37,15 @@ test:
31
37
  ### Copy development schema (repeat after migrations)
32
38
  rake parallel:prepare
33
39
 
40
+ ### Run migrations in additional database(s) (repeat after migrations)
41
+ rake parallel:migrate
42
+
43
+ ### Setup environment from scratch (create db and loads schema, useful for CI)
44
+ rake parallel:setup
45
+
46
+ ### Drop all test databases
47
+ rake parallel:drop
48
+
34
49
  ### Run!
35
50
  rake parallel:test # Test::Unit
36
51
  rake parallel:spec # RSpec
@@ -42,11 +57,12 @@ test:
42
57
  rake parallel:test --> got 4 CPUs? --> 26 seconds
43
58
  ...
44
59
 
45
- Test by pattern (e.g. use one integration server per subfolder / see if you broke any 'user'-related tests)
60
+ Test by pattern with Regex (e.g. use one integration server per subfolder / see if you broke any 'user'-related tests)
46
61
 
47
62
  rake parallel:test[^test/unit] # every test file in test/unit folder
48
63
  rake parallel:test[user] # run users_controller + user_helper + user tests
49
64
  rake parallel:test['user|product'] # run user and product related tests
65
+ rake parallel:spec['spec\/(?!features)'] # run RSpec tests except the tests in spec/features
50
66
 
51
67
 
52
68
  ### Example output
@@ -63,6 +79,8 @@ Test by pattern (e.g. use one integration server per subfolder / see if you brok
63
79
  RAILS_ENV=test parallel_test -e "rake my:custom:task"
64
80
  # or
65
81
  rake parallel:rake[my:custom:task]
82
+ # limited parallelism
83
+ rake parallel:rake[my:custom:task,2]
66
84
  ```
67
85
 
68
86
 
@@ -70,10 +88,17 @@ Running things once
70
88
  ===================
71
89
 
72
90
  ```Ruby
73
- # effected by race-condition: first process may boot slower the second
91
+ require "parallel_tests"
92
+
93
+ # preparation:
94
+ # affected by race-condition: first process may boot slower than the second
74
95
  # either sleep a bit or use a lock for example File.lock
75
96
  ParallelTests.first_process? ? do_something : sleep(1)
76
97
 
98
+ # cleanup:
99
+ # last_process? does NOT mean last finished process, just last started
100
+ ParallelTests.last_process? ? do_something : sleep(1)
101
+
77
102
  at_exit do
78
103
  if ParallelTests.first_process?
79
104
  ParallelTests.wait_for_other_processes_to_finish
@@ -82,24 +107,22 @@ at_exit do
82
107
  end
83
108
  ```
84
109
 
85
- Loggers
86
- ===================
87
-
88
110
  Even test group run-times
89
- -------------------------
111
+ =========================
90
112
 
91
- ### RSpec
113
+ Test groups are often not balanced and will run for different times, making everything wait for the slowest group.
114
+ Use these loggers to record test runtime and then use the recorded runtime to balance test groups more evenly.
92
115
 
93
- Add the `RuntimeLogger` to log how long each test takes to run.
94
- This log file will be loaded on the next test run, and the tests will be grouped
95
- so that each process should finish around the same time.
116
+ ### RSpec
96
117
 
97
118
  Rspec: Add to your `.rspec_parallel` (or `.rspec`) :
98
119
 
99
120
  --format progress
100
121
  --format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
101
122
 
102
- ### Test::Unit & Minitest 4/5
123
+ To use a custom logfile location (default: `tmp/parallel_runtime_rspec.log`), use the CLI: `parallel_test spec -t rspec --runtime-log my.log`
124
+
125
+ ### Minitest
103
126
 
104
127
  Add to your `test_helper.rb`:
105
128
  ```ruby
@@ -109,6 +132,9 @@ require 'parallel_tests/test/runtime_logger' if ENV['RECORD_RUNTIME']
109
132
  results will be logged to tmp/parallel_runtime_test.log when `RECORD_RUNTIME` is set,
110
133
  so it is not always required or overwritten.
111
134
 
135
+ Loggers
136
+ =======
137
+
112
138
  RSpec: SummaryLogger
113
139
  --------------------
114
140
 
@@ -122,17 +148,19 @@ Add the following to your `.rspec_parallel` (or `.rspec`) :
122
148
  RSpec: FailuresLogger
123
149
  -----------------------
124
150
 
125
- Produce pasteable command-line snippets for each failed example.
151
+ Produce pastable command-line snippets for each failed example. For example:
126
152
 
127
- E.g.
128
-
129
- rspec /path/to/my_spec.rb:123 # should do something
153
+ ```bash
154
+ rspec /path/to/my_spec.rb:123 # should do something
155
+ ```
130
156
 
131
- Add the following to your `.rspec_parallel` (or `.rspec`) :
157
+ Add to `.rspec_parallel` or use as CLI flag:
132
158
 
133
159
  --format progress
134
160
  --format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log
135
161
 
162
+ (Not needed to retry failures, for that pass [--only-failures](https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures) to rspec)
163
+
136
164
  Cucumber: FailuresLogger
137
165
  -----------------------
138
166
 
@@ -157,46 +185,78 @@ Setup for non-rails
157
185
 
158
186
  gem install parallel_tests
159
187
  # go to your project dir
160
- parallel_test test/
161
- parallel_rspec spec/
162
- parallel_cucumber features/
163
- parallel_spinach features/
188
+ parallel_test
189
+ parallel_rspec
190
+ parallel_cucumber
191
+ parallel_spinach
164
192
 
165
- - use ENV['TEST_ENV_NUMBER'] inside your tests to select separate db/memcache/etc.
166
- - Only run selected files & folders:
193
+ - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc. (docker compose: expose it)
167
194
 
168
- parallel_test test/bar test/baz/foo_text.rb
195
+ - Only run a subset of files / folders:
196
+
197
+ `parallel_test test/bar test/baz/foo_text.rb`
169
198
 
170
- Options are:
199
+ - Pass test-options and files via `--`:
200
+
201
+ `parallel_rspec -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
202
+
203
+ - Pass in test options, by using the -o flag (wrap everything in quotes):
204
+
205
+ `parallel_cucumber -n 2 -o '-p foo_profile --tags @only_this_tag or @only_that_tag --format summary'`
171
206
 
207
+ Options are:
208
+ <!-- copy output from bundle exec ./bin/parallel_test -h -->
172
209
  -n [PROCESSES] How many processes to use, default: available CPUs
173
- -p, --pattern [PATTERN] run tests matching this pattern
210
+ -p, --pattern [PATTERN] run tests matching this regex pattern
211
+ --exclude-pattern [PATTERN] exclude tests matching this regex pattern
174
212
  --group-by [TYPE] group tests by:
175
- found - order of finding files
176
- steps - number of cucumber/spinach steps
177
- scenarios - individual cucumber scenarios
178
- filesize - by size of the file
179
- runtime - info from runtime log
180
- default - runtime when runtime log is filled otherwise filesize
213
+ found - order of finding files
214
+ steps - number of cucumber/spinach steps
215
+ scenarios - individual cucumber scenarios
216
+ filesize - by size of the file
217
+ runtime - info from runtime log
218
+ default - runtime when runtime log is filled otherwise filesize
181
219
  -m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
182
220
  -s, --single [PATTERN] Run all matching files in the same process
183
221
  -i, --isolate Do not run any other tests in the group used by --single(-s)
184
- --only-group INT[, INT]
185
- -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUM']
222
+ --isolate-n [PROCESSES] Use 'isolate' singles with number of processes, default: 1.
223
+ --highest-exit-status Exit with the highest exit status provided by test run(s)
224
+ --specify-groups [SPECS] Use 'specify-groups' if you want to specify multiple specs running in multiple
225
+ processes in a specific formation. Commas indicate specs in the same process,
226
+ pipes indicate specs in a new process. Cannot use with --single, --isolate, or
227
+ --isolate-n. Ex.
228
+ $ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
229
+ Process 1 will contain 1_spec.rb and 2_spec.rb
230
+ Process 2 will contain 3_spec.rb
231
+ Process 3 will contain all other specs
232
+ --only-group INT[,INT]
233
+ -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUMBER']
186
234
  -o, --test-options '[OPTIONS]' execute test commands with those options
187
235
  -t, --type [TYPE] test(default) / rspec / cucumber / spinach
236
+ --suffix [PATTERN] override built in test file pattern (should match suffix):
237
+ '_spec.rb$' - matches rspec files
238
+ '_(test|spec).rb$' - matches test or spec files
188
239
  --serialize-stdout Serialize stdout output, nothing will be written until everything is done
240
+ --prefix-output-with-test-env-number
241
+ Prefixes test env number to the output when not using --serialize-stdout
189
242
  --combine-stderr Combine stderr into stdout, useful in conjunction with --serialize-stdout
190
243
  --non-parallel execute same commands but do not in parallel, needs --exec
191
244
  --no-symlinks Do not traverse symbolic links to find test files
192
245
  --ignore-tags [PATTERN] When counting steps ignore scenarios with tags that match this pattern
193
246
  --nice execute test commands with low priority.
194
247
  --runtime-log [PATH] Location of previously recorded test runtimes
195
- --verbose Print more output
248
+ --allowed-missing [INT] Allowed percentage of missing runtimes (default = 50)
249
+ --unknown-runtime [FLOAT] Use given number as unknown runtime (otherwise use average time)
250
+ --first-is-1 Use "1" as TEST_ENV_NUMBER to not reuse the default test environment
251
+ --fail-fast Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported
252
+ --verbose Print debug output
253
+ --verbose-process-command Displays only the command that will be executed by each process
254
+ --verbose-rerun-command When there are failures, displays the command executed by each process that failed
255
+ --quiet Print only tests output
196
256
  -v, --version Show Version
197
257
  -h, --help Show this.
198
258
 
199
- You can run any kind of code in parallel with -e / --execute
259
+ You can run any kind of code in parallel with -e / --exec
200
260
 
201
261
  parallel_test -n 5 -e 'ruby -e "puts %[hello from process #{ENV[:TEST_ENV_NUMBER.to_s].inspect}]"'
202
262
  hello from process "2"
@@ -213,34 +273,46 @@ You can run any kind of code in parallel with -e / --execute
213
273
 
214
274
  TIPS
215
275
  ====
216
- - [RSpec] add a `.rspec_parallel` to use different options, e.g. **no --drb**
217
- - Spring does not work with parallel_tests, use `DISABLE_SPRING=1 rake parallel:spec` if you have spring hardcoded in your binaries
218
- - [RSpec] remove `--loadby` from `.rspec`
219
- - [RSpec] Instantly see failures (instead of just a red F) with [rspec-instafail](https://github.com/grosser/rspec-instafail)
220
- - [Cucumber] add a `parallel: foo` profile to your `config/cucumber.yml` and it will be used to run parallel tests
221
- - [Capybara setup](https://github.com/grosser/parallel_tests/wiki)
222
- - [Sphinx setup](https://github.com/grosser/parallel_tests/wiki)
223
- - [Capistrano setup](https://github.com/grosser/parallel_tests/wiki/Remotely-with-capistrano) let your tests run on a big box instead of your laptop
224
- - [SQL schema format] use :ruby schema format to get faster parallel:prepare`
225
- - `export PARALLEL_TEST_PROCESSORS=X` in your environment and parallel_tests will use this number of processors by default
276
+
277
+ ### RSpec
278
+
279
+ - Add a `.rspec_parallel` to use different options, e.g. **no --drb**
280
+ - Remove `--loadby` from `.rspec`
281
+ - Instantly see failures (instead of just a red F) with [rspec-instafail](https://github.com/grosser/rspec-instafail)
282
+ - Use [rspec-retry](https://github.com/NoRedInk/rspec-retry) (not rspec-rerun) to rerun failed tests.
283
+ - [JUnit formatter configuration](https://github.com/grosser/parallel_tests/wiki#with-rspec_junit_formatter----by-jgarber)
284
+ - Use [parallel_split_test](https://github.com/grosser/parallel_split_test) to run multiple scenarios in a single spec file, concurrently. (`parallel_tests` [works at the file-level and intends to stay that way](https://github.com/grosser/parallel_tests/issues/747#issuecomment-580216980))
285
+
286
+ ### Cucumber
287
+
288
+ - Add a `parallel: foo` profile to your `config/cucumber.yml` and it will be used to run parallel tests
289
+ - [ReportBuilder](https://github.com/rajatthareja/ReportBuilder) can help with combining parallel test results
290
+ - Supports Cucumber 2.0+ and is actively maintained
291
+ - Combines many JSON files into a single file
292
+ - Builds a HTML report from JSON with support for debug msgs & embedded Base64 images.
293
+
294
+ ### General
226
295
  - [ZSH] use quotes to use rake arguments `rake "parallel:prepare[3]"`
296
+ - [Memcached] use different namespaces<br/>
297
+ e.g. `config.cache_store = ..., namespace: "test_#{ENV['TEST_ENV_NUMBER']}"`
298
+ - Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
299
+ - `export PARALLEL_TEST_PROCESSORS=13` to override default processor count
300
+ - Shell alias: `alias prspec='parallel_rspec -m 2 --'`
301
+ - [Spring] Add the [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) gem to your `Gemfile` to get `parallel_tests` working with Spring.
302
+ - `--first-is-1` will make the first environment be `1`, so you can test while running your full suite.<br/>
303
+ `export PARALLEL_TEST_FIRST_IS_1=true` will provide the same result
227
304
  - [email_spec and/or action_mailer_cache_delivery](https://github.com/grosser/parallel_tests/wiki)
228
- - [Memcached] use different namespaces e.g. `config.cache_store = ..., namespace: "test_#{ENV['TEST_ENV_NUMBER']}"`
229
305
  - [zeus-parallel_tests](https://github.com/sevos/zeus-parallel_tests)
230
- - [Distributed parallel test (e.g. Travis Support)](https://github.com/grosser/parallel_tests/wiki/Distributed-Parallel-Tests-and-Travis-Support)
231
- - Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
232
- - Contribute your own gotaches to the [Wiki](https://github.com/grosser/parallel_tests/wiki) or even better open a PR :)
306
+ - [Distributed Parallel Tests on CI systems)](https://github.com/grosser/parallel_tests/wiki/Distributed-Parallel-Tests-on-CI-systems) learn how `parallel_tests` can run on distributed servers such as Travis and GitLab-CI. Also shows you how to use parallel_tests without adding `TEST_ENV_NUMBER`-backends
307
+ - [Capybara setup](https://github.com/grosser/parallel_tests/wiki)
308
+ - [Sphinx setup](https://github.com/grosser/parallel_tests/wiki)
309
+ - [Capistrano setup](https://github.com/grosser/parallel_tests/wiki/Remotely-with-capistrano) let your tests run on a big box instead of your laptop
233
310
 
234
- TODO
235
- ====
236
- - fix tests vs cucumber >= 1.2 `unknown option --format`
237
- - add integration tests for the rake tasks, maybe generate a rails project ...
238
- - add unit tests for cucumber runtime formatter
239
- - make windows compatible
311
+ Contribute your own gotchas to the [Wiki](https://github.com/grosser/parallel_tests/wiki) or even better open a PR :)
240
312
 
241
313
  Authors
242
314
  ====
243
- inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-parallelize-your-rspec-suite)
315
+ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rspec-suite)
244
316
 
245
317
  ### [Contributors](https://github.com/grosser/parallel_tests/contributors)
246
318
  - [Charles Finkel](http://charlesfinkel.com/)
@@ -309,8 +381,28 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
309
381
  - [Mike Mueller](https://github.com/mmueller)
310
382
  - [Aaron Jensen](https://github.com/aaronjensen)
311
383
  - [Ed Slocomb](https://github.com/edslocomb)
384
+ - [Cezary Baginski](https://github.com/e2)
385
+ - [Marius Ioana](https://github.com/mariusioana)
386
+ - [Lukas Oberhuber](https://github.com/lukaso)
387
+ - [Ryan Zhang](https://github.com/ryanus)
388
+ - [Rhett Sutphin](https://github.com/rsutphin)
389
+ - [Doc Ritezel](https://github.com/ohrite)
390
+ - [Alexandre Wilhelm](https://github.com/dogild)
391
+ - [Jerry](https://github.com/boblington)
392
+ - [Aleksei Gusev](https://github.com/hron)
393
+ - [Scott Olsen](https://github.com/scottolsen)
394
+ - [Andrei Botalov](https://github.com/abotalov)
395
+ - [Zachary Attas](https://github.com/snackattas)
396
+ - [David Rodríguez](https://github.com/deivid-rodriguez)
397
+ - [Justin Doody](https://github.com/justindoody)
398
+ - [Sandeep Singh](https://github.com/sandeepnagra)
399
+ - [Calaway](https://github.com/calaway)
400
+ - [alboyadjian](https://github.com/alboyadjian)
401
+ - [Nathan Broadbent](https://github.com/ndbroadbent)
402
+ - [Vikram B Kumar](https://github.com/v-kumar)
403
+ - [Joshua Pinter](https://github.com/joshuapinter)
404
+ - [Zach Dennis](https://github.com/zdennis)
312
405
 
313
406
  [Michael Grosser](http://grosser.it)<br/>
314
407
  michael@grosser.it<br/>
315
- License: MIT<br/>
316
- [![Build Status](https://travis-ci.org/grosser/parallel_tests.png)](https://travis-ci.org/grosser/parallel_tests)
408
+ License: MIT
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # enable local usage from cloned repo
4
- root = File.expand_path("../..", __FILE__)
5
+ root = File.expand_path('..', __dir__)
5
6
  $LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
6
7
 
7
8
  require "parallel_tests"
data/bin/parallel_rspec CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # enable local usage from cloned repo
4
- root = File.expand_path("../..", __FILE__)
5
+ root = File.expand_path('..', __dir__)
5
6
  $LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
6
7
 
7
8
  require "parallel_tests"
data/bin/parallel_spinach CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # enable local usage from cloned repo
4
- root = File.expand_path("../..", __FILE__)
5
+ root = File.expand_path('..', __dir__)
5
6
  $LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
6
7
 
7
8
  require "parallel_tests"
data/bin/parallel_test CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # enable local usage from cloned repo
4
- root = File.expand_path("../..", __FILE__)
5
+ root = File.expand_path('..', __dir__)
5
6
  $LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
6
7
 
7
8
  require "parallel_tests"