single_cov 1.3.2 → 1.4.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: 91538588abc7b40a632293cb64315edb846af54cee5b894925716c84b5209423
4
- data.tar.gz: 9e2cdd8fb800e72cd957eb80e29a631045aad84075d8c016b5e5ac40cec14829
3
+ metadata.gz: 6cd1fb991b879dcaf753d2aa30c4f94ac3f97659cf602df4f9adab874046c16f
4
+ data.tar.gz: c2351364b4482ceff98314b881fd5b774e9040c117479674b8fb41c0b550dac4
5
5
  SHA512:
6
- metadata.gz: 5daa193ee245aa4a55c49a5f5767286b5f0e1eb6a680f6977efe18eaaffa1867fd7c9fa941d4eafecb141995202a971df490fa4e6814b3662fc788c4509a939e
7
- data.tar.gz: fd0bbe8516e1bbf194886d87b38be3a5cf388d6afbecc796dbf6287a39778e81b251a44be890bd43ecc6f39ff8b93f246b272378430a7772b5cd06ee86274101
6
+ metadata.gz: 813924bc4aaad528db8afe9640178f3cfad2c11ffa4042573e4810a83cf941014e3d77352436b1c999330c70c066619054b88a3117e5d87885f95ce619dfaf2d
7
+ data.tar.gz: 31915f85ff52971fb4691f1fe52680c026b8f8e70c6b390b0c538e84ced5e59b035803130f09d5df03f4eba7731608c46f02ba28df366506322559495baf588d
@@ -6,6 +6,9 @@ module SingleCov
6
6
  UNCOVERED_COMMENT_MARKER = "uncovered"
7
7
 
8
8
  class << self
9
+ # enable coverage reporting, changed by forking-test-runner to combine multiple reports
10
+ attr_accessor :coverage_report
11
+
9
12
  # optionally rewrite the file we guessed with a lambda
10
13
  def rewrite(&block)
11
14
  @rewrite = block
@@ -118,7 +121,11 @@ module SingleCov
118
121
  start_coverage_recording
119
122
 
120
123
  override_at_exit do |status, _exception|
121
- exit 1 if enabled? && main_process? && status == 0 && !SingleCov.all_covered?(coverage_results)
124
+ if enabled? && main_process? && status == 0
125
+ results = coverage_results
126
+ generate_report results
127
+ exit 1 unless SingleCov.all_covered?(results)
128
+ end
122
129
  end
123
130
  end
124
131
 
@@ -358,5 +365,21 @@ module SingleCov
358
365
  def root
359
366
  @root ||= (defined?(Bundler) && Bundler.root.to_s.sub(/\/gemfiles$/, '')) || Dir.pwd
360
367
  end
368
+
369
+ def generate_report(results)
370
+ return unless report = coverage_report
371
+
372
+ # not a hard dependency for the whole library
373
+ require "json"
374
+ require "fileutils"
375
+
376
+ used = COVERAGES.map { |f, _| "#{root}/#{f}" }
377
+ covered = results.select { |k, _| used.include?(k) }
378
+ data = JSON.pretty_generate(
379
+ "Unit Tests" => {"coverage" => covered, "timestamp" => Time.now.to_i }
380
+ )
381
+ FileUtils.mkdir_p(File.dirname(report))
382
+ File.write report, data
383
+ end
361
384
  end
362
385
  end
@@ -1,3 +1,3 @@
1
1
  module SingleCov
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_cov
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.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: 2019-05-09 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it
@@ -38,8 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.7.6
41
+ rubygems_version: 3.1.3
43
42
  signing_key:
44
43
  specification_version: 4
45
44
  summary: Actionable code coverage.