rspec-multiprocess_runner 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +38 -4
- data/exe/multirspec +1 -0
- data/lib/rspec/multiprocess_runner/command_line_options.rb +24 -2
- data/lib/rspec/multiprocess_runner/coordinator.rb +3 -1
- data/lib/rspec/multiprocess_runner/rake_task.rb +6 -0
- data/lib/rspec/multiprocess_runner/version.rb +1 -1
- data/lib/rspec/multiprocess_runner/worker.rb +10 -1
- data/rspec-multiprocess_runner.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 520007bffb4a964152f9126341c18e31ddfacf1e
|
4
|
+
data.tar.gz: 3cb996f53ea6a3d9b1e34f7c6d55847f9db3c9a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363f45289a698a62ee9789c7429e6821239f58047d920b753531e306d847eac2806477a968b49fd6c06bc2aa5ec481a73036fb7d298859d63a005beba0dd1348
|
7
|
+
data.tar.gz: 8e5e26062ce94dfbbd635f5a1bfbe7fcf936fdc526d6d3786dc2753aef6c3423dc758a436daffb9db80a5e0971c82b58a73bdfdd4e821d0ccf8e2aa887691e03
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 0.4.0
|
2
|
+
|
3
|
+
* Change TEST_ENV_NUMBER values to match parallel_tests (#10)
|
4
|
+
* Allow for environment-variable-based defaults for worker count and first-is-1
|
5
|
+
in `multirspec` (like #10, improving compatibility with parallel_tests)
|
6
|
+
|
1
7
|
# 0.3.0
|
2
8
|
|
3
9
|
* Require a filename for the `--log-failing-files` option (#9)
|
data/README.md
CHANGED
@@ -4,13 +4,14 @@ This gem provides a mechanism for running a suite of RSpec tests in multiple
|
|
4
4
|
processes on the same machine, potentially allowing substantial performance
|
5
5
|
improvements.
|
6
6
|
|
7
|
-
It differs from `
|
7
|
+
It differs from `parallel_tests` in that it uses a coordinator process to manage
|
8
8
|
the workers, hand off work to them, and receive results. This means it can
|
9
9
|
dynamically balance the workload among the processors. It also means it can
|
10
10
|
provide consolidated results in the console.
|
11
11
|
|
12
|
-
It
|
13
|
-
|
12
|
+
It follows parallel_tests' environment variable conventions so it's easy to
|
13
|
+
use them together. (E.g., parallel_tests has a very nice set of rake tasks
|
14
|
+
for setting up parallel environments.)
|
14
15
|
|
15
16
|
## Benefits
|
16
17
|
|
@@ -35,7 +36,6 @@ switch.
|
|
35
36
|
* Intermediate-quality code. Happy path works, and workers are
|
36
37
|
managed/restarted, but:
|
37
38
|
* There's no test coverage of the runner itself, only auxiliaries.
|
38
|
-
* Does not handle the coordinator process dying (e.g., from `^C`).
|
39
39
|
|
40
40
|
## Installation
|
41
41
|
|
@@ -107,6 +107,40 @@ Create a coordinator and tell it to run:
|
|
107
107
|
)
|
108
108
|
coordinator.run
|
109
109
|
|
110
|
+
… but you are probably better off using the command line interface.
|
111
|
+
|
112
|
+
## Runtime environment
|
113
|
+
|
114
|
+
### `TEST_ENV_NUMBER`
|
115
|
+
|
116
|
+
This runner provides each worker with a environment number so that you can
|
117
|
+
segment access to resources (databases, etc). For convenience, it follows the
|
118
|
+
same convention as `parallel_tests`.
|
119
|
+
|
120
|
+
* The environment number is provided as an environment variable named `TEST_ENV_NUMBER`
|
121
|
+
* The first environment number is `""` and subsequent ones are integers (`"2"`, `"3"`, etc.)
|
122
|
+
|
123
|
+
Like `parallel_tests` 2.3 and later, `multirspec` supports a `--first-is-1`
|
124
|
+
argument which makes the first environment number `"1"` instead. Use this to
|
125
|
+
have your multiprocess runs be isolated from the environment used in tests you
|
126
|
+
run normally, allowing you to to TDD while a long-running multiprocess run
|
127
|
+
continues in the background.
|
128
|
+
|
129
|
+
### Behavior options
|
130
|
+
|
131
|
+
All options are available via the `multirspec` command line interface. A couple
|
132
|
+
may alternatively be set in the calling environment.
|
133
|
+
|
134
|
+
* Worker count: instead of providing `-w 5`, set `PARALLEL_TEST_PROCESSORS="5"` or
|
135
|
+
`MULTIRSPEC_WORKER_COUNT="5"` in the environment. If both `-w` and one of these
|
136
|
+
vars is set, the value passed to `-w` will win.
|
137
|
+
* First-is-1: instead of providing `--first-is-1`, set
|
138
|
+
`PARALLEL_TEST_FIRST_IS_1="true"` or `MULTIRSPEC_FIRST_IS_1="true"` in the
|
139
|
+
environment.
|
140
|
+
|
141
|
+
These environment variables only apply to the CLI and rake task. If you
|
142
|
+
directly invoke `RSpec::MultiprocessRunner::Coordinator#run`, they are ignored.
|
143
|
+
|
110
144
|
## Contributing
|
111
145
|
|
112
146
|
Bug reports and pull requests are welcome on GitHub at https://github.com/cdd/rspec-multiprocess_runner.
|
data/exe/multirspec
CHANGED
@@ -12,6 +12,7 @@ coordinator = RSpec::MultiprocessRunner::Coordinator.new(
|
|
12
12
|
{
|
13
13
|
file_timeout_seconds: options.file_timeout_seconds,
|
14
14
|
example_timeout_seconds: options.example_timeout_seconds,
|
15
|
+
test_env_number_first_is_1: options.first_is_1,
|
15
16
|
rspec_options: options.rspec_options,
|
16
17
|
log_failing_files: options.log_failing_files
|
17
18
|
}
|
@@ -6,15 +6,19 @@ module RSpec::MultiprocessRunner
|
|
6
6
|
# @private
|
7
7
|
class CommandLineOptions
|
8
8
|
attr_accessor :worker_count, :file_timeout_seconds, :example_timeout_seconds,
|
9
|
-
:rspec_options, :explicit_files_or_directories, :pattern, :log_failing_files
|
9
|
+
:rspec_options, :explicit_files_or_directories, :pattern, :log_failing_files,
|
10
|
+
:first_is_1
|
11
|
+
|
12
|
+
DEFAULT_WORKER_COUNT = 3
|
10
13
|
|
11
14
|
def initialize
|
12
|
-
self.worker_count =
|
15
|
+
self.worker_count = default_worker_count
|
13
16
|
self.file_timeout_seconds = nil
|
14
17
|
self.example_timeout_seconds = 15
|
15
18
|
self.pattern = "**/*_spec.rb"
|
16
19
|
self.log_failing_files = nil
|
17
20
|
self.rspec_options = []
|
21
|
+
self.first_is_1 = default_first_is_1
|
18
22
|
end
|
19
23
|
|
20
24
|
def parse(command_line_args, error_stream=$stderr)
|
@@ -52,6 +56,20 @@ module RSpec::MultiprocessRunner
|
|
52
56
|
|
53
57
|
private
|
54
58
|
|
59
|
+
def default_worker_count
|
60
|
+
from_env = ENV['MULTIRSPEC_WORKER_COUNT'] || ENV['PARALLEL_TEST_PROCESSORS']
|
61
|
+
if from_env
|
62
|
+
from_env.to_i
|
63
|
+
else
|
64
|
+
DEFAULT_WORKER_COUNT
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def default_first_is_1
|
69
|
+
from_env = ENV['MULTIRSPEC_FIRST_IS_1'] || ENV['PARALLEL_TEST_FIRST_IS_1']
|
70
|
+
%w(true 1).include?(from_env)
|
71
|
+
end
|
72
|
+
|
55
73
|
def help_requested!
|
56
74
|
@help_requested = true
|
57
75
|
end
|
@@ -92,6 +110,10 @@ module RSpec::MultiprocessRunner
|
|
92
110
|
self.log_failing_files = filename
|
93
111
|
end
|
94
112
|
|
113
|
+
parser.on("--first-is-1", "Use \"1\" for the first worker's TEST_ENV_NUMBER (instead of \"\")#{" (enabled in environment)" if first_is_1}") do
|
114
|
+
self.first_is_1 = true
|
115
|
+
end
|
116
|
+
|
95
117
|
parser.on_tail("-h", "--help", "Prints this help") do
|
96
118
|
help_requested!
|
97
119
|
end
|
@@ -8,6 +8,7 @@ module RSpec::MultiprocessRunner
|
|
8
8
|
@worker_count = worker_count
|
9
9
|
@file_timeout_seconds = options[:file_timeout_seconds]
|
10
10
|
@example_timeout_seconds = options[:example_timeout_seconds]
|
11
|
+
@test_env_number_first_is_1 = options[:test_env_number_first_is_1]
|
11
12
|
@log_failing_files = options[:log_failing_files]
|
12
13
|
@rspec_options = options[:rspec_options]
|
13
14
|
@spec_files = sort_files(files)
|
@@ -145,7 +146,8 @@ module RSpec::MultiprocessRunner
|
|
145
146
|
n,
|
146
147
|
file_timeout_seconds: @file_timeout_seconds,
|
147
148
|
example_timeout_seconds: @example_timeout_seconds,
|
148
|
-
rspec_options: @rspec_options
|
149
|
+
rspec_options: @rspec_options,
|
150
|
+
test_env_number_first_is_1: @test_env_number_first_is_1
|
149
151
|
)
|
150
152
|
@workers << new_worker
|
151
153
|
new_worker.start
|
@@ -37,6 +37,9 @@ module RSpec::MultiprocessRunner
|
|
37
37
|
# before killing it. Defaults to 15.
|
38
38
|
attr_accessor :example_timeout_seconds
|
39
39
|
|
40
|
+
# If true, set TEST_ENV_NUMBER="1" for the first worker (instead of "")
|
41
|
+
attr_accessor :first_is_1
|
42
|
+
|
40
43
|
# Whether or not to fail Rake when an error occurs (typically when
|
41
44
|
# examples fail). Defaults to `true`.
|
42
45
|
attr_accessor :fail_on_error
|
@@ -108,6 +111,9 @@ module RSpec::MultiprocessRunner
|
|
108
111
|
if file_timeout_seconds
|
109
112
|
cmd_parts << '--file-timeout' << file_timeout_seconds.to_s
|
110
113
|
end
|
114
|
+
if first_is_1
|
115
|
+
cmd_parts << '--first-is-1'
|
116
|
+
end
|
111
117
|
if pattern
|
112
118
|
cmd_parts << '--pattern' << pattern
|
113
119
|
end
|
@@ -35,6 +35,7 @@ module RSpec::MultiprocessRunner
|
|
35
35
|
@rspec_arguments = (options[:rspec_options] || []) + ["--format", ReportingFormatter.to_s]
|
36
36
|
@example_timeout_seconds = options[:example_timeout_seconds]
|
37
37
|
@file_timeout_seconds = options[:file_timeout_seconds]
|
38
|
+
@test_env_number_first_is_1 = options[:test_env_number_first_is_1]
|
38
39
|
@example_results = []
|
39
40
|
|
40
41
|
# Use a single configuration and world across all individual runs
|
@@ -55,6 +56,14 @@ module RSpec::MultiprocessRunner
|
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
59
|
+
def test_env_number
|
60
|
+
if environment_number == 1 && !@test_env_number_first_is_1
|
61
|
+
""
|
62
|
+
else
|
63
|
+
environment_number.to_s
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
58
67
|
##
|
59
68
|
# Forks the worker process. In the parent, returns the PID.
|
60
69
|
def start
|
@@ -65,7 +74,7 @@ module RSpec::MultiprocessRunner
|
|
65
74
|
else
|
66
75
|
@coordinator_socket.close
|
67
76
|
@pid = Process.pid
|
68
|
-
ENV["TEST_ENV_NUMBER"] =
|
77
|
+
ENV["TEST_ENV_NUMBER"] = test_env_number
|
69
78
|
|
70
79
|
# reset TERM handler so that
|
71
80
|
# - the coordinator's version (if any) is not executed twice
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-multiprocess_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rhett Sutphin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: stub_env
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
75
89
|
description:
|
76
90
|
email:
|
77
91
|
- rhett@detailedbalance.net
|