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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 906e4b29ac1f504f1abb438ef730e5ae7a7076e1
4
- data.tar.gz: fcc5d45823c76190851fd0f340b98b99d00b4a55
3
+ metadata.gz: eb03b149858850d173e253b5f221955c78308d31
4
+ data.tar.gz: 2b7ab7a8bc2404f4753d098becf7d317470e4a5b
5
5
  SHA512:
6
- metadata.gz: db53a0c8a8a517a3d6464845b0b6604a8a34377b61e60139e52a30f7aae2939f8db9096a4b1e6568bd16f33bdab85579b26ab393b68d5d59057addfd52a07e9c
7
- data.tar.gz: b1a64ce20f6ad0d057edbb8e354a99604371546b0b6caf824ba316ae375b1acc4d94f59b7665e81b6394611586ba49183f74b4b480320a98cb8c04a56a81055e
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
- default - runtime or filesize
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/>
@@ -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
- default - runtime or filesize
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
- raise "--group-by filesize is required for --only-group" if options[:group_by] != :filesize and options[:only_group]
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
- tests = if options[:group_by] == :found
45
- tests.map { |t| [t, 1] }
46
- elsif options[:group_by] == :filesize
47
- with_filesize_info(tests)
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
- with_runtime_info(tests, options)
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 with_runtime_info(tests, options = {})
140
- log = options[:runtime_log] || runtime_log
141
- lines = File.read(log).split("\n") rescue []
142
-
143
- # use recorded test runtime if we got enough data
144
- if lines.size * 1.5 > tests.size
145
- puts "Using recorded test runtime: #{log}"
146
- times = Hash.new(1)
147
- lines.each do |line|
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 with_filesize_info(tests)
159
- # use filesize to group files
160
- tests.sort.map { |test| [test, File.stat(test).size] }
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?(MiniTest::Unit)
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
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '1.3.1'
2
+ VERSION = Version = '1.3.2'
3
3
  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: 1.3.1
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-02-26 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel