single_cov 1.3.2 → 1.5.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: 8a086ee2f32cf635cc63929751ba9440fd473b9a5b6f6f5cae7e4546efd4db56
4
+ data.tar.gz: 7a8a8a4d601f53d79ed45b93e1eb7f06fc7b917fd01ffc41d7e3e02bf1f0825c
5
5
  SHA512:
6
- metadata.gz: 5daa193ee245aa4a55c49a5f5767286b5f0e1eb6a680f6977efe18eaaffa1867fd7c9fa941d4eafecb141995202a971df490fa4e6814b3662fc788c4509a939e
7
- data.tar.gz: fd0bbe8516e1bbf194886d87b38be3a5cf388d6afbecc796dbf6287a39778e81b251a44be890bd43ecc6f39ff8b93f246b272378430a7772b5cd06ee86274101
6
+ metadata.gz: ff29c57455d8fe0b7a16d14a58b5efb2d97a5cbbca25b03da77f322e4443e12e378f7ce5156770f5907f1db10a543907b5a0ea1d87950e2d05237edff9d28a2f
7
+ data.tar.gz: 16eb10a22563b11c53e67b5037ce0b5f6d867435844fd3f153f6cdb892ffe4a3a46c113e6732fc1895bbb6c6bd17e7d5c3666c636b24c23c78a48cfd1a46eae9
@@ -1,3 +1,3 @@
1
1
  module SingleCov
2
- VERSION = "1.3.2"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/single_cov.rb CHANGED
@@ -6,6 +6,12 @@ module SingleCov
6
6
  UNCOVERED_COMMENT_MARKER = "uncovered"
7
7
 
8
8
  class << self
9
+ # enable coverage reporting: location of output file, changed by forking-test-runner to combine multiple reports
10
+ attr_accessor :coverage_report
11
+
12
+ # emit only line coverage in coverage report for older coverage systems
13
+ attr_accessor :coverage_report_lines
14
+
9
15
  # optionally rewrite the file we guessed with a lambda
10
16
  def rewrite(&block)
11
17
  @rewrite = block
@@ -118,7 +124,11 @@ module SingleCov
118
124
  start_coverage_recording
119
125
 
120
126
  override_at_exit do |status, _exception|
121
- exit 1 if enabled? && main_process? && status == 0 && !SingleCov.all_covered?(coverage_results)
127
+ if enabled? && main_process? && status == 0
128
+ results = coverage_results
129
+ generate_report results
130
+ exit 1 unless SingleCov.all_covered?(results)
131
+ end
122
132
  end
123
133
  end
124
134
 
@@ -358,5 +368,27 @@ module SingleCov
358
368
  def root
359
369
  @root ||= (defined?(Bundler) && Bundler.root.to_s.sub(/\/gemfiles$/, '')) || Dir.pwd
360
370
  end
371
+
372
+ def generate_report(results)
373
+ return unless report = coverage_report
374
+
375
+ # not a hard dependency for the whole library
376
+ require "json"
377
+ require "fileutils"
378
+
379
+ used = COVERAGES.map { |f, _| "#{root}/#{f}" }
380
+ covered = results.select { |k, _| used.include?(k) }
381
+
382
+ if coverage_report_lines
383
+ covered = covered.each_with_object({}) { |(k, v), h| h[k] = v.is_a?(Hash) ? v.fetch(:lines) : v }
384
+ end
385
+
386
+ # chose "Minitest" because it is what simplecov uses for reports and "Unit Tests" makes sonarqube break
387
+ data = JSON.pretty_generate(
388
+ "Minitest" => {"coverage" => covered, "timestamp" => Time.now.to_i }
389
+ )
390
+ FileUtils.mkdir_p(File.dirname(report))
391
+ File.write report, data
392
+ end
361
393
  end
362
394
  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.5.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-26 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.