slather 2.4.8 → 2.4.9

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: 24ee530494c9f131751a85dba16a4bc09292c187d045be17b1212d9cf4038378
4
- data.tar.gz: 4c5dabc3de752ebb88998ca29d87d6f072e4477a909926d4237078a2a9f73bc2
3
+ metadata.gz: 1e8bb7fa0d1346a2a81a47272a1f55d2625a8457d8c4b88a82f2b737792aa39a
4
+ data.tar.gz: a375044a21453e30695adf31c20f5a9ea885091d1eb3ac6fafc3f3ef9d44d752
5
5
  SHA512:
6
- metadata.gz: b7d4a1db210237adec6b9c03634774991a209c4aa64c10dea0a73208642298082b9a76f9c0e979b68a4601c6c9ff37f92d6f05bfd3c8a35429bd78cc8ac9549c
7
- data.tar.gz: 9bf87cccabbd4b243e8ba9c519d491818a38924125694ca8701b3b34764a8c9ae167919b764638fa0af27b137dbbf10d9188b3e6297f93f3d1673ec07566d817
6
+ metadata.gz: 9a9dddfd5dcf8160cd31327f170030f3520c2a885b7c56f6f2d7d470e5442b8c49c3f30ba289664767cc43d597415c2309654699a5ac2fd59db90ac5bc796697
7
+ data.tar.gz: 5f67d766eb09e18df9a2bf1016f49a3a7a7f912be2bf5e05ed31c925540fb51ccaef34e53f1dffaed6aadfef827a3e69aa1c7144fa30a024f9f72a1ce2d47605
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.4.9
4
+
5
+ * Added support for Sonarqube output
6
+ [adellibovi](https://github.com/adellibovi)
7
+ [#456](https://github.com/SlatherOrg/slather/pull/456)
8
+
3
9
  ## v2.4.8
4
10
 
5
11
  * Optimize performance for many binaries
@@ -12,6 +12,7 @@ require 'slather/coverage_service/simple_output'
12
12
  require 'slather/coverage_service/html_output'
13
13
  require 'slather/coverage_service/json_output'
14
14
  require 'slather/coverage_service/llvm_cov_output'
15
+ require 'slather/coverage_service/sonarqube_xml_output'
15
16
  require 'cfpropertylist'
16
17
 
17
18
  module Slather
@@ -13,6 +13,7 @@ class CoverageCommand < Clamp::Command
13
13
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
14
14
  option ["--gutter-json", "-g"], :flag, "Output coverage results as Gutter JSON format"
15
15
  option ["--cobertura-xml", "-x"], :flag, "Output coverage results as Cobertura XML format"
16
+ option ["--sonarqube-xml", "-sq"], :flag, "Output coverage results as Cobertura XML format"
16
17
  option ["--llvm-cov", "-r"], :flag, "Output coverage as llvm-cov format"
17
18
  option ["--json"], :flag, "Output coverage results as simple JSON"
18
19
  option ["--html"], :flag, "Output coverage results as static html pages"
@@ -124,6 +125,8 @@ class CoverageCommand < Clamp::Command
124
125
  project.show_html = show?
125
126
  elsif json?
126
127
  project.coverage_service = :json
128
+ elsif sonarqube_xml?
129
+ project.coverage_service = :sonarqube_xml
127
130
  end
128
131
  end
129
132
 
@@ -0,0 +1,61 @@
1
+ require 'nokogiri'
2
+ require 'date'
3
+
4
+ module Slather
5
+ module CoverageService
6
+ module SonarqubeXmlOutput
7
+
8
+ def coverage_file_class
9
+ if input_format == "profdata"
10
+ Slather::ProfdataCoverageFile
11
+ else
12
+ Slather::CoverageFile
13
+ end
14
+ end
15
+ private :coverage_file_class
16
+
17
+ def post
18
+ cobertura_xml_report = create_xml_report(coverage_files)
19
+ store_report(cobertura_xml_report)
20
+ end
21
+
22
+ def store_report(report)
23
+ output_file = 'sonarqube-generic-coverage.xml'
24
+ if output_directory
25
+ FileUtils.mkdir_p(output_directory)
26
+ output_file = File.join(output_directory, output_file)
27
+ end
28
+ File.write(output_file, report.to_s)
29
+ end
30
+
31
+ def create_xml_report(coverage_files)
32
+ create_empty_xml_report
33
+ coverage_node = @doc.root
34
+ coverage_node['version'] = "1"
35
+
36
+ coverage_files.each do |coverage_file|
37
+ file_node = Nokogiri::XML::Node.new "file", @doc
38
+ file_node.parent = coverage_node
39
+ file_node['path'] = coverage_file.source_file_pathname_relative_to_repo_root.to_s
40
+ coverage_file.all_lines.each do |line|
41
+ if coverage_file.coverage_for_line(line)
42
+ line_node = Nokogiri::XML::Node.new "lineToCover", @doc
43
+ line_node['lineNumber'] = coverage_file.line_number_in_line(line)
44
+ line_node['covered'] = coverage_file.coverage_for_line(line) == 0 ? "false" : "true"
45
+ line_node.parent = file_node
46
+ end
47
+ end
48
+ end
49
+ @doc.to_xml
50
+ end
51
+
52
+ def create_empty_xml_report
53
+ builder = Nokogiri::XML::Builder.new do |xml|
54
+ xml.coverage
55
+ end
56
+ @doc = builder.doc
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -424,6 +424,8 @@ module Slather
424
424
  extend(Slather::CoverageService::HtmlOutput)
425
425
  when :json
426
426
  extend(Slather::CoverageService::JsonOutput)
427
+ when :sonarqube_xml
428
+ extend(Slather::CoverageService::SonarqubeXmlOutput)
427
429
  else
428
430
  raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal`, `coveralls`, `gutter_json`, `cobertura_xml` or `html`"
429
431
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = '2.4.8' unless defined?(Slather::VERSION)
2
+ VERSION = '2.4.9' unless defined?(Slather::VERSION)
3
3
  end
@@ -0,0 +1,93 @@
1
+ <?xml version="1.0"?>
2
+ <coverage version="1">
3
+ <file path="spec/fixtures/fixtures/fixtures.m">
4
+ <lineToCover lineNumber="14" covered="true"/>
5
+ <lineToCover lineNumber="15" covered="true"/>
6
+ <lineToCover lineNumber="16" covered="true"/>
7
+ <lineToCover lineNumber="19" covered="false"/>
8
+ <lineToCover lineNumber="20" covered="false"/>
9
+ <lineToCover lineNumber="21" covered="false"/>
10
+ </file>
11
+ <file path="spec/fixtures/fixtures/more_files/Branches.m">
12
+ <lineToCover lineNumber="14" covered="true"/>
13
+ <lineToCover lineNumber="15" covered="true"/>
14
+ <lineToCover lineNumber="16" covered="true"/>
15
+ <lineToCover lineNumber="17" covered="true"/>
16
+ <lineToCover lineNumber="18" covered="true"/>
17
+ <lineToCover lineNumber="19" covered="false"/>
18
+ <lineToCover lineNumber="20" covered="false"/>
19
+ <lineToCover lineNumber="21" covered="true"/>
20
+ <lineToCover lineNumber="22" covered="true"/>
21
+ <lineToCover lineNumber="23" covered="true"/>
22
+ <lineToCover lineNumber="24" covered="true"/>
23
+ <lineToCover lineNumber="25" covered="true"/>
24
+ <lineToCover lineNumber="26" covered="true"/>
25
+ <lineToCover lineNumber="27" covered="true"/>
26
+ <lineToCover lineNumber="28" covered="true"/>
27
+ <lineToCover lineNumber="29" covered="false"/>
28
+ <lineToCover lineNumber="30" covered="false"/>
29
+ <lineToCover lineNumber="31" covered="false"/>
30
+ <lineToCover lineNumber="32" covered="false"/>
31
+ <lineToCover lineNumber="33" covered="false"/>
32
+ <lineToCover lineNumber="34" covered="false"/>
33
+ <lineToCover lineNumber="35" covered="false"/>
34
+ <lineToCover lineNumber="36" covered="false"/>
35
+ <lineToCover lineNumber="37" covered="false"/>
36
+ <lineToCover lineNumber="38" covered="false"/>
37
+ <lineToCover lineNumber="39" covered="false"/>
38
+ <lineToCover lineNumber="40" covered="false"/>
39
+ <lineToCover lineNumber="41" covered="false"/>
40
+ <lineToCover lineNumber="42" covered="false"/>
41
+ <lineToCover lineNumber="43" covered="false"/>
42
+ </file>
43
+ <file path="spec/fixtures/fixturesTests/BranchesTests.m">
44
+ <lineToCover lineNumber="18" covered="true"/>
45
+ <lineToCover lineNumber="19" covered="true"/>
46
+ <lineToCover lineNumber="20" covered="true"/>
47
+ <lineToCover lineNumber="21" covered="true"/>
48
+ <lineToCover lineNumber="23" covered="true"/>
49
+ <lineToCover lineNumber="24" covered="true"/>
50
+ <lineToCover lineNumber="25" covered="true"/>
51
+ <lineToCover lineNumber="26" covered="true"/>
52
+ <lineToCover lineNumber="28" covered="true"/>
53
+ <lineToCover lineNumber="29" covered="true"/>
54
+ <lineToCover lineNumber="30" covered="true"/>
55
+ <lineToCover lineNumber="31" covered="true"/>
56
+ <lineToCover lineNumber="33" covered="true"/>
57
+ <lineToCover lineNumber="34" covered="true"/>
58
+ <lineToCover lineNumber="35" covered="true"/>
59
+ <lineToCover lineNumber="36" covered="true"/>
60
+ </file>
61
+ <file path="spec/fixtures/fixturesTests/fixturesTests.m">
62
+ <lineToCover lineNumber="20" covered="true"/>
63
+ <lineToCover lineNumber="21" covered="true"/>
64
+ <lineToCover lineNumber="22" covered="true"/>
65
+ <lineToCover lineNumber="23" covered="true"/>
66
+ <lineToCover lineNumber="26" covered="true"/>
67
+ <lineToCover lineNumber="27" covered="true"/>
68
+ <lineToCover lineNumber="28" covered="true"/>
69
+ <lineToCover lineNumber="29" covered="true"/>
70
+ <lineToCover lineNumber="32" covered="true"/>
71
+ <lineToCover lineNumber="33" covered="true"/>
72
+ <lineToCover lineNumber="34" covered="true"/>
73
+ <lineToCover lineNumber="35" covered="true"/>
74
+ <lineToCover lineNumber="38" covered="true"/>
75
+ <lineToCover lineNumber="39" covered="true"/>
76
+ <lineToCover lineNumber="40" covered="true"/>
77
+ <lineToCover lineNumber="41" covered="true"/>
78
+ <lineToCover lineNumber="42" covered="true"/>
79
+ </file>
80
+ <file path="spec/fixtures/fixturesTests/peekaviewTests&#x1F4A3;.m">
81
+ <lineToCover lineNumber="18" covered="true"/>
82
+ <lineToCover lineNumber="19" covered="true"/>
83
+ <lineToCover lineNumber="20" covered="true"/>
84
+ <lineToCover lineNumber="21" covered="true"/>
85
+ <lineToCover lineNumber="24" covered="true"/>
86
+ <lineToCover lineNumber="25" covered="true"/>
87
+ <lineToCover lineNumber="26" covered="true"/>
88
+ <lineToCover lineNumber="27" covered="true"/>
89
+ <lineToCover lineNumber="30" covered="true"/>
90
+ <lineToCover lineNumber="31" covered="true"/>
91
+ <lineToCover lineNumber="32" covered="true"/>
92
+ </file>
93
+ </coverage>
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+ require 'json'
3
+
4
+ describe Slather::CoverageService::SonarqubeXmlOutput do
5
+
6
+ let(:fixtures_project) do
7
+ proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
8
+ proj.build_directory = TEMP_DERIVED_DATA_PATH
9
+ proj.input_format = "profdata"
10
+ proj.coverage_service = "sonarqube_xml"
11
+ proj.configure
12
+ proj
13
+ end
14
+
15
+ describe '#coverage_file_class' do
16
+ it "should return CoverageFile" do
17
+ expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
18
+ end
19
+ end
20
+
21
+ describe '#post' do
22
+ it "should create an XML report spanning all coverage files" do
23
+ fixtures_project.post
24
+
25
+ file = File.open(FIXTURES_SONARQUBE_XML_PATH)
26
+ fixture_xml_doc = Nokogiri::XML(file)
27
+ file.close
28
+
29
+ file = File.open('sonarqube-generic-coverage.xml')
30
+ current_xml_doc = Nokogiri::XML(file)
31
+ file.close
32
+
33
+ expect(EquivalentXml.equivalent?(current_xml_doc, fixture_xml_doc)).to be_truthy
34
+ end
35
+
36
+ it "should create an XML report in the given output directory" do
37
+ fixtures_project.output_directory = "./output"
38
+ fixtures_project.post
39
+
40
+ filepath = "#{fixtures_project.output_directory}/sonarqube-generic-coverage.xml"
41
+ expect(File.exists?(filepath)).to be_truthy
42
+
43
+ FileUtils.rm_rf(fixtures_project.output_directory)
44
+ end
45
+ end
46
+ end
@@ -13,6 +13,7 @@ require 'equivalent-xml'
13
13
 
14
14
 
15
15
  FIXTURES_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/cobertura.xml')
16
+ FIXTURES_SONARQUBE_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/sonarqube-generic-coverage.xml')
16
17
  FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/report.json')
17
18
  FIXTURES_LLCOV_PATH = File.join(File.dirname(__FILE__), 'fixtures/report.llcov')
18
19
  FIXTURES_GUTTER_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.8
4
+ version: 2.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-23 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -255,6 +255,7 @@ files:
255
255
  - lib/slather/coverage_service/json_output.rb
256
256
  - lib/slather/coverage_service/llvm_cov_output.rb
257
257
  - lib/slather/coverage_service/simple_output.rb
258
+ - lib/slather/coverage_service/sonarqube_xml_output.rb
258
259
  - lib/slather/coveralls_coverage.rb
259
260
  - lib/slather/profdata_coverage_file.rb
260
261
  - lib/slather/project.rb
@@ -304,6 +305,7 @@ files:
304
305
  - spec/fixtures/gutter.json
305
306
  - spec/fixtures/report.json
306
307
  - spec/fixtures/report.llcov
308
+ - spec/fixtures/sonarqube-generic-coverage.xml
307
309
  - spec/slather/cocoapods_plugin_spec.rb
308
310
  - spec/slather/coverage_file_spec.rb
309
311
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -314,6 +316,7 @@ files:
314
316
  - spec/slather/coverage_service/json_spec.rb
315
317
  - spec/slather/coverage_service/llvm_cov_spec.rb
316
318
  - spec/slather/coverage_service/simple_output_spec.rb
319
+ - spec/slather/coverage_service/sonarqube_xml_spec.rb
317
320
  - spec/slather/fixtures.gcno
318
321
  - spec/slather/profdata_coverage_spec.rb
319
322
  - spec/slather/project_spec.rb
@@ -337,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
340
  - !ruby/object:Gem::Version
338
341
  version: '0'
339
342
  requirements: []
340
- rubygems_version: 3.1.2
343
+ rubygems_version: 3.1.3
341
344
  signing_key:
342
345
  specification_version: 4
343
346
  summary: Test coverage reports for Xcode projects
@@ -386,6 +389,7 @@ test_files:
386
389
  - spec/fixtures/gutter.json
387
390
  - spec/fixtures/report.json
388
391
  - spec/fixtures/report.llcov
392
+ - spec/fixtures/sonarqube-generic-coverage.xml
389
393
  - spec/slather/cocoapods_plugin_spec.rb
390
394
  - spec/slather/coverage_file_spec.rb
391
395
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -396,6 +400,7 @@ test_files:
396
400
  - spec/slather/coverage_service/json_spec.rb
397
401
  - spec/slather/coverage_service/llvm_cov_spec.rb
398
402
  - spec/slather/coverage_service/simple_output_spec.rb
403
+ - spec/slather/coverage_service/sonarqube_xml_spec.rb
399
404
  - spec/slather/fixtures.gcno
400
405
  - spec/slather/profdata_coverage_spec.rb
401
406
  - spec/slather/project_spec.rb