parallel_tests 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +7 -4
- data/lib/parallel_tests/cli.rb +6 -2
- data/lib/parallel_tests/test/runner.rb +42 -24
- data/lib/parallel_tests/test/runtime_logger.rb +20 -2
- data/lib/parallel_tests/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb03b149858850d173e253b5f221955c78308d31
|
4
|
+
data.tar.gz: 2b7ab7a8bc2404f4753d098becf7d317470e4a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3505c81d9d74cded2d43af6c94260d06090e2d0aff0b10ea49af3f2411471190ea84516841c2a5df819cea1fe437320b4711e3beaf98a0d9fd40aac813a36ded
|
7
|
+
data.tar.gz: f1e93029650eca41352d4b5feac1fc663a6405ec6daef96116f24b58ae1f274bbdf906da26cabcf6151b72abd6a949b55cb3a3f974f3997ad7f8b91957b83768
|
data/Readme.md
CHANGED
@@ -99,14 +99,15 @@ Rspec: Add to your `.rspec_parallel` (or `.rspec`) :
|
|
99
99
|
--format progress
|
100
100
|
--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
|
101
101
|
|
102
|
-
### Test::Unit & Minitest 4
|
102
|
+
### Test::Unit & Minitest 4/5
|
103
103
|
|
104
104
|
Add to your `test_helper.rb`:
|
105
105
|
```ruby
|
106
|
-
require 'parallel_tests/test/runtime_logger'
|
106
|
+
require 'parallel_tests/test/runtime_logger' if ENV['RECORD_RUNTIME']
|
107
107
|
```
|
108
108
|
|
109
|
-
results will be logged to tmp/parallel_runtime_test.log
|
109
|
+
results will be logged to tmp/parallel_runtime_test.log when `RECORD_RUNTIME` is set,
|
110
|
+
so it is not always required or overwritten.
|
110
111
|
|
111
112
|
RSpec: SummaryLogger
|
112
113
|
--------------------
|
@@ -175,7 +176,8 @@ Options are:
|
|
175
176
|
steps - number of cucumber/spinach steps
|
176
177
|
scenarios - individual cucumber scenarios
|
177
178
|
filesize - by size of the file
|
178
|
-
|
179
|
+
runtime - info from runtime log
|
180
|
+
default - runtime when runtime log is filled otherwise filesize
|
179
181
|
-m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
|
180
182
|
-s, --single [PATTERN] Run all matching files in the same process
|
181
183
|
-i, --isolate Do not run any other tests in the group used by --single(-s)
|
@@ -306,6 +308,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
|
|
306
308
|
- [Volodymyr Mykhailyk](https:/github.com/volodymyr-mykhailyk)
|
307
309
|
- [Mike Mueller](https://github.com/mmueller)
|
308
310
|
- [Aaron Jensen](https://github.com/aaronjensen)
|
311
|
+
- [Ed Slocomb](https://github.com/edslocomb)
|
309
312
|
|
310
313
|
[Michael Grosser](http://grosser.it)<br/>
|
311
314
|
michael@grosser.it<br/>
|
data/lib/parallel_tests/cli.rb
CHANGED
@@ -108,7 +108,8 @@ module ParallelTests
|
|
108
108
|
steps - number of cucumber/spinach steps
|
109
109
|
scenarios - individual cucumber scenarios
|
110
110
|
filesize - by size of the file
|
111
|
-
|
111
|
+
runtime - info from runtime log
|
112
|
+
default - runtime when runtime log is filled otherwise filesize
|
112
113
|
TEXT
|
113
114
|
) { |type| options[:group_by] = type.to_sym }
|
114
115
|
opts.on("-m [FLOAT]", "--multiply-processes [FLOAT]", Float, "use given number as a multiplier of processes to run") { |multiply| options[:multiply] = multiply }
|
@@ -162,7 +163,10 @@ module ParallelTests
|
|
162
163
|
options[:group_by] ||= :filesize if options[:only_group]
|
163
164
|
|
164
165
|
raise "--group-by found and --single-process are not supported" if options[:group_by] == :found and options[:single_process]
|
165
|
-
|
166
|
+
allowed = [:filesize, :runtime, :found]
|
167
|
+
if !allowed.include?(options[:group_by]) && options[:only_group]
|
168
|
+
raise "--group-by #{allowed.join(" or ")} is required for --only-group"
|
169
|
+
end
|
166
170
|
|
167
171
|
options
|
168
172
|
end
|
@@ -41,13 +41,26 @@ module ParallelTests
|
|
41
41
|
def tests_in_groups(tests, num_groups, options={})
|
42
42
|
tests = find_tests(tests, options)
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
case options[:group_by]
|
45
|
+
when :found
|
46
|
+
tests.map! { |t| [t, 1] }
|
47
|
+
when :filesize
|
48
|
+
sort_by_filesize(tests)
|
49
|
+
when :runtime
|
50
|
+
sort_by_runtime(tests, runtimes(options), allowed_missing: 0.5)
|
51
|
+
when nil
|
52
|
+
# use recorded test runtime if we got enough data
|
53
|
+
runtimes = runtimes(options) rescue []
|
54
|
+
if runtimes.size * 1.5 > tests.size
|
55
|
+
puts "Using recorded test runtime"
|
56
|
+
sort_by_runtime(tests, runtimes)
|
57
|
+
else
|
58
|
+
sort_by_filesize(tests)
|
59
|
+
end
|
48
60
|
else
|
49
|
-
|
61
|
+
raise ArgumentError, "Unsupported option #{options[:group_by]}"
|
50
62
|
end
|
63
|
+
|
51
64
|
Grouper.in_even_groups_by_size(tests, num_groups, options)
|
52
65
|
end
|
53
66
|
|
@@ -136,28 +149,33 @@ module ParallelTests
|
|
136
149
|
result
|
137
150
|
end
|
138
151
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
test, time = line.split(":")
|
149
|
-
next unless test and time
|
150
|
-
times[test] = time.to_f
|
151
|
-
end
|
152
|
-
tests.sort.map { |test| [test, times[test]] }
|
153
|
-
else # use file sizes
|
154
|
-
with_filesize_info(tests)
|
152
|
+
def sort_by_runtime(tests, runtimes, options={})
|
153
|
+
allowed_missing = options[:allowed_missing] || 1.0
|
154
|
+
allowed_missing = tests.size * allowed_missing
|
155
|
+
|
156
|
+
times = {}
|
157
|
+
runtimes.each do |line|
|
158
|
+
test, time = line.split(":", 2)
|
159
|
+
next unless test and time
|
160
|
+
times[test] = time.to_f
|
155
161
|
end
|
162
|
+
|
163
|
+
tests.sort!
|
164
|
+
tests.map! do |test|
|
165
|
+
allowed_missing -= 1 unless time = times[test]
|
166
|
+
raise "Too little runtime info" if allowed_missing < 0
|
167
|
+
[test, time || 1]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def runtimes(options)
|
172
|
+
log = options[:runtime_log] || runtime_log
|
173
|
+
File.read(log).split("\n")
|
156
174
|
end
|
157
175
|
|
158
|
-
def
|
159
|
-
|
160
|
-
tests.
|
176
|
+
def sort_by_filesize(tests)
|
177
|
+
tests.sort!
|
178
|
+
tests.map! { |test| [test, File.stat(test).size] }
|
161
179
|
end
|
162
180
|
|
163
181
|
def find_tests(tests, options = {})
|
@@ -71,7 +71,25 @@ module ParallelTests
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
if defined?(
|
74
|
+
if defined?(Minitest::Test) # Minitest 5
|
75
|
+
class << Minitest::Runnable
|
76
|
+
alias_method :run_without_runtime_log, :run
|
77
|
+
def run(*args)
|
78
|
+
ParallelTests::Test::RuntimeLogger.log_test_run(self) do
|
79
|
+
run_without_runtime_log(*args)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class << Minitest
|
85
|
+
alias_method :run_without_runtime_log, :run
|
86
|
+
def run(*args)
|
87
|
+
result = run_without_runtime_log(*args)
|
88
|
+
ParallelTests::Test::RuntimeLogger.unique_log
|
89
|
+
result
|
90
|
+
end
|
91
|
+
end
|
92
|
+
elsif defined?(MiniTest::Unit) # Minitest 4
|
75
93
|
MiniTest::Unit.class_eval do
|
76
94
|
alias_method :_run_suite_without_runtime_log, :_run_suite
|
77
95
|
def _run_suite(*args)
|
@@ -87,7 +105,7 @@ if defined?(MiniTest::Unit)
|
|
87
105
|
result
|
88
106
|
end
|
89
107
|
end
|
90
|
-
else
|
108
|
+
else # Test::Unit
|
91
109
|
require 'test/unit/testsuite'
|
92
110
|
class ::Test::Unit::TestSuite
|
93
111
|
alias_method :run_without_timing, :run
|
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.3.
|
4
|
+
version: 1.3.2
|
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-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|