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 +4 -4
- data/lib/forking_test_runner.rb +31 -1
- data/lib/forking_test_runner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33abc47d33141843b1d89ce17adee27897c64bc3445d9567845194aaa9f07224
|
4
|
+
data.tar.gz: a61958472117f965f21e354ce7f874f7ea920a76503589b5dd36e0a6f21eb7c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59f31396b4c6ccdce8cb625aebdea2b3f2a49c6e91983990f2b93e386c19f8e6ef94100d8ca0482a0e82cec2450fb1a5db1a47c42566749b69d7324543676c87
|
7
|
+
data.tar.gz: 32bbc0a83affacf06da8943e9a592152841ead2d7180aabe201031934d68705ac9e769c9c75b33b13b0a4b1587f6795fb38bbdb44c145f4e5c3de74bd698dab3
|
data/lib/forking_test_runner.rb
CHANGED
@@ -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=) #
|
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
|
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.
|
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.
|
136
|
+
version: 2.5.0
|
137
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
139
|
- - ">="
|