slather 2.4.7 → 2.6.1

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: b96a2924692977293e43094ff06f13424436d3e52c4703d7827753164043d65b
4
- data.tar.gz: 813bb754172204b270f51b2e8548506163a7d38eddd8c8f69899bf0b5b6c789e
3
+ metadata.gz: 65797ce8dfbfe5637c983ce35e07296cf3948e054b84db165536643e6fa7bd2f
4
+ data.tar.gz: 77ee9800d1f2845739563b06932037409499b07c9d7524a1e15e8c709453aeda
5
5
  SHA512:
6
- metadata.gz: 11206bb710d0fbcdc70970113c18c250e94c009ee99b85d8b8fbc655dcd10f1d88d42c7fa29a67cad3e9b07a09ebb4b1866af70f21b54944aeeb898ddc52ffca
7
- data.tar.gz: 7f0b18beaacafa3e38eaded6df28747619570f6d0a67a4546465485bfcddfcb152543185782703cd32814cd38b86dfb3f68c49876a13a9642eb02f7ae96cb224
6
+ metadata.gz: 9e14157b010048c0d03876f2aed5107821e2c533ddc0b48e1eaa8cc5e177c7346b23d92c0fa6c4b0393c63c921036f8e65f2574374aa6c655bf4c1ff79dffe2b
7
+ data.tar.gz: 51d9746ef872aa49cf26ad6b03e78d61d6a4e99a87551f54f99bee6714ce4401002fe83ccf609a86233f50560b4e181ee8412fb122bf59f026a184a3289a75d3
data/.gitignore CHANGED
@@ -46,4 +46,8 @@ html
46
46
  *.gcno
47
47
 
48
48
  # JetBrains IDE
49
- .idea/
49
+ .idea/
50
+
51
+ # Test output
52
+ report.llcov
53
+ report.json
@@ -1,10 +1,10 @@
1
1
  language: objective-c
2
2
  script: bundle exec rake
3
- osx_image: xcode9.2
3
+ osx_image: xcode12.2
4
4
 
5
5
  before_install:
6
6
  - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
7
- - gem install bundler -v "~> 1.0" --no-ri --no-rdoc
7
+ - gem install bundler -v "~> 2.0" --no-document
8
8
 
9
9
  install:
10
10
  - bundle install --without=documentation
@@ -1,5 +1,47 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.6.1
4
+
5
+ * Update nokogiri to 1.11
6
+ [ashin-omg](https://github.com/ashin-omg)
7
+ [#473](https://github.com/SlatherOrg/slather/pull/473)
8
+
9
+ ## v2.6.0
10
+
11
+ * Added GitHub actions support
12
+ [martin-key](https://github.com/martin-key), [troyfontaine](https://github.com/troyfontaine)
13
+ [#468](https://github.com/SlatherOrg/slather/pull/468)
14
+
15
+ ## v2.5.0
16
+
17
+ * Fixed activesupport and cocoapods dependencies
18
+ [daneov](https://github.com/daneov)
19
+ [#456](https://github.com/SlatherOrg/slather/pull/467)
20
+
21
+ * Fixed typo in documentation
22
+ [descorp](https://github.com/descorp)
23
+ [#456](https://github.com/SlatherOrg/slather/pull/463)
24
+
25
+ ## v2.4.9
26
+
27
+ * Added support for Sonarqube output
28
+ [adellibovi](https://github.com/adellibovi)
29
+ [#456](https://github.com/SlatherOrg/slather/pull/456)
30
+
31
+ ## v2.4.8
32
+
33
+ * Optimize performance for many binaries
34
+ [cltnschlosser](https://github.com/cltnschlosser)
35
+ [#455](https://github.com/SlatherOrg/slather/pull/455)
36
+
37
+ * Don't generate line 0 in profdata_coverage_file.rb from line with error
38
+ [tthbalazs](https://github.com/tthbalazs)
39
+ [#449](https://github.com/SlatherOrg/slather/pull/449)
40
+
41
+ * coveralls dependency update
42
+ [GRiMe2D](https://github.com/GRiMe2D)
43
+ [#448](https://github.com/SlatherOrg/slather/pull/448)
44
+
3
45
  ## v2.4.7
4
46
 
5
47
  * Update dependencies
data/README.md CHANGED
@@ -67,6 +67,20 @@ If your configuration produces a universal binary you need to specify a specific
67
67
  $ slather coverage -s --arch x86_64 --scheme YourXcodeSchemeName --configuration YourBuildConfigurationName path/to/project.xcodeproj
68
68
  ```
69
69
 
70
+ ### For multiple modules
71
+
72
+ If you want to run some modules, but not all (like modules created by CocoaPods) you can do it like this:
73
+
74
+ ```sh
75
+ $ slather coverage --binary-basename module1 --binary-basename module2 path/to/project.xcodeproj
76
+ ```
77
+ You can also add it to the `.slather.yml` file as an array:
78
+ ```yml
79
+ binary_basename:
80
+ - module1
81
+ - module2
82
+ ```
83
+
70
84
  ### Setup for Xcode 5 and 6
71
85
 
72
86
  Run this command to enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project:
@@ -135,7 +149,7 @@ ignore:
135
149
  - ProjectTestsGroup/*
136
150
  ```
137
151
 
138
- And then in your `.travis.yml` or `circle.yml`, call `slather` after a successful build:
152
+ And then in your `.travis.yml` or `circle.yml` or `github-action.yml`, call `slather` after a successful build:
139
153
 
140
154
  ```yml
141
155
  # .travis.yml
@@ -154,6 +168,25 @@ test:
154
168
 
155
169
  ```
156
170
 
171
+ ```yml
172
+ # github-action.yml
173
+ myjob:
174
+ steps:
175
+ - run: |
176
+ bundle config path vendor/bundle
177
+ bundle install --without=documentation --jobs 4 --retry 3
178
+ - name: Extract branch name
179
+ shell: bash
180
+ run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
181
+ id: get_branch
182
+ - run: bundle exec slather
183
+ env:
184
+ GIT_BRANCH: ${{ steps.get_branch.outputs.branch }}
185
+ CI_PULL_REQUEST: ${{ github.event.number }}
186
+ COVERAGE_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187
+
188
+ ```
189
+
157
190
  #### Usage with Travis CI Pro
158
191
 
159
192
  To use Coveralls with Travis CI Pro (for private repos), add following lines along with other settings to `.slather.yml`:
@@ -251,3 +284,4 @@ Please make sure to follow our general coding style and add test coverage for ne
251
284
  * [@jhersh](https://github.com/jhersh), CircleCI support.
252
285
  * [@tarbrain](https://github.com/tarbrain), Cobertura support and bugfixing.
253
286
  * [@ikhsan](https://github.com/ikhsan), html support.
287
+ * [@martin-key](https://github.com/martin-key) and [@troyfontaine](https://github.com/troyfontaine), Github Actions support.
@@ -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
@@ -8,11 +8,13 @@ class CoverageCommand < Clamp::Command
8
8
  option ["--jenkins"], :flag, "Indicate that the builds are running on Jenkins"
9
9
  option ["--buildkite"], :flag, "Indicate that the builds are running on Buildkite"
10
10
  option ["--teamcity"], :flag, "Indicate that the builds are running on TeamCity"
11
+ option ["--github"], :flag, "Indicate that the builds are running on Github Actions"
11
12
 
12
13
  option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
13
14
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
14
15
  option ["--gutter-json", "-g"], :flag, "Output coverage results as Gutter JSON format"
15
16
  option ["--cobertura-xml", "-x"], :flag, "Output coverage results as Cobertura XML format"
17
+ option ["--sonarqube-xml", "-sq"], :flag, "Output coverage results as SonarQube XML format"
16
18
  option ["--llvm-cov", "-r"], :flag, "Output coverage as llvm-cov format"
17
19
  option ["--json"], :flag, "Output coverage results as simple JSON"
18
20
  option ["--html"], :flag, "Output coverage results as static html pages"
@@ -90,6 +92,8 @@ class CoverageCommand < Clamp::Command
90
92
  project.ci_service = :buildkite
91
93
  elsif teamcity?
92
94
  project.ci_service = :teamcity
95
+ elsif github?
96
+ project.ci_service = :github
93
97
  end
94
98
  end
95
99
 
@@ -124,6 +128,8 @@ class CoverageCommand < Clamp::Command
124
128
  project.show_html = show?
125
129
  elsif json?
126
130
  project.coverage_service = :json
131
+ elsif sonarqube_xml?
132
+ project.coverage_service = :sonarqube_xml
127
133
  end
128
134
  end
129
135
 
@@ -43,18 +43,23 @@ module Slather
43
43
 
44
44
  def gcov_data
45
45
  @gcov_data ||= begin
46
- gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
47
- # Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
48
- gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)
46
+ gcov_data = ""
47
+
48
+ Dir.chdir(project.project_dir) do
49
+ gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
50
+ # Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
51
+ gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)
52
+
53
+ gcov_file_name = "./#{source_file_pathname.basename}.gcov"
54
+ if File.exists?(gcov_file_name)
55
+ gcov_data = File.new(gcov_file_name).read
56
+ else
57
+ gcov_data = ""
58
+ end
49
59
 
50
- gcov_file_name = "./#{source_file_pathname.basename}.gcov"
51
- if File.exists?(gcov_file_name)
52
- gcov_data = File.new(gcov_file_name).read
53
- else
54
- gcov_data = ""
60
+ gcov_files_created.each { |file| FileUtils.rm_f(file) }
55
61
  end
56
62
 
57
- gcov_files_created.each { |file| FileUtils.rm_f(file) }
58
63
  gcov_data
59
64
  end
60
65
  end
@@ -36,6 +36,21 @@ module Slather
36
36
  end
37
37
  private :jenkins_job_id
38
38
 
39
+ def github_job_id
40
+ ENV['GITHUB_RUN_ID']
41
+ end
42
+ private :github_job_id
43
+
44
+ def github_pull_request
45
+ ENV['CI_PULL_REQUEST'] || ""
46
+ end
47
+ private :github_pull_request
48
+
49
+ def github_repo_name
50
+ ENV['GITHUB_REPOSITORY'] || ""
51
+ end
52
+ private :github_repo_name
53
+
39
54
  def jenkins_branch_name
40
55
  branch_name = ENV['GIT_BRANCH'] || ENV['BRANCH_NAME']
41
56
  if branch_name.include? 'origin/'
@@ -51,6 +66,11 @@ module Slather
51
66
  end
52
67
  private :teamcity_branch_name
53
68
 
69
+ def github_branch_name
70
+ ENV['GIT_BRANCH'] || `git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3-`.chomp
71
+ end
72
+ private :github_branch_name
73
+
54
74
  def buildkite_job_id
55
75
  ENV['BUILDKITE_BUILD_NUMBER']
56
76
  end
@@ -119,6 +139,23 @@ module Slather
119
139
  "https://buildkite.com/" + ENV['BUILDKITE_PROJECT_SLUG'] + "/builds/" + ENV['BUILDKITE_BUILD_NUMBER'] + "#"
120
140
  end
121
141
 
142
+ def github_git_info
143
+ {
144
+ :head => {
145
+ :id => ENV['GITHUB_SHA'],
146
+ :author_name => ENV['GITHUB_ACTOR'],
147
+ :message => (`git log --format=%s -n 1 HEAD`.chomp || "")
148
+ },
149
+ :branch => github_branch_name
150
+ }
151
+ end
152
+ private :github_git_info
153
+
154
+ def github_build_url
155
+ "https://github.com/" + ENV['GITHUB_REPOSITORY'] + "/actions/runs/" + ENV['GITHUB_RUN_ID']
156
+ end
157
+ private :github_build_url
158
+
122
159
  def coveralls_coverage_data
123
160
  if ci_service == :travis_ci || ci_service == :travis_pro
124
161
  if travis_job_id
@@ -206,6 +243,26 @@ module Slather
206
243
  else
207
244
  raise StandardError, "Environment variable `TC_BUILD_NUMBER` not set. Is this running on a teamcity build?"
208
245
  end
246
+ elsif ci_service == :github
247
+
248
+ if coverage_access_token.to_s.strip.length == 0
249
+ raise StandardError, "Access token is not set. Uploading coverage data for private repositories requires an access token."
250
+ end
251
+
252
+ if github_job_id
253
+ {
254
+ :service_job_id => github_job_id,
255
+ :service_name => "github",
256
+ :repo_token => coverage_access_token,
257
+ :repo_name => github_repo_name,
258
+ :source_files => coverage_files.map(&:as_json),
259
+ :service_build_url => github_build_url,
260
+ :service_pull_request => github_pull_request,
261
+ :git => github_git_info
262
+ }.to_json
263
+ else
264
+ raise StandardError, "Environment variable `GITHUB_RUN_ID` not set. Is this running on github build?"
265
+ end
209
266
  else
210
267
  raise StandardError, "No support for ci named #{ci_service}"
211
268
  end
@@ -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
@@ -18,7 +18,6 @@ module Slather
18
18
  end
19
19
 
20
20
  def create_line_data
21
- all_lines = source_code_lines
22
21
  line_data = Hash.new
23
22
  all_lines.each { |line| line_data[line_number_in_line(line, self.line_numbers_first)] = line }
24
23
  self.line_data = line_data
@@ -26,14 +25,20 @@ module Slather
26
25
  private :create_line_data
27
26
 
28
27
  def path_on_first_line?
29
- path = self.source.split("\n")[0].sub ":", ""
30
- !path.lstrip.start_with?("1|")
28
+ !source.lstrip.start_with?("1|")
31
29
  end
32
30
 
33
31
  def source_file_pathname
34
32
  @source_file_pathname ||= begin
35
33
  if path_on_first_line?
36
- path = self.source.split("\n")[0].sub ":", ""
34
+ end_index = self.source.index(/:?\n/)
35
+ if end_index != nil
36
+ end_index -= 1
37
+ path = self.source[0..end_index]
38
+ else
39
+ # Empty file, output just contains path
40
+ path = self.source.sub ":", ""
41
+ end
37
42
  path &&= Pathname(path)
38
43
  else
39
44
  # llvm-cov was run with just one matching source file
@@ -64,7 +69,16 @@ module Slather
64
69
  end
65
70
 
66
71
  def source_code_lines
67
- self.source.split("\n")[(path_on_first_line? ? 1 : 0)..-1]
72
+ lines = self.source.split("\n")[(path_on_first_line? ? 1 : 0)..-1]
73
+ ignore_error_lines(lines)
74
+ end
75
+
76
+ def ignore_error_lines(lines, line_numbers_first = self.line_numbers_first)
77
+ if line_numbers_first
78
+ lines.reject { |line| line.lstrip.start_with?('|', '--') }
79
+ else
80
+ lines
81
+ end
68
82
  end
69
83
 
70
84
  def source_data
@@ -72,10 +86,7 @@ module Slather
72
86
  end
73
87
 
74
88
  def all_lines
75
- if @all_lines == nil
76
- @all_lines = source_code_lines
77
- end
78
- @all_lines
89
+ @all_lines ||= source_code_lines
79
90
  end
80
91
 
81
92
  def raw_source
@@ -94,6 +105,9 @@ module Slather
94
105
 
95
106
  def line_number_in_line(line, line_numbers_first = self.line_numbers_first)
96
107
  if line_numbers_first
108
+ # Skip regex if the number is the first thing in the line
109
+ fastpath_number = line.to_i
110
+ return fastpath_number if fastpath_number != 0
97
111
  line =~ /^(\s*)(\d*)/
98
112
  group = $2
99
113
  else
@@ -123,7 +137,7 @@ module Slather
123
137
  end
124
138
 
125
139
  def line_coverage_data
126
- source_code_lines.map do |line|
140
+ all_lines.map do |line|
127
141
  coverage_for_line(line, self.line_numbers_first)
128
142
  end
129
143
  end
@@ -191,36 +191,38 @@ module Slather
191
191
  end
192
192
 
193
193
  def profdata_coverage_dir
194
- raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory)
195
- dir = nil
196
- if self.scheme
197
- dir = Dir[File.join(build_directory,"/**/CodeCoverage/#{self.scheme}")].first
198
- else
199
- dir = Dir[File.join(build_directory,"/**/#{first_product_name}")].first
200
- end
194
+ @profdata_coverage_dir ||= begin
195
+ raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory)
196
+ dir = nil
197
+ if self.scheme
198
+ dir = Dir[File.join(build_directory,"/**/CodeCoverage/#{self.scheme}")].first
199
+ else
200
+ dir = Dir[File.join(build_directory,"/**/#{first_product_name}")].first
201
+ end
201
202
 
202
- if dir == nil
203
- # Xcode 7.3 moved the location of Coverage.profdata
204
- dir = Dir[File.join(build_directory,"/**/CodeCoverage")].first
205
- end
203
+ if dir == nil
204
+ # Xcode 7.3 moved the location of Coverage.profdata
205
+ dir = Dir[File.join(build_directory,"/**/CodeCoverage")].first
206
+ end
206
207
 
207
- if dir == nil && Slather.xcode_version[0] >= 9
208
- # Xcode 9 moved the location of Coverage.profdata
209
- coverage_files = Dir[File.join(build_directory, "/**/ProfileData/*/Coverage.profdata")]
208
+ if dir == nil && Slather.xcode_version[0] >= 9
209
+ # Xcode 9 moved the location of Coverage.profdata
210
+ coverage_files = Dir[File.join(build_directory, "/**/ProfileData/*/Coverage.profdata")]
210
211
 
211
- if coverage_files.count == 0
212
- # Look up one directory
213
- # The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates)
214
- coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
215
- end
212
+ if coverage_files.count == 0
213
+ # Look up one directory
214
+ # The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates)
215
+ coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
216
+ end
216
217
 
217
- if coverage_files != nil && coverage_files.count != 0
218
- dir = Pathname.new(coverage_files.first).parent()
218
+ if coverage_files != nil && coverage_files.count != 0
219
+ dir = Pathname.new(coverage_files.first).parent()
220
+ end
219
221
  end
220
- end
221
222
 
222
- raise StandardError, "No coverage directory found." unless dir != nil
223
- dir
223
+ raise StandardError, "No coverage directory found." unless dir != nil
224
+ dir
225
+ end
224
226
  end
225
227
 
226
228
  def profdata_file
@@ -422,6 +424,8 @@ module Slather
422
424
  extend(Slather::CoverageService::HtmlOutput)
423
425
  when :json
424
426
  extend(Slather::CoverageService::JsonOutput)
427
+ when :sonarqube_xml
428
+ extend(Slather::CoverageService::SonarqubeXmlOutput)
425
429
  else
426
430
  raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal`, `coveralls`, `gutter_json`, `cobertura_xml` or `html`"
427
431
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = '2.4.7' unless defined?(Slather::VERSION)
2
+ VERSION = '2.6.1' unless defined?(Slather::VERSION)
3
3
  end
@@ -17,20 +17,20 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.17'
21
- spec.add_development_dependency 'coveralls', '~> 0'
20
+ spec.add_development_dependency 'bundler', '~> 2.0'
21
+ spec.add_development_dependency 'coveralls', '~> 0.8'
22
22
  spec.add_development_dependency 'simplecov', '~> 0'
23
23
  spec.add_development_dependency 'rake', '~> 12.3'
24
24
  spec.add_development_dependency 'rspec', '~> 3.8'
25
25
  spec.add_development_dependency 'pry', '~> 0.12'
26
- spec.add_development_dependency 'cocoapods', '~> 1.5'
26
+ spec.add_development_dependency 'cocoapods', '~> 1.10.beta.1'
27
27
  spec.add_development_dependency 'json_spec', '~> 1.1'
28
28
  spec.add_development_dependency 'equivalent-xml', '~> 0.6'
29
29
 
30
30
  spec.add_dependency 'clamp', '~> 1.3'
31
31
  spec.add_dependency 'xcodeproj', '~> 1.7'
32
- spec.add_dependency 'nokogiri', '~> 1.8'
32
+ spec.add_dependency 'nokogiri', '~> 1.11'
33
33
  spec.add_dependency 'CFPropertyList', '>= 2.2', '< 4'
34
34
 
35
- spec.add_runtime_dependency 'activesupport', '< 5', '>= 4.0.2'
35
+ spec.add_runtime_dependency 'activesupport'
36
36
  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>
@@ -13,7 +13,7 @@ describe Slather do
13
13
  # Execute the post_install hook via CocoaPods
14
14
  sandbox_root = 'Pods'
15
15
  sandbox = Pod::Sandbox.new(sandbox_root)
16
- context = Pod::Installer::PostInstallHooksContext.generate(sandbox, [])
16
+ context = Pod::Installer::PostInstallHooksContext.generate(sandbox, mock_project, [])
17
17
  Pod::HooksManager.run(:post_install, context, {'slather' => nil})
18
18
  end
19
19
  end
@@ -151,6 +151,26 @@ describe Slather::CoverageService::Coveralls do
151
151
  ENV['GIT_BRANCH'] = git_branch
152
152
  end
153
153
  end
154
+
155
+ context "coverage_service is :github" do
156
+ before(:each) { fixtures_project.ci_service = :github }
157
+
158
+ it "should return valid json for coveralls coverage data" do
159
+ allow(fixtures_project).to receive(:github_job_id).and_return("9182")
160
+ allow(fixtures_project).to receive(:coverage_access_token).and_return("abc123")
161
+ allow(fixtures_project).to receive(:github_pull_request).and_return("1")
162
+ allow(fixtures_project).to receive(:github_build_url).and_return("https://github.com/Bruce/Wayne/actions/runs/1")
163
+ allow(fixtures_project).to receive(:github_git_info).and_return({ :head => { :id => "ababa123", :author_name => "bwayne", :message => "hello" }, :branch => "master" })
164
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"github\",\"repo_name\":\"\",\"repo_token\":\"abc123\",\"service_pull_request\":\"1\",\"service_build_url\":\"https://github.com/Bruce/Wayne/actions/runs/1\",\"git\":{\"head\":{\"id\":\"ababa123\",\"author_name\":\"bwayne\",\"message\":\"hello\"},\"branch\":\"master\"}}").excluding("source_files")
165
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.coverage_files.map(&:as_json).to_json).at_path("source_files")
166
+ end
167
+
168
+ it "should raise an error if there is no GITHUB_RUN_ID" do
169
+ allow(fixtures_project).to receive(:github_job_id).and_return(nil)
170
+ expect { fixtures_project.send(:coveralls_coverage_data) }.to raise_error(StandardError)
171
+ end
172
+ end
173
+
154
174
  end
155
175
 
156
176
  describe '#coveralls_coverage_data' do
@@ -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
@@ -90,6 +90,23 @@ describe Slather::ProfdataCoverageFile do
90
90
  end
91
91
  end
92
92
 
93
+ describe '#ignore_error_lines' do
94
+ it 'should ignore lines starting with - when line_numbers_first is true' do
95
+ expect(profdata_coverage_file.ignore_error_lines(['--------'], true)).to eq([])
96
+ expect(profdata_coverage_file.ignore_error_lines(['--------', 'not ignored'], true)).to eq(['not ignored'])
97
+ end
98
+
99
+ it 'should ignore lines starting with | when line_numbers_first is true' do
100
+ expect(profdata_coverage_file.ignore_error_lines(['| Unexecuted instantiation'], true)).to eq([])
101
+ expect(profdata_coverage_file.ignore_error_lines(['| Unexecuted instantiation', 'not ignored'], true)).to eq(['not ignored'])
102
+ end
103
+
104
+ it 'should not ignore any lines when line_numbers_first is false' do
105
+ lines = ['| Unexecuted instantiation', '------']
106
+ expect(profdata_coverage_file.ignore_error_lines(lines, false)).to eq(lines)
107
+ end
108
+ end
109
+
93
110
  describe "#coverage_for_line" do
94
111
  it "should return the number of hits for the line" do
95
112
  expect(profdata_coverage_file.coverage_for_line(" 10| 40| func applicationWillTerminate(application: UIApplication) {", false)).to eq(10)
@@ -116,6 +133,10 @@ describe Slather::ProfdataCoverageFile do
116
133
  expect(profdata_coverage_file.coverage_for_line(" 18| 11.8k| return a + b;", true)).to eq(11800)
117
134
  expect(profdata_coverage_file.coverage_for_line(" 18| 2.58M| return a + b;", true)).to eq(2580000)
118
135
  end
136
+
137
+ it 'should ignore errors in profdata' do
138
+ expect(profdata_coverage_file.coverage_for_line('------------------', true)).to eq(nil)
139
+ end
119
140
  end
120
141
 
121
142
  describe "#num_lines_tested" do
@@ -653,8 +653,8 @@ describe Slather::Project do
653
653
  it "should find relevant source files" do
654
654
  source_files = fixtures_project.find_source_files
655
655
  expect(source_files.count).to eq(2)
656
- expect(source_files.first.to_s).to include("fixtures.m")
657
- expect(source_files.last.to_s).to include("fixturesTwo.m")
656
+ expect(source_files.first.to_s).to include("fixturesTwo.m")
657
+ expect(source_files.last.to_s).to include("fixtures.m")
658
658
  end
659
659
 
660
660
  it "should print out the coverage for each file, and then total coverage" do
@@ -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.7
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-14 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.8'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.5'
103
+ version: 1.10.beta.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.5'
110
+ version: 1.10.beta.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json_spec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.8'
173
+ version: '1.11'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.8'
180
+ version: '1.11'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: CFPropertyList
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -202,23 +202,17 @@ dependencies:
202
202
  name: activesupport
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - "<"
206
- - !ruby/object:Gem::Version
207
- version: '5'
208
205
  - - ">="
209
206
  - !ruby/object:Gem::Version
210
- version: 4.0.2
207
+ version: '0'
211
208
  type: :runtime
212
209
  prerelease: false
213
210
  version_requirements: !ruby/object:Gem::Requirement
214
211
  requirements:
215
- - - "<"
216
- - !ruby/object:Gem::Version
217
- version: '5'
218
212
  - - ">="
219
213
  - !ruby/object:Gem::Version
220
- version: 4.0.2
221
- description:
214
+ version: '0'
215
+ description:
222
216
  email:
223
217
  - mark@venmo.com
224
218
  executables:
@@ -255,6 +249,7 @@ files:
255
249
  - lib/slather/coverage_service/json_output.rb
256
250
  - lib/slather/coverage_service/llvm_cov_output.rb
257
251
  - lib/slather/coverage_service/simple_output.rb
252
+ - lib/slather/coverage_service/sonarqube_xml_output.rb
258
253
  - lib/slather/coveralls_coverage.rb
259
254
  - lib/slather/profdata_coverage_file.rb
260
255
  - lib/slather/project.rb
@@ -304,6 +299,7 @@ files:
304
299
  - spec/fixtures/gutter.json
305
300
  - spec/fixtures/report.json
306
301
  - spec/fixtures/report.llcov
302
+ - spec/fixtures/sonarqube-generic-coverage.xml
307
303
  - spec/slather/cocoapods_plugin_spec.rb
308
304
  - spec/slather/coverage_file_spec.rb
309
305
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -314,6 +310,7 @@ files:
314
310
  - spec/slather/coverage_service/json_spec.rb
315
311
  - spec/slather/coverage_service/llvm_cov_spec.rb
316
312
  - spec/slather/coverage_service/simple_output_spec.rb
313
+ - spec/slather/coverage_service/sonarqube_xml_spec.rb
317
314
  - spec/slather/fixtures.gcno
318
315
  - spec/slather/profdata_coverage_spec.rb
319
316
  - spec/slather/project_spec.rb
@@ -322,7 +319,7 @@ homepage: https://github.com/SlatherOrg/slather
322
319
  licenses:
323
320
  - MIT
324
321
  metadata: {}
325
- post_install_message:
322
+ post_install_message:
326
323
  rdoc_options: []
327
324
  require_paths:
328
325
  - lib
@@ -337,9 +334,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
334
  - !ruby/object:Gem::Version
338
335
  version: '0'
339
336
  requirements: []
340
- rubyforge_project:
341
- rubygems_version: 2.7.6
342
- signing_key:
337
+ rubygems_version: 3.1.3
338
+ signing_key:
343
339
  specification_version: 4
344
340
  summary: Test coverage reports for Xcode projects
345
341
  test_files:
@@ -387,6 +383,7 @@ test_files:
387
383
  - spec/fixtures/gutter.json
388
384
  - spec/fixtures/report.json
389
385
  - spec/fixtures/report.llcov
386
+ - spec/fixtures/sonarqube-generic-coverage.xml
390
387
  - spec/slather/cocoapods_plugin_spec.rb
391
388
  - spec/slather/coverage_file_spec.rb
392
389
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -397,6 +394,7 @@ test_files:
397
394
  - spec/slather/coverage_service/json_spec.rb
398
395
  - spec/slather/coverage_service/llvm_cov_spec.rb
399
396
  - spec/slather/coverage_service/simple_output_spec.rb
397
+ - spec/slather/coverage_service/sonarqube_xml_spec.rb
400
398
  - spec/slather/fixtures.gcno
401
399
  - spec/slather/profdata_coverage_spec.rb
402
400
  - spec/slather/project_spec.rb