danger-jacoco-instacart 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1abc0461e9b260a95c412ad877e45259ee557f26b9ed4de55eaa982cc84a0dad
4
- data.tar.gz: be45bc45af39819be0735aa3d9a5456118a317c597890da3145fb00cbabe6b2b
3
+ metadata.gz: 04b74ccc5974fdd122bb8909a71b541891e760d99f7cfd120c06d71c133c2b32
4
+ data.tar.gz: 9f8e75aa5cf7611307255edb1ae2119e81f5c7010700d324d1b7041cd7d5d275
5
5
  SHA512:
6
- metadata.gz: d2f3260792e92abff7de9d85f6cf67c6c93233b6b492937049167cf37a72f3e2dfc90dba09f8ba14da85e9a5991c8602c54439275c7c3b601026cbcd00b0afe3
7
- data.tar.gz: 84bbc4e0f01417de4dac8a1d2b2da1c07e65e69769828154fa1bda935ffc8639145e79132ea0bc12734ac01e3c72fbac78717dc18f55a232b5d9d63e8019a409
6
+ metadata.gz: da2bc98c6c2693be43e96012f0ac3b2000911fca7610fba47387046f908797eb49a4b2f04d505af4ddd359cae44703725c1216bf9716bb0cf62c58b20636dca5
7
+ data.tar.gz: 9f768d669d1eb720bf898ab9fbdfd6deb8fd68994a67ae490938eee2fd4c693dcfb0a06314b466fef6c9109424f037738171e77113546579986a1ca6dfce4266
data/.yardoc/checksums CHANGED
@@ -1,6 +1,6 @@
1
1
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_jacoco.rb 38229d934b3315bb2a5a4eec18eb65f3c54d304f
2
- /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb fcee9a884aa0707169357197da0ee6d6298be6fa
3
- /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb f1cb8c9c21dde323e5f7dd51b3f4387094361fcc
2
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb 1c81f68cb95296bfd592c1b57e0f2e6341f56b55
3
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb e99030c6a408c1bc77962b844d74c324daecad40
4
4
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/sax_parser.rb 370e2799f8dbdf7d642c820214e6ea84c30c9cb0
5
5
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/counter.rb 368f4a9811617b7a174ddf837a8fac49a4bc32a6
6
6
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/report.rb 7cf45ee71ff347a130320f6190ddb25525c7095d
data/.yardoc/object_types CHANGED
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jacoco
4
- VERSION = '0.1.12'
4
+ VERSION = '0.1.13'
5
5
  end
data/lib/jacoco/plugin.rb CHANGED
@@ -23,7 +23,7 @@ module Danger
23
23
  attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
24
24
  :minimum_composable_class_coverage_percentage, :only_check_new_files, :files_extension,
25
25
  :minimum_package_coverage_map, :minimum_class_coverage_map, :fail_no_coverage_data_found,
26
- :title, :class_column_title, :subtitle_success, :subtitle_failure
26
+ :title, :class_column_title, :subtitle_success, :subtitle_failure, :file_to_create_on_failure
27
27
 
28
28
  # Initialize the plugin with configured parameters or defaults
29
29
  def setup
@@ -31,6 +31,7 @@ module Danger
31
31
  setup_texts
32
32
  @only_check_new_files = false unless only_check_new_files
33
33
  @files_extension = ['.kt', '.java'] unless files_extension
34
+ @file_to_create_on_failure = 'danger_jacoco_failure_status_file.txt' unless file_to_create_on_failure
34
35
  end
35
36
 
36
37
  # Initialize the plugin with configured optional texts
@@ -231,14 +232,24 @@ module Danger
231
232
  # fail danger if total coverage is smaller than minimum_project_coverage_percentage
232
233
  covered = total_covered[:covered]
233
234
  fail("Total coverage of #{covered}%. Improve this to at least #{minimum_project_coverage_percentage}%")
235
+ # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
236
+ create_status_file_on_failure if class_coverage_above_minimum
237
+ # rubocop:enable Lint/UnreachableCode
234
238
  end
235
239
 
236
240
  return if class_coverage_above_minimum
237
241
 
238
242
  fail("Class coverage is below minimum. Improve to at least #{minimum_class_coverage_percentage}%")
243
+ # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
244
+ create_status_file_on_failure
245
+ # rubocop:enable Lint/UnreachableCode
239
246
  end
240
247
  # rubocop:enable Style/SignalException
241
248
 
249
+ def create_status_file_on_failure
250
+ File.open(file_to_create_on_failure, 'w') {}
251
+ end
252
+
242
253
  def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
243
254
  class_coverage_above_minimum = true
244
255
  parser.classes.each do |jacoco_class| # Check metrics for each classes
data/spec/jacoco_spec.rb CHANGED
@@ -25,6 +25,7 @@ module Danger
25
25
 
26
26
  allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
27
27
  allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
28
+ allow(File).to receive(:open).and_call_original
28
29
  end
29
30
 
30
31
  it :report do
@@ -43,6 +44,36 @@ module Danger
43
44
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
44
45
  end
45
46
 
47
+ it 'creates supplied status file upon failure' do
48
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
49
+
50
+ @my_plugin.minimum_project_coverage_percentage = 100
51
+ @my_plugin.minimum_class_coverage_percentage = 60
52
+ @my_plugin.file_to_create_on_failure = 'kmm.txt'
53
+
54
+ expect(File).to receive(:open).with('kmm.txt', 'w')
55
+ @my_plugin.report path_a
56
+ end
57
+
58
+ it 'creates default status file upon failure' do
59
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
60
+
61
+ @my_plugin.minimum_class_coverage_percentage = 60
62
+
63
+ expect(File).to receive(:open).with('danger_jacoco_failure_status_file.txt', 'w')
64
+ @my_plugin.report path_a
65
+ end
66
+
67
+ it 'does _not_ create status file upon success' do
68
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
69
+
70
+ @my_plugin.minimum_class_coverage_percentage = 40
71
+ @my_plugin.file_to_create_on_failure = 'kmm.txt'
72
+
73
+ expect(File).to_not receive(:open).with('kmm.txt', 'w')
74
+ @my_plugin.report path_a
75
+ end
76
+
46
77
  it 'test regex class coverage' do
47
78
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
48
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-jacoco-instacart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-07 00:00:00.000000000 Z
12
+ date: 2022-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: danger-plugin-api