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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 455fbc6f17156c672bf430e9b003c968d5607dc7
4
- data.tar.gz: b7d396787d8df135c38d45587241dbb9f4eefdbb
3
+ metadata.gz: 17cad472149c140f2a0f3a3be8d62f2be58c1e6b
4
+ data.tar.gz: b60a9c8dada047c49bc63e47f2dac4eefc9af30f
5
5
  SHA512:
6
- metadata.gz: b7f8da2b97dfd0c554eec9e74f74cfc06ad1053184b2d9811874a77797dc3673a8bda7f23398a7995f26d09a19d1fc6e372c4461bf3538b17037c8d3feffa199
7
- data.tar.gz: 5031d3a3bebe4a34d6e66d9a9cbac3b92f64d0a01de61e0604e36cb18e1096bb8f5384d58af24a91a68a587324ff6e67fc4161b56541018e562fc177aa1d8b8a
6
+ metadata.gz: cc505b6161b01782421fc361a400ab5d8b2335b59bc77addbac26bbda7913d1e8dc455e7fb9ec34d3e29bacb14b0453ff35c3a4012e01e788258eceed384ad46
7
+ data.tar.gz: 50a6f0da185ed385affa0ae02273a432a3bb24bf2ac5cc40ba48cb58a4c37323e032066852d1b30e5b02116f084509bc5f61de6589151a9f52b8ec9008a53b3e
@@ -1,3 +1,3 @@
1
1
  module ForkingTestRunner
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -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.6.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: 2015-08-12 00:00:00.000000000 Z
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.2.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