forking_test_runner 1.8.0 → 1.9.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
  SHA256:
3
- metadata.gz: 4305afeb107804af380e5b6bcd47f2898f9eab13c278a0ceb7f9f0c38ef43e08
4
- data.tar.gz: 0cac2bb33fa7aa9e95773d954f2dd79525afde18820eddc61463f2d4e1f9f00a
3
+ metadata.gz: 33abc47d33141843b1d89ce17adee27897c64bc3445d9567845194aaa9f07224
4
+ data.tar.gz: a61958472117f965f21e354ce7f874f7ea920a76503589b5dd36e0a6f21eb7c7
5
5
  SHA512:
6
- metadata.gz: 5e61dd68b3d49db51c47b6c1634fb4868c0ba1da8abe04eef24c89729ea6286a96c1c1c7211270e57e4a3fa945b5be9ed0eb89662d9a1f1fbd7aaea30d0486a2
7
- data.tar.gz: 607c539c59aba33a07aa8cee7eafcd079326e9ca7c94cb6fd8e3b70fc2467e5a367a04b6166c3a3d8e86cd73185ef14a9068435d219f0cf77e3779b9b742fd5c
6
+ metadata.gz: 59f31396b4c6ccdce8cb625aebdea2b3f2a49c6e91983990f2b93e386c19f8e6ef94100d8ca0482a0e82cec2450fb1a5db1a47c42566749b69d7324543676c87
7
+ data.tar.gz: 32bbc0a83affacf06da8943e9a592152841ead2d7180aabe201031934d68705ac9e769c9c75b33b13b0a4b1587f6795fb38bbdb44c145f4e5c3de74bd698dab3
@@ -8,6 +8,7 @@ require 'tempfile'
8
8
 
9
9
  module ForkingTestRunner
10
10
  CLEAR = "------"
11
+ CONVERAGE_REPORT_PREFIX = "coverage/fork-"
11
12
 
12
13
  class << self
13
14
  def cli(argv)
@@ -79,6 +80,8 @@ module ForkingTestRunner
79
80
  record_test_runtime(mode, results, log)
80
81
  end
81
82
 
83
+ summarize_partial_reports if partial_reports_for_single_cov?
84
+
82
85
  # exit with success or failure
83
86
  success ? 0 : 1
84
87
  end
@@ -279,7 +282,10 @@ module ForkingTestRunner
279
282
  def run_test(file)
280
283
  stdout = change_program_name_to file do
281
284
  fork_with_captured_stdout do
282
- SimpleCov.pid = Process.pid if defined?(SimpleCov) && SimpleCov.respond_to?(:pid=) # trick simplecov into reporting in this fork
285
+ SimpleCov.pid = Process.pid if defined?(SimpleCov) && SimpleCov.respond_to?(:pid=) # make simplecov report in this fork
286
+ if partial_reports_for_single_cov?
287
+ SingleCov.coverage_report = "#{CONVERAGE_REPORT_PREFIX}#{Process.pid}.json"
288
+ end
283
289
  if active_record?
284
290
  key = (ActiveRecord::VERSION::STRING >= "4.1.0" ? :test : "test")
285
291
  ActiveRecord::Base.establish_connection key
@@ -291,6 +297,10 @@ module ForkingTestRunner
291
297
  [$?.success?, stdout]
292
298
  end
293
299
 
300
+ def partial_reports_for_single_cov?
301
+ @options.fetch(:merge_coverage) && defined?(SingleCov) && SingleCov.respond_to?(:coverage_report=) && SingleCov.coverage_report
302
+ end
303
+
294
304
  def change_program_name_to(name)
295
305
  return yield if @options.fetch(:parallel)
296
306
  begin
@@ -351,5 +361,25 @@ module ForkingTestRunner
351
361
  end
352
362
  end
353
363
  end
364
+
365
+ def summarize_partial_reports
366
+ reports = Dir.glob("#{CONVERAGE_REPORT_PREFIX}*")
367
+ return if reports.empty?
368
+
369
+ require "json" # not a global dependency
370
+ coverage = reports.each_with_object({}) do |report, all|
371
+ suites = JSON.parse(File.read(report), symbolize_names: true).values
372
+ raise "Unsupported number of suites #{suites.size}" if suites.size != 1
373
+ all.replace CoverageCapture.merge_coverage(all, suites.first.fetch(:coverage))
374
+ ensure
375
+ File.unlink(report) # do not leave junk behind
376
+ end
377
+
378
+ data = JSON.pretty_generate("Unit Tests" => {"coverage" => coverage, "timestamp" => Time.now.to_i })
379
+ File.write(SingleCov.coverage_report, data)
380
+
381
+ # make it not override our report when it finishes for main process
382
+ SingleCov.coverage_report = nil
383
+ end
354
384
  end
355
385
  end
@@ -1,3 +1,3 @@
1
1
  module ForkingTestRunner
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forking_test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 2.3.0
136
+ version: 2.5.0
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="