forking_test_runner 1.7.0 → 1.12.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 +38 -2
- data/lib/forking_test_runner/cli.rb +1 -1
- data/lib/forking_test_runner/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be87df3e12024204491610717130bc0b71a3b7fc02d6a60c82da34ebedbf74c6
|
4
|
+
data.tar.gz: 4e6fb9c449dc7e00c46e39fdbc7686bcfe0bf1df439c800e78767950a517f6c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 323f765b32f2ed37f62a82dfff10b6bdc7c0c8670a441f340f2a910d8dfb17a9660726698b8c34dfb89522246003e8c7fde4a205d17b8511c3ec432027604a65
|
7
|
+
data.tar.gz: ad243eb959c09b3bac8d58da961adec4c34b92844b239da2e541d599e2f1b78d738bdc3cc5db7b44c4817e18aa99be86d5adb74bac2e5614c01b57c027a0b562
|
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
|
@@ -250,7 +253,7 @@ module ForkingTestRunner
|
|
250
253
|
def fork_with_captured_stdout
|
251
254
|
rpipe, wpipe = IO.pipe
|
252
255
|
|
253
|
-
child = fork do
|
256
|
+
child = Process.fork do
|
254
257
|
rpipe.close
|
255
258
|
preserve_tty { $stdout.reopen(wpipe) }
|
256
259
|
yield
|
@@ -279,7 +282,13 @@ 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
|
-
|
285
|
+
if defined?(SimpleCov)
|
286
|
+
SimpleCov.pid = Process.pid
|
287
|
+
SimpleCov.command_name file
|
288
|
+
end
|
289
|
+
if partial_reports_for_single_cov?
|
290
|
+
SingleCov.coverage_report = "#{CONVERAGE_REPORT_PREFIX}#{Process.pid}.json"
|
291
|
+
end
|
283
292
|
if active_record?
|
284
293
|
key = (ActiveRecord::VERSION::STRING >= "4.1.0" ? :test : "test")
|
285
294
|
ActiveRecord::Base.establish_connection key
|
@@ -291,6 +300,10 @@ module ForkingTestRunner
|
|
291
300
|
[$?.success?, stdout]
|
292
301
|
end
|
293
302
|
|
303
|
+
def partial_reports_for_single_cov?
|
304
|
+
@options.fetch(:merge_coverage) && defined?(SingleCov) && SingleCov.respond_to?(:coverage_report=) && SingleCov.coverage_report
|
305
|
+
end
|
306
|
+
|
294
307
|
def change_program_name_to(name)
|
295
308
|
return yield if @options.fetch(:parallel)
|
296
309
|
begin
|
@@ -351,5 +364,28 @@ module ForkingTestRunner
|
|
351
364
|
end
|
352
365
|
end
|
353
366
|
end
|
367
|
+
|
368
|
+
def summarize_partial_reports
|
369
|
+
reports = Dir.glob("#{CONVERAGE_REPORT_PREFIX}*")
|
370
|
+
return if reports.empty?
|
371
|
+
key = nil
|
372
|
+
|
373
|
+
require "json" # not a global dependency
|
374
|
+
coverage = reports.each_with_object({}) do |report, all|
|
375
|
+
data = JSON.parse(File.read(report), symbolize_names: true)
|
376
|
+
key ||= data.keys.first
|
377
|
+
suites = data.values
|
378
|
+
raise "Unsupported number of suites #{suites.size}" if suites.size != 1
|
379
|
+
all.replace CoverageCapture.merge_coverage(all, suites.first.fetch(:coverage))
|
380
|
+
ensure
|
381
|
+
File.unlink(report) # do not leave junk behind
|
382
|
+
end
|
383
|
+
|
384
|
+
data = JSON.pretty_generate(key => {"coverage" => coverage, "timestamp" => Time.now.to_i })
|
385
|
+
File.write(SingleCov.coverage_report, data)
|
386
|
+
|
387
|
+
# make it not override our report when it finishes for main process
|
388
|
+
SingleCov.coverage_report = nil
|
389
|
+
end
|
354
390
|
end
|
355
391
|
end
|
@@ -7,7 +7,7 @@ module ForkingTestRunner
|
|
7
7
|
[:quiet, "--quiet", "Quiet"],
|
8
8
|
[:no_fixtures, "--no-fixtures", "Do not load fixtures"],
|
9
9
|
[:no_ar, "--no-ar", "Disable ActiveRecord logic"],
|
10
|
-
[:merge_coverage, "--merge-coverage", "Merge base code coverage into
|
10
|
+
[:merge_coverage, "--merge-coverage", "Merge base code coverage into individual files coverage and summarize coverage report"],
|
11
11
|
[
|
12
12
|
:record_runtime,
|
13
13
|
"--record-runtime=MODE",
|
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: 1.
|
4
|
+
version: 1.12.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: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.3.7
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: wwtd
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bump
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,14 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
119
|
requirements:
|
134
120
|
- - ">="
|
135
121
|
- !ruby/object:Gem::Version
|
136
|
-
version: 2.
|
122
|
+
version: 2.5.0
|
137
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
124
|
requirements:
|
139
125
|
- - ">="
|
140
126
|
- !ruby/object:Gem::Version
|
141
127
|
version: '0'
|
142
128
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.2.16
|
144
130
|
signing_key:
|
145
131
|
specification_version: 4
|
146
132
|
summary: Run every test in a fork to avoid pollution and get clean output per test
|