parallel_tests 4.2.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +34 -10
- data/lib/parallel_tests/cli.rb +9 -2
- data/lib/parallel_tests/rspec/failures_logger.rb +5 -13
- data/lib/parallel_tests/rspec/logger_base.rb +0 -2
- data/lib/parallel_tests/rspec/runner.rb +3 -1
- data/lib/parallel_tests/rspec/runtime_logger.rb +5 -4
- data/lib/parallel_tests/rspec/summary_logger.rb +1 -1
- data/lib/parallel_tests/rspec/verbose_logger.rb +62 -0
- data/lib/parallel_tests/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf9a4f09819ff1193b0f02d9148f72d7b12e4c2efc2ca4e5e7981eb6959ebfef
|
4
|
+
data.tar.gz: f86bdeb95cb93b8d8d79a81727e719014a481c18520da973480ff44d6828ffdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 549401be10742522594fbd9f9ba1eb657c7689c13be3f9034bb7ee78225a7b86cf127b83d1f16cac932b639cfec92ecac9644e8aff9aa488b39e3980eb23ff6c
|
7
|
+
data.tar.gz: ad909f442e744a869bc4db59b9bf2bc9b3559e888f2d017cee58fa51b4d8563f5dc9123d6ce48317fe65f56e7d6f4f4d89c56274960d14ec1befbe5e3cabcc2d
|
data/Readme.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/parallel_tests.svg)](https://rubygems.org/gems/parallel_tests)
|
4
4
|
[![Build status](https://github.com/grosser/parallel_tests/workflows/test/badge.svg)](https://github.com/grosser/parallel_tests/actions?query=workflow%3Atest)
|
5
5
|
|
6
|
-
Speedup
|
7
|
-
ParallelTests splits tests into
|
6
|
+
Speedup Minitest + RSpec + Turnip + Cucumber + Spinach by running parallel on multiple CPU cores.<br/>
|
7
|
+
ParallelTests splits tests into balanced groups (by number of lines or runtime) and runs each group in a process with its own database.
|
8
8
|
|
9
9
|
Setup for Rails
|
10
10
|
===============
|
@@ -46,7 +46,7 @@ test:
|
|
46
46
|
rake parallel:drop
|
47
47
|
|
48
48
|
### Run!
|
49
|
-
rake parallel:test #
|
49
|
+
rake parallel:test # Minitest
|
50
50
|
rake parallel:spec # RSpec
|
51
51
|
rake parallel:features # Cucumber
|
52
52
|
rake parallel:features-spinach # Spinach
|
@@ -106,11 +106,13 @@ at_exit do
|
|
106
106
|
end
|
107
107
|
```
|
108
108
|
|
109
|
-
Even test group
|
110
|
-
|
109
|
+
Even test group runtimes
|
110
|
+
========================
|
111
111
|
|
112
|
-
Test groups
|
113
|
-
|
112
|
+
Test groups will often run for different times, making the full test run as slow as the slowest group.
|
113
|
+
|
114
|
+
Step 1: Use these loggers (see below) to record test runtime
|
115
|
+
Step 2: Your next run will use the recorded test runtimes (use `--runtime-log <file>` if you picked a location different from below)
|
114
116
|
|
115
117
|
### RSpec
|
116
118
|
|
@@ -128,9 +130,11 @@ Add to your `test_helper.rb`:
|
|
128
130
|
require 'parallel_tests/test/runtime_logger' if ENV['RECORD_RUNTIME']
|
129
131
|
```
|
130
132
|
|
131
|
-
results will be logged to tmp/parallel_runtime_test.log when `RECORD_RUNTIME` is set,
|
133
|
+
results will be logged to `tmp/parallel_runtime_test.log` when `RECORD_RUNTIME` is set,
|
132
134
|
so it is not always required or overwritten.
|
133
135
|
|
136
|
+
### TODO: add instructions for other frameworks
|
137
|
+
|
134
138
|
Loggers
|
135
139
|
=======
|
136
140
|
|
@@ -147,7 +151,7 @@ Add the following to your `.rspec_parallel` (or `.rspec`) :
|
|
147
151
|
RSpec: FailuresLogger
|
148
152
|
-----------------------
|
149
153
|
|
150
|
-
Produce
|
154
|
+
Produce pasteable command-line snippets for each failed example. For example:
|
151
155
|
|
152
156
|
```bash
|
153
157
|
rspec /path/to/my_spec.rb:123 # should do something
|
@@ -160,6 +164,24 @@ Add to `.rspec_parallel` or use as CLI flag:
|
|
160
164
|
|
161
165
|
(Not needed to retry failures, for that pass [--only-failures](https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures) to rspec)
|
162
166
|
|
167
|
+
|
168
|
+
RSpec: VerboseLogger
|
169
|
+
-----------------------
|
170
|
+
|
171
|
+
Prints a single line for starting and finishing each example, to see what is currently running in each process.
|
172
|
+
|
173
|
+
```
|
174
|
+
# PID, parallel process number, spec status, example description
|
175
|
+
[14403] [2] [STARTED] Foo foo
|
176
|
+
[14402] [1] [STARTED] Bar bar
|
177
|
+
[14402] [1] [PASSED] Bar bar
|
178
|
+
```
|
179
|
+
|
180
|
+
Add to `.rspec_parallel` or use as CLI flag:
|
181
|
+
|
182
|
+
--format ParallelTests::RSpec::VerboseLogger
|
183
|
+
|
184
|
+
|
163
185
|
Cucumber: FailuresLogger
|
164
186
|
-----------------------
|
165
187
|
|
@@ -228,7 +250,9 @@ Options are:
|
|
228
250
|
Process 1 will contain 1_spec.rb and 2_spec.rb
|
229
251
|
Process 2 will contain 3_spec.rb
|
230
252
|
Process 3 will contain all other specs
|
231
|
-
--only-group INT[,INT]
|
253
|
+
--only-group INT[,INT] Only run the given group numbers. Note that this will force the 'filesize'
|
254
|
+
grouping strategy (even when the runtime log is present) unless you explicitly
|
255
|
+
set it otherwise via the '-group-by' flag.
|
232
256
|
-e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUMBER']
|
233
257
|
-o, --test-options '[OPTIONS]' execute test commands with those options
|
234
258
|
-t, --type [TYPE] test(default) / rspec / cucumber / spinach
|
data/lib/parallel_tests/cli.rb
CHANGED
@@ -244,7 +244,14 @@ module ParallelTests
|
|
244
244
|
TEXT
|
245
245
|
) { |groups| options[:specify_groups] = groups }
|
246
246
|
|
247
|
-
opts.on(
|
247
|
+
opts.on(
|
248
|
+
"--only-group INT[,INT]",
|
249
|
+
Array,
|
250
|
+
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
|
251
|
+
Only run the given group numbers.
|
252
|
+
Changes `--group-by` default to 'filesize'.
|
253
|
+
TEXT
|
254
|
+
) { |groups| options[:only_group] = groups.map(&:to_i) }
|
248
255
|
|
249
256
|
opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
|
250
257
|
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = Shellwords.shellsplit(arg) }
|
@@ -258,7 +265,7 @@ module ParallelTests
|
|
258
265
|
"--suffix [PATTERN]",
|
259
266
|
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
|
260
267
|
override built in test file pattern (should match suffix):
|
261
|
-
'_spec
|
268
|
+
'_spec.rb$' - matches rspec files
|
262
269
|
'_(test|spec).rb$' - matches test or spec files
|
263
270
|
TEXT
|
264
271
|
) { |pattern| options[:suffix] = /#{pattern}/ }
|
@@ -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
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
notification
|
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
|
@@ -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
|
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
|
-
|
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
|
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
|
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
|
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: 4.
|
4
|
+
version: 4.4.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: 2023-
|
11
|
+
date: 2023-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/parallel_tests/rspec/runner.rb
|
59
59
|
- lib/parallel_tests/rspec/runtime_logger.rb
|
60
60
|
- lib/parallel_tests/rspec/summary_logger.rb
|
61
|
+
- lib/parallel_tests/rspec/verbose_logger.rb
|
61
62
|
- lib/parallel_tests/spinach/runner.rb
|
62
63
|
- lib/parallel_tests/tasks.rb
|
63
64
|
- lib/parallel_tests/test/runner.rb
|
@@ -68,8 +69,8 @@ licenses:
|
|
68
69
|
- MIT
|
69
70
|
metadata:
|
70
71
|
bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
|
71
|
-
documentation_uri: https://github.com/grosser/parallel_tests/blob/v4.
|
72
|
-
source_code_uri: https://github.com/grosser/parallel_tests/tree/v4.
|
72
|
+
documentation_uri: https://github.com/grosser/parallel_tests/blob/v4.4.0/Readme.md
|
73
|
+
source_code_uri: https://github.com/grosser/parallel_tests/tree/v4.4.0
|
73
74
|
wiki_uri: https://github.com/grosser/parallel_tests/wiki
|
74
75
|
post_install_message:
|
75
76
|
rdoc_options: []
|