parallel_tests 1.3.5 → 1.3.6

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: 352fa864d70d787e50eb44c7c47c1b2d2bade48d
4
- data.tar.gz: cb300796822d200a52b06ffc78fbde18cc443898
3
+ metadata.gz: b57802f4d3da910095fefb6c49645784d566ae31
4
+ data.tar.gz: 355cc6948f4513854032fde22251d7a4e136bd49
5
5
  SHA512:
6
- metadata.gz: d35ee99456b3adad10251061b6576deaade4783f56239616283e308420dd45888a0ac5c16ea298b4499f52a7c8260cee7cdff6aa89032198f8a12c07bafcd881
7
- data.tar.gz: d66c822297d2b63f7d0896c5943f1ca4e6c6d1d879f35824fd872c95ec3f5916ddbd30dc05500cb59209de82ef2fea4b534ef79001e81556f15ba178dd8ae558
6
+ metadata.gz: 1f225a898105d9363f624f1d62c3776d7d7893a2ad718fc1ebae4dacac84af2aad915566b2e4534ff4ab71c525faad95d425033f79f7b0f4c554529fca19fa8c
7
+ data.tar.gz: 34d5724a1fb8085e2677077abd08d70486f7195b0a1f019a53be8bd413de8c8b6e9cbcb3562a1e7943d1e31e23fea16f4dd6a0f0d6e9ef87d0dfcc5ecd8450d6
@@ -47,10 +47,10 @@ module ParallelTests
47
47
  when :filesize
48
48
  sort_by_filesize(tests)
49
49
  when :runtime
50
- sort_by_runtime(tests, runtimes(options), options.merge(allowed_missing: 0.5))
50
+ sort_by_runtime(tests, runtimes(tests, options), options.merge(allowed_missing: 0.5))
51
51
  when nil
52
52
  # use recorded test runtime if we got enough data
53
- runtimes = runtimes(options) rescue []
53
+ runtimes = runtimes(tests, options) rescue []
54
54
  if runtimes.size * 1.5 > tests.size
55
55
  puts "Using recorded test runtime"
56
56
  sort_by_runtime(tests, runtimes)
@@ -153,18 +153,10 @@ module ParallelTests
153
153
  allowed_missing = options[:allowed_missing] || 1.0
154
154
  allowed_missing = tests.size * allowed_missing
155
155
 
156
- # build runtime hash
157
- times = {}
158
- runtimes.each do |line|
159
- test, time = line.split(":", 2)
160
- next unless test and time
161
- times[test] = time.to_f
162
- end
163
-
164
156
  # set know runtime for each test
165
157
  tests.sort!
166
158
  tests.map! do |test|
167
- allowed_missing -= 1 unless time = times[test]
159
+ allowed_missing -= 1 unless time = runtimes[test]
168
160
  raise "Too little runtime info" if allowed_missing < 0
169
161
  [test, time]
170
162
  end
@@ -175,13 +167,18 @@ module ParallelTests
175
167
 
176
168
  # fill gaps with average runtime
177
169
  known, unknown = tests.partition(&:last)
178
- average = known.map!(&:last).inject(:+) / known.size
170
+ average = (known.any? ? known.map!(&:last).inject(:+) / known.size : 1)
179
171
  unknown.each { |set| set[1] = average }
180
172
  end
181
173
 
182
- def runtimes(options)
174
+ def runtimes(tests, options)
183
175
  log = options[:runtime_log] || runtime_log
184
- File.read(log).split("\n")
176
+ lines = File.read(log).split("\n")
177
+ lines.each_with_object({}) do |line, times|
178
+ test, time = line.split(":", 2)
179
+ next unless test and time
180
+ times[test] = time.to_f if tests.include?(test)
181
+ end
185
182
  end
186
183
 
187
184
  def sort_by_filesize(tests)
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '1.3.5'
2
+ VERSION = Version = '1.3.6'
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.5
4
+ version: 1.3.6
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-03-10 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel