forking_test_runner 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/forking_test_runner/version.rb +1 -1
- data/lib/forking_test_runner.rb +43 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17cad472149c140f2a0f3a3be8d62f2be58c1e6b
|
4
|
+
data.tar.gz: b60a9c8dada047c49bc63e47f2dac4eefc9af30f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc505b6161b01782421fc361a400ab5d8b2335b59bc77addbac26bbda7913d1e8dc455e7fb9ec34d3e29bacb14b0453ff35c3a4012e01e788258eceed384ad46
|
7
|
+
data.tar.gz: 50a6f0da185ed385affa0ae02273a432a3bb24bf2ac5cc40ba48cb58a4c37323e032066852d1b30e5b02116f084509bc5f61de6589151a9f52b8ec9008a53b3e
|
data/lib/forking_test_runner.rb
CHANGED
@@ -3,12 +3,52 @@ require 'benchmark'
|
|
3
3
|
module ForkingTestRunner
|
4
4
|
CLEAR = "------"
|
5
5
|
|
6
|
+
module CoverageCapture
|
7
|
+
def capture_coverage!
|
8
|
+
@capture_coverage = peek_result.dup
|
9
|
+
end
|
10
|
+
|
11
|
+
# override to add pre-fork captured coverage when someone asks for the results
|
12
|
+
def result
|
13
|
+
original = super
|
14
|
+
return original unless @capture_coverage
|
15
|
+
|
16
|
+
merged = original.dup
|
17
|
+
@capture_coverage.each do |file, coverage|
|
18
|
+
orig = merged[file]
|
19
|
+
merged[file] = if orig
|
20
|
+
merge_coverage(orig, coverage)
|
21
|
+
else
|
22
|
+
coverage
|
23
|
+
end
|
24
|
+
end
|
25
|
+
merged
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# [nil,1,0] + [nil,nil,2] -> [nil,1,2]
|
31
|
+
def merge_coverage(a, b)
|
32
|
+
b.each_with_index.map do |b_count, i|
|
33
|
+
a_count = a[i]
|
34
|
+
(!b_count && !a_count) ? nil : b_count.to_i + a_count.to_i
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
6
39
|
class << self
|
7
40
|
def cli(argv)
|
8
41
|
@rspec = delete_argv("--rspec", argv, arg: false)
|
9
42
|
@no_fixtures = delete_argv("--no-fixtures", argv, arg: false)
|
10
|
-
|
11
43
|
@quiet = delete_argv("--quiet", argv, arg: false)
|
44
|
+
@merge_coverage = delete_argv("--merge-coverage", argv, arg: false)
|
45
|
+
|
46
|
+
if @merge_coverage
|
47
|
+
raise "merge_coverage does not work on ruby prior to 2.3" if RUBY_VERSION < "2.3.0"
|
48
|
+
require 'coverage'
|
49
|
+
klass = (class << Coverage; self; end)
|
50
|
+
klass.prepend CoverageCapture
|
51
|
+
end
|
12
52
|
|
13
53
|
disable_test_autorun
|
14
54
|
|
@@ -26,6 +66,8 @@ module ForkingTestRunner
|
|
26
66
|
puts "Running tests #{tests.map(&:first).join(" ")}"
|
27
67
|
end
|
28
68
|
|
69
|
+
Coverage.capture_coverage! if @merge_coverage
|
70
|
+
|
29
71
|
# run all the tests
|
30
72
|
results = tests.map do |file, expected|
|
31
73
|
puts "#{CLEAR} >>> #{file} "
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forking_test_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.5.1
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Run every test in a fork to avoid pollution and get clean output per test
|