parallel_tests 1.0.9 → 1.1.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/Readme.md +7 -3
- data/bin/parallel_cucumber +5 -1
- data/bin/parallel_rspec +5 -1
- data/bin/parallel_spinach +5 -1
- data/bin/parallel_test +5 -2
- data/lib/parallel_tests.rb +0 -1
- metadata +3 -51
- data/.gitignore +0 -4
- data/.rspec +0 -2
- data/.travis.yml +0 -10
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -53
- data/Rakefile +0 -10
- data/ReadmeRails2.md +0 -48
- data/lib/parallel_tests/cli.rb +0 -206
- data/lib/parallel_tests/cucumber/failures_logger.rb +0 -25
- data/lib/parallel_tests/cucumber/runner.rb +0 -37
- data/lib/parallel_tests/cucumber/scenario_line_logger.rb +0 -51
- data/lib/parallel_tests/cucumber/scenarios.rb +0 -34
- data/lib/parallel_tests/gherkin/io.rb +0 -41
- data/lib/parallel_tests/gherkin/listener.rb +0 -87
- data/lib/parallel_tests/gherkin/runner.rb +0 -116
- data/lib/parallel_tests/gherkin/runtime_logger.rb +0 -28
- data/lib/parallel_tests/grouper.rb +0 -73
- data/lib/parallel_tests/railtie.rb +0 -8
- data/lib/parallel_tests/rspec/failures_logger.rb +0 -54
- data/lib/parallel_tests/rspec/logger_base.rb +0 -55
- data/lib/parallel_tests/rspec/runner.rb +0 -73
- data/lib/parallel_tests/rspec/runtime_logger.rb +0 -59
- data/lib/parallel_tests/rspec/summary_logger.rb +0 -19
- data/lib/parallel_tests/spinach/runner.rb +0 -19
- data/lib/parallel_tests/tasks.rb +0 -157
- data/lib/parallel_tests/test/runner.rb +0 -186
- data/lib/parallel_tests/test/runtime_logger.rb +0 -98
- data/lib/parallel_tests/version.rb +0 -3
- data/parallel_tests.gemspec +0 -14
- data/spec/integration_spec.rb +0 -437
- data/spec/parallel_tests/cli_spec.rb +0 -149
- data/spec/parallel_tests/cucumber/failure_logger_spec.rb +0 -43
- data/spec/parallel_tests/cucumber/runner_spec.rb +0 -25
- data/spec/parallel_tests/cucumber/scenarios_spec.rb +0 -69
- data/spec/parallel_tests/gherkin/listener_spec.rb +0 -96
- data/spec/parallel_tests/gherkin/runner_behaviour.rb +0 -216
- data/spec/parallel_tests/grouper_spec.rb +0 -61
- data/spec/parallel_tests/rspec/failures_logger_spec.rb +0 -82
- data/spec/parallel_tests/rspec/logger_base_spec.rb +0 -35
- data/spec/parallel_tests/rspec/runner_spec.rb +0 -201
- data/spec/parallel_tests/rspec/runtime_logger_spec.rb +0 -131
- data/spec/parallel_tests/rspec/summary_logger_spec.rb +0 -37
- data/spec/parallel_tests/spinach/runner_spec.rb +0 -12
- data/spec/parallel_tests/tasks_spec.rb +0 -178
- data/spec/parallel_tests/test/runner_spec.rb +0 -407
- data/spec/parallel_tests/test/runtime_logger_spec.rb +0 -112
- data/spec/parallel_tests_spec.rb +0 -137
- data/spec/spec_helper.rb +0 -182
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d378dd684c7e7a13876bc30b017c2d7d38a65238
|
4
|
+
data.tar.gz: 15a61d401253bcff02d591f5d73345beb3244fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a743c635bd8a247d26536bb163f1b5383edc75c5e4cc9ca923d774a81df3656cdac6cfd15ebab70ead6293e07b7b71633d90d71e8c687f9968b36ebfab6a0ad
|
7
|
+
data.tar.gz: 788fd6fb129d348952fe7ed52314d19d573c59f420fbbe06a9a2b08937ca7dd50a454f267154a80325f4845b1c18d563382909b4ebf34985336f7ae3d6e05689
|
data/Readme.md
CHANGED
@@ -170,12 +170,14 @@ Options are:
|
|
170
170
|
-p, --pattern [PATTERN] run tests matching this pattern
|
171
171
|
--group-by [TYPE] group tests by:
|
172
172
|
found - order of finding files
|
173
|
-
steps - number of cucumber steps
|
174
|
-
|
173
|
+
steps - number of cucumber/spinach steps
|
174
|
+
scenarios - individual cucumber scenarios
|
175
|
+
filesize - by size of the file
|
175
176
|
default - runtime or filesize
|
176
177
|
-m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
|
177
178
|
-s, --single [PATTERN] Run all matching files in the same process
|
178
179
|
-i, --isolate Do not run any other tests in the group used by --single(-s)
|
180
|
+
--only-group INT[, INT]
|
179
181
|
-e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUM']
|
180
182
|
-o, --test-options '[OPTIONS]' execute test commands with those options
|
181
183
|
-t, --type [TYPE] test(default) / rspec / cucumber / spinach
|
@@ -185,7 +187,8 @@ Options are:
|
|
185
187
|
--no-symlinks Do not traverse symbolic links to find test files
|
186
188
|
--ignore-tags [PATTERN] When counting steps ignore scenarios with tags that match this pattern
|
187
189
|
--nice execute test commands with low priority.
|
188
|
-
--
|
190
|
+
--runtime-log [PATH] Location of previously recorded test runtimes
|
191
|
+
--verbose Print more output
|
189
192
|
-v, --version Show Version
|
190
193
|
-h, --help Show this.
|
191
194
|
|
@@ -302,6 +305,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
|
|
302
305
|
- [Samer Masry](https://github.com/smasry)
|
303
306
|
- [Volodymyr Mykhailyk](https:/github.com/volodymyr-mykhailyk)
|
304
307
|
- [Mike Mueller](https://github.com/mmueller)
|
308
|
+
- [Aaron Jensen](https://github.com/aaronjensen)
|
305
309
|
|
306
310
|
[Michael Grosser](http://grosser.it)<br/>
|
307
311
|
michael@grosser.it<br/>
|
data/bin/parallel_cucumber
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
# enable local usage from cloned repo
|
4
|
+
root = File.expand_path("../..", __FILE__)
|
5
|
+
$LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
|
6
|
+
|
3
7
|
require "parallel_tests"
|
4
8
|
|
5
9
|
ParallelTests::CLI.new.run(["--type", "cucumber"] + ARGV)
|
data/bin/parallel_rspec
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
# enable local usage from cloned repo
|
4
|
+
root = File.expand_path("../..", __FILE__)
|
5
|
+
$LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
|
6
|
+
|
3
7
|
require "parallel_tests"
|
4
8
|
|
5
9
|
ParallelTests::CLI.new.run(["--type", "rspec"] + ARGV)
|
data/bin/parallel_spinach
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
# enable local usage from cloned repo
|
4
|
+
root = File.expand_path("../..", __FILE__)
|
5
|
+
$LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
|
6
|
+
|
3
7
|
require "parallel_tests"
|
4
8
|
|
5
9
|
ParallelTests::CLI.new.run(["--type", "spinach"] + ARGV)
|
data/bin/parallel_test
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
# enable local usage from cloned repo
|
4
|
+
root = File.expand_path("../..", __FILE__)
|
5
|
+
$LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
|
6
|
+
|
4
7
|
require "parallel_tests"
|
5
8
|
|
6
9
|
ParallelTests::CLI.new.run(["--type", "test"] + ARGV)
|
data/lib/parallel_tests.rb
CHANGED
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: 1.0
|
4
|
+
version: 1.1.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: 2015-
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -34,60 +34,12 @@ executables:
|
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
|
-
- ".gitignore"
|
38
|
-
- ".rspec"
|
39
|
-
- ".travis.yml"
|
40
|
-
- Gemfile
|
41
|
-
- Gemfile.lock
|
42
|
-
- Rakefile
|
43
37
|
- Readme.md
|
44
|
-
- ReadmeRails2.md
|
45
38
|
- bin/parallel_cucumber
|
46
39
|
- bin/parallel_rspec
|
47
40
|
- bin/parallel_spinach
|
48
41
|
- bin/parallel_test
|
49
42
|
- lib/parallel_tests.rb
|
50
|
-
- lib/parallel_tests/cli.rb
|
51
|
-
- lib/parallel_tests/cucumber/failures_logger.rb
|
52
|
-
- lib/parallel_tests/cucumber/runner.rb
|
53
|
-
- lib/parallel_tests/cucumber/scenario_line_logger.rb
|
54
|
-
- lib/parallel_tests/cucumber/scenarios.rb
|
55
|
-
- lib/parallel_tests/gherkin/io.rb
|
56
|
-
- lib/parallel_tests/gherkin/listener.rb
|
57
|
-
- lib/parallel_tests/gherkin/runner.rb
|
58
|
-
- lib/parallel_tests/gherkin/runtime_logger.rb
|
59
|
-
- lib/parallel_tests/grouper.rb
|
60
|
-
- lib/parallel_tests/railtie.rb
|
61
|
-
- lib/parallel_tests/rspec/failures_logger.rb
|
62
|
-
- lib/parallel_tests/rspec/logger_base.rb
|
63
|
-
- lib/parallel_tests/rspec/runner.rb
|
64
|
-
- lib/parallel_tests/rspec/runtime_logger.rb
|
65
|
-
- lib/parallel_tests/rspec/summary_logger.rb
|
66
|
-
- lib/parallel_tests/spinach/runner.rb
|
67
|
-
- lib/parallel_tests/tasks.rb
|
68
|
-
- lib/parallel_tests/test/runner.rb
|
69
|
-
- lib/parallel_tests/test/runtime_logger.rb
|
70
|
-
- lib/parallel_tests/version.rb
|
71
|
-
- parallel_tests.gemspec
|
72
|
-
- spec/integration_spec.rb
|
73
|
-
- spec/parallel_tests/cli_spec.rb
|
74
|
-
- spec/parallel_tests/cucumber/failure_logger_spec.rb
|
75
|
-
- spec/parallel_tests/cucumber/runner_spec.rb
|
76
|
-
- spec/parallel_tests/cucumber/scenarios_spec.rb
|
77
|
-
- spec/parallel_tests/gherkin/listener_spec.rb
|
78
|
-
- spec/parallel_tests/gherkin/runner_behaviour.rb
|
79
|
-
- spec/parallel_tests/grouper_spec.rb
|
80
|
-
- spec/parallel_tests/rspec/failures_logger_spec.rb
|
81
|
-
- spec/parallel_tests/rspec/logger_base_spec.rb
|
82
|
-
- spec/parallel_tests/rspec/runner_spec.rb
|
83
|
-
- spec/parallel_tests/rspec/runtime_logger_spec.rb
|
84
|
-
- spec/parallel_tests/rspec/summary_logger_spec.rb
|
85
|
-
- spec/parallel_tests/spinach/runner_spec.rb
|
86
|
-
- spec/parallel_tests/tasks_spec.rb
|
87
|
-
- spec/parallel_tests/test/runner_spec.rb
|
88
|
-
- spec/parallel_tests/test/runtime_logger_spec.rb
|
89
|
-
- spec/parallel_tests_spec.rb
|
90
|
-
- spec/spec_helper.rb
|
91
43
|
homepage: http://github.com/grosser/parallel_tests
|
92
44
|
licenses:
|
93
45
|
- MIT
|
@@ -100,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
52
|
requirements:
|
101
53
|
- - ">="
|
102
54
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
55
|
+
version: 1.9.3
|
104
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
57
|
requirements:
|
106
58
|
- - ">="
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
parallel_tests (1.0.9)
|
5
|
-
parallel
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
builder (3.2.2)
|
11
|
-
bump (0.3.8)
|
12
|
-
colorize (0.5.8)
|
13
|
-
cucumber (1.3.10)
|
14
|
-
builder (>= 2.1.2)
|
15
|
-
diff-lcs (>= 1.1.3)
|
16
|
-
gherkin (~> 2.12)
|
17
|
-
multi_json (>= 1.7.5, < 2.0)
|
18
|
-
multi_test (>= 0.0.2)
|
19
|
-
diff-lcs (1.2.5)
|
20
|
-
gherkin (2.12.2)
|
21
|
-
multi_json (~> 1.3)
|
22
|
-
gherkin (2.12.2-java)
|
23
|
-
multi_json (~> 1.3)
|
24
|
-
gherkin-ruby (0.3.0)
|
25
|
-
multi_json (1.8.2)
|
26
|
-
multi_test (0.0.2)
|
27
|
-
parallel (1.3.3)
|
28
|
-
rake (10.0.3)
|
29
|
-
rspec (2.13.0)
|
30
|
-
rspec-core (~> 2.13.0)
|
31
|
-
rspec-expectations (~> 2.13.0)
|
32
|
-
rspec-mocks (~> 2.13.0)
|
33
|
-
rspec-core (2.13.1)
|
34
|
-
rspec-expectations (2.13.0)
|
35
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
36
|
-
rspec-mocks (2.13.1)
|
37
|
-
spinach (0.8.3)
|
38
|
-
colorize (= 0.5.8)
|
39
|
-
gherkin-ruby (~> 0.3.0)
|
40
|
-
test-unit (2.4.4)
|
41
|
-
|
42
|
-
PLATFORMS
|
43
|
-
java
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
bump
|
48
|
-
cucumber
|
49
|
-
parallel_tests!
|
50
|
-
rake
|
51
|
-
rspec (>= 2.4)
|
52
|
-
spinach
|
53
|
-
test-unit
|
data/Rakefile
DELETED
data/ReadmeRails2.md
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
### Install
|
2
|
-
|
3
|
-
As gem
|
4
|
-
|
5
|
-
gem install parallel_tests
|
6
|
-
|
7
|
-
# add to config/environments/development.rb
|
8
|
-
config.gem "parallel_tests"
|
9
|
-
|
10
|
-
# add to Rakefile
|
11
|
-
begin; require 'parallel_tests/tasks'; rescue LoadError; end
|
12
|
-
|
13
|
-
OR as plugin
|
14
|
-
|
15
|
-
gem install parallel
|
16
|
-
|
17
|
-
# add to config/environments/development.rb
|
18
|
-
config.gem "parallel"
|
19
|
-
|
20
|
-
./script/plugin install git://github.com/grosser/parallel_tests.git
|
21
|
-
|
22
|
-
# add to Rakefile
|
23
|
-
begin; require 'vendor/plugins/parallel_tests/lib/parallel_tests/tasks'; rescue LoadError; end
|
24
|
-
|
25
|
-
|
26
|
-
Even process runtimes
|
27
|
-
-----------------
|
28
|
-
|
29
|
-
RSpec 1.x:
|
30
|
-
--format progress
|
31
|
-
--require parallel_tests/rspec/runtime_logger
|
32
|
-
--format ParallelTests::RSpec::RuntimeLogger:tmp/parallel_runtime_rspec.log
|
33
|
-
|
34
|
-
SpecSummaryLogger
|
35
|
-
--------------------
|
36
|
-
|
37
|
-
RSpec 1.x:
|
38
|
-
--format progress
|
39
|
-
--require parallel_tests/rspec/summary_logger
|
40
|
-
--format ParallelTests::RSpec::SummaryLogger:tmp/spec_summary.log
|
41
|
-
|
42
|
-
SpecFailuresLogger
|
43
|
-
-----------------------
|
44
|
-
|
45
|
-
RSpec 1.x:
|
46
|
-
--format progress
|
47
|
-
--require parallel_tests/rspec/failures_logger
|
48
|
-
--format ParallelTests::RSpec::FailuresLogger:tmp/failing_specs.log
|
data/lib/parallel_tests/cli.rb
DELETED
@@ -1,206 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'parallel_tests'
|
4
|
-
|
5
|
-
module ParallelTests
|
6
|
-
class CLI
|
7
|
-
def run(argv)
|
8
|
-
options = parse_options!(argv)
|
9
|
-
|
10
|
-
num_processes = ParallelTests.determine_number_of_processes(options[:count])
|
11
|
-
num_processes = num_processes * (options[:multiply] || 1)
|
12
|
-
|
13
|
-
if options[:execute]
|
14
|
-
execute_shell_command_in_parallel(options[:execute], num_processes, options)
|
15
|
-
else
|
16
|
-
run_tests_in_parallel(num_processes, options)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def execute_in_parallel(items, num_processes, options)
|
23
|
-
Tempfile.open 'parallel_tests-lock' do |lock|
|
24
|
-
return Parallel.map(items, :in_threads => num_processes) do |item|
|
25
|
-
result = yield(item)
|
26
|
-
report_output(result, lock) if options[:serialize_stdout]
|
27
|
-
result
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def run_tests_in_parallel(num_processes, options)
|
33
|
-
test_results = nil
|
34
|
-
|
35
|
-
report_time_taken do
|
36
|
-
groups = @runner.tests_in_groups(options[:files], num_processes, options)
|
37
|
-
|
38
|
-
test_results = if options[:only_group]
|
39
|
-
groups_to_run = options[:only_group].collect{|i| groups[i - 1]}
|
40
|
-
report_number_of_tests(groups_to_run)
|
41
|
-
execute_in_parallel(groups_to_run, groups_to_run.size, options) do |group|
|
42
|
-
run_tests(group, groups_to_run.index(group), 1, options)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
report_number_of_tests(groups)
|
46
|
-
|
47
|
-
execute_in_parallel(groups, groups.size, options) do |group|
|
48
|
-
run_tests(group, groups.index(group), num_processes, options)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
report_results(test_results)
|
53
|
-
end
|
54
|
-
|
55
|
-
abort final_fail_message if any_test_failed?(test_results)
|
56
|
-
end
|
57
|
-
|
58
|
-
def run_tests(group, process_number, num_processes, options)
|
59
|
-
if group.empty?
|
60
|
-
{:stdout => '', :exit_status => 0}
|
61
|
-
else
|
62
|
-
@runner.run_tests(group, process_number, num_processes, options)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def report_output(result, lock)
|
67
|
-
lock.flock File::LOCK_EX
|
68
|
-
$stdout.puts result[:stdout]
|
69
|
-
$stdout.flush
|
70
|
-
ensure
|
71
|
-
lock.flock File::LOCK_UN
|
72
|
-
end
|
73
|
-
|
74
|
-
def report_results(test_results)
|
75
|
-
results = @runner.find_results(test_results.map { |result| result[:stdout] }*"")
|
76
|
-
puts ""
|
77
|
-
puts @runner.summarize_results(results)
|
78
|
-
end
|
79
|
-
|
80
|
-
def report_number_of_tests(groups)
|
81
|
-
name = @runner.test_file_name
|
82
|
-
num_processes = groups.size
|
83
|
-
num_tests = groups.map(&:size).inject(:+)
|
84
|
-
puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{num_tests / groups.size} #{name}s per process"
|
85
|
-
end
|
86
|
-
|
87
|
-
#exit with correct status code so rake parallel:test && echo 123 works
|
88
|
-
def any_test_failed?(test_results)
|
89
|
-
test_results.any? { |result| result[:exit_status] != 0 }
|
90
|
-
end
|
91
|
-
|
92
|
-
def parse_options!(argv)
|
93
|
-
options = {}
|
94
|
-
OptionParser.new do |opts|
|
95
|
-
opts.banner = <<BANNER
|
96
|
-
Run all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('', '2', '3', ...)
|
97
|
-
|
98
|
-
[optional] Only run selected files & folders:
|
99
|
-
parallel_test test/bar test/baz/xxx_text.rb
|
100
|
-
|
101
|
-
Options are:
|
102
|
-
BANNER
|
103
|
-
opts.on("-n [PROCESSES]", Integer, "How many processes to use, default: available CPUs") { |n| options[:count] = n }
|
104
|
-
opts.on("-p", "--pattern [PATTERN]", "run tests matching this pattern") { |pattern| options[:pattern] = /#{pattern}/ }
|
105
|
-
opts.on("--group-by [TYPE]", <<-TEXT
|
106
|
-
group tests by:
|
107
|
-
found - order of finding files
|
108
|
-
steps - number of cucumber/spinach steps
|
109
|
-
scenarios - individual cucumber scenarios
|
110
|
-
filesize - by size of the file
|
111
|
-
default - runtime or filesize
|
112
|
-
TEXT
|
113
|
-
) { |type| options[:group_by] = type.to_sym }
|
114
|
-
opts.on("-m [FLOAT]", "--multiply-processes [FLOAT]", Float, "use given number as a multiplier of processes to run") { |multiply| options[:multiply] = multiply }
|
115
|
-
|
116
|
-
opts.on("-s [PATTERN]", "--single [PATTERN]",
|
117
|
-
"Run all matching files in the same process") do |pattern|
|
118
|
-
|
119
|
-
options[:single_process] ||= []
|
120
|
-
options[:single_process] << /#{pattern}/
|
121
|
-
end
|
122
|
-
|
123
|
-
opts.on("-i", "--isolate",
|
124
|
-
"Do not run any other tests in the group used by --single(-s)") do |pattern|
|
125
|
-
|
126
|
-
options[:isolate] = true
|
127
|
-
end
|
128
|
-
|
129
|
-
opts.on("--only-group INT[, INT]", Array) { |groups| options[:only_group] = groups.map(&:to_i) }
|
130
|
-
|
131
|
-
opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUM']") { |path| options[:execute] = path }
|
132
|
-
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg }
|
133
|
-
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
|
134
|
-
begin
|
135
|
-
@runner = load_runner(type)
|
136
|
-
rescue NameError, LoadError => e
|
137
|
-
puts "Runner for `#{type}` type has not been found! (#{e})"
|
138
|
-
abort
|
139
|
-
end
|
140
|
-
end
|
141
|
-
opts.on("--serialize-stdout", "Serialize stdout output, nothing will be written until everything is done") { options[:serialize_stdout] = true }
|
142
|
-
opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true }
|
143
|
-
opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
|
144
|
-
opts.on("--no-symlinks", "Do not traverse symbolic links to find test files") { options[:symlinks] = false }
|
145
|
-
opts.on('--ignore-tags [PATTERN]', 'When counting steps ignore scenarios with tags that match this pattern') { |arg| options[:ignore_tag_pattern] = arg }
|
146
|
-
opts.on("--nice", "execute test commands with low priority.") { options[:nice] = true }
|
147
|
-
opts.on("--runtime-log [PATH]", "Location of previously recorded test runtimes") { |path| options[:runtime_log] = path }
|
148
|
-
opts.on("-v", "--version", "Show Version") { puts ParallelTests::VERSION; exit }
|
149
|
-
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
150
|
-
end.parse!(argv)
|
151
|
-
|
152
|
-
if options[:count] == 0
|
153
|
-
options.delete(:count)
|
154
|
-
options[:non_parallel] = true
|
155
|
-
end
|
156
|
-
|
157
|
-
options[:files] = argv
|
158
|
-
|
159
|
-
options[:group_by] ||= :filesize if options[:only_group]
|
160
|
-
|
161
|
-
raise "--group-by found and --single-process are not supported" if options[:group_by] == :found and options[:single_process]
|
162
|
-
raise "--group-by filesize is required for --only-group" if options[:group_by] != :filesize and options[:only_group]
|
163
|
-
|
164
|
-
options
|
165
|
-
end
|
166
|
-
|
167
|
-
def load_runner(type)
|
168
|
-
require "parallel_tests/#{type}/runner"
|
169
|
-
runner_classname = type.split("_").map(&:capitalize).join.sub("Rspec", "RSpec")
|
170
|
-
klass_name = "ParallelTests::#{runner_classname}::Runner"
|
171
|
-
klass_name.split('::').inject(Object) { |x, y| x.const_get(y) }
|
172
|
-
end
|
173
|
-
|
174
|
-
def execute_shell_command_in_parallel(command, num_processes, options)
|
175
|
-
runs = (0...num_processes).to_a
|
176
|
-
results = if options[:non_parallel]
|
177
|
-
runs.map do |i|
|
178
|
-
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options)
|
179
|
-
end
|
180
|
-
else
|
181
|
-
execute_in_parallel(runs, num_processes, options) do |i|
|
182
|
-
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options)
|
183
|
-
end
|
184
|
-
end.flatten
|
185
|
-
|
186
|
-
abort if results.any? { |r| r[:exit_status] != 0 }
|
187
|
-
end
|
188
|
-
|
189
|
-
def report_time_taken
|
190
|
-
start = Time.now
|
191
|
-
yield
|
192
|
-
puts "\nTook #{Time.now - start} seconds"
|
193
|
-
end
|
194
|
-
|
195
|
-
def final_fail_message
|
196
|
-
fail_message = "#{@runner.name}s Failed"
|
197
|
-
fail_message = "\e[31m#{fail_message}\e[0m" if use_colors?
|
198
|
-
|
199
|
-
fail_message
|
200
|
-
end
|
201
|
-
|
202
|
-
def use_colors?
|
203
|
-
$stdout.tty?
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|