slather 2.4.2 → 2.4.3

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
  SHA1:
3
- metadata.gz: 468a58d0b18f5ae7633a796c72205f80d4db2eb8
4
- data.tar.gz: 4f4ee9f3346d2849a29e7a654be2e42354209320
3
+ metadata.gz: e4792a1ef157980aebe454c8f2f66ba615afce74
4
+ data.tar.gz: 20c3278d981f6b6989d59ea446a5e102f2cc1119
5
5
  SHA512:
6
- metadata.gz: 67a07567cfcd9b80606b67b2e40ce3c0f96679f556bf8919bbbbd6d6ccd099d33ad1bab5d624307ee55c4cf3cc80fd9006fef1227998e7d04d9ed593c5b79b90
7
- data.tar.gz: 1bd3e902f18d8bee77087615a9806da2359ea235a86fcae23e70c5900ee1ae0ed47ed72789756e9ebd78286589abb5be0f25a26eac1557b083054218799587d8
6
+ metadata.gz: 76515b90aa82cad8d98ee37d31b8204e28053a987c1207d60a07e3f843bab9579faef26ef9e2ce4129a171a323a86bc98d376fe23ee21b030fc8c367032b39bb
7
+ data.tar.gz: 0bf97e2d021ceb10ac033fe93a45c4eed0b17be60c23e05ba6ee0c554c3260da0d21982104be9a58e34486330c7a72b3860a3a0c1264ee13f0ea349353da2bea
@@ -1,6 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
- ## master
3
+ ## v2.4.3
4
+
5
+ * Initial Xcode 9 support
6
+ [ksuther](https://github.com/ksuther) [#339](https://github.com/SlatherOrg/slather/pull/339), [ivanbrunel](https://github.com/ivanbruel) [#321](https://github.com/SlatherOrg/slather/pull/321), [FDREAL](https://github.com/FDREAL) [#338](https://github.com/SlatherOrg/slather/pull/338)
7
+
8
+ * Add `--json` output option for basic JSON format not specific to any particular service.
9
+ [ileitch](https://github.com/ileitch)
10
+ [#318](https://github.com/SlatherOrg/slather/pull/318)
4
11
 
5
12
  ## v2.4.2
6
13
 
@@ -10,6 +10,7 @@ require 'slather/coverage_service/hardcover'
10
10
  require 'slather/coverage_service/gutter_json_output'
11
11
  require 'slather/coverage_service/simple_output'
12
12
  require 'slather/coverage_service/html_output'
13
+ require 'slather/coverage_service/json_output'
13
14
  require 'cfpropertylist'
14
15
 
15
16
  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 ["--json"], :flag, "Output coverage results as simple JSON"
16
17
  option ["--html"], :flag, "Output coverage results as static html pages"
17
18
  option ["--show"], :flag, "Indicate that the static html pages will open automatically"
18
19
 
@@ -116,6 +117,8 @@ class CoverageCommand < Clamp::Command
116
117
  elsif html?
117
118
  project.coverage_service = :html
118
119
  project.show_html = show?
120
+ elsif json?
121
+ project.coverage_service = :json
119
122
  end
120
123
  end
121
124
 
@@ -0,0 +1,38 @@
1
+ require 'nokogiri'
2
+ require 'date'
3
+
4
+ module Slather
5
+ module CoverageService
6
+ module JsonOutput
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
+ report = coverage_files.map do |file|
19
+ {
20
+ file: file.source_file_pathname_relative_to_repo_root,
21
+ coverage: file.line_coverage_data
22
+ }
23
+ end.to_json
24
+
25
+ store_report(report)
26
+ end
27
+
28
+ def store_report(report)
29
+ output_file = 'report.json'
30
+ if output_directory
31
+ FileUtils.mkdir_p(output_directory)
32
+ output_file = File.join(output_directory, output_file)
33
+ end
34
+ File.write(output_file, report.to_s)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -158,14 +158,29 @@ module Slather
158
158
  raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory)
159
159
  dir = nil
160
160
  if self.scheme
161
- dir = Dir[File.join("#{build_directory}","/**/CodeCoverage/#{self.scheme}")].first
161
+ dir = Dir[File.join(build_directory,"/**/CodeCoverage/#{self.scheme}")].first
162
162
  else
163
- dir = Dir[File.join("#{build_directory}","/**/#{first_product_name}")].first
163
+ dir = Dir[File.join(build_directory,"/**/#{first_product_name}")].first
164
164
  end
165
165
 
166
166
  if dir == nil
167
167
  # Xcode 7.3 moved the location of Coverage.profdata
168
- dir = Dir[File.join("#{build_directory}","/**/CodeCoverage")].first
168
+ dir = Dir[File.join(build_directory,"/**/CodeCoverage")].first
169
+ end
170
+
171
+ if dir == nil && Slather.xcode_version[0] >= 9
172
+ # Xcode 9 moved the location of Coverage.profdata
173
+ coverage_files = Dir[File.join(build_directory, "/**/ProfileData/*/Coverage.profdata")]
174
+
175
+ if coverage_files.count == 0
176
+ # Look up one directory
177
+ # The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates)
178
+ coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
179
+ end
180
+
181
+ if coverage_files != nil
182
+ dir = Pathname.new(coverage_files.first).parent()
183
+ end
169
184
  end
170
185
 
171
186
  raise StandardError, "No coverage directory found." unless dir != nil
@@ -339,6 +354,8 @@ module Slather
339
354
  extend(Slather::CoverageService::CoberturaXmlOutput)
340
355
  when :html
341
356
  extend(Slather::CoverageService::HtmlOutput)
357
+ when :json
358
+ extend(Slather::CoverageService::JsonOutput)
342
359
  else
343
360
  raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal`, `coveralls`, `gutter_json`, `cobertura_xml` or `html`"
344
361
  end
@@ -404,9 +421,15 @@ module Slather
404
421
  end
405
422
 
406
423
  search_list = binary_basename || find_buildable_names(xcscheme)
424
+ search_dir = profdata_coverage_dir
425
+
426
+ if Slather.xcode_version[0] >= 9
427
+ # Go from the directory containing Coverage.profdata back to the directory containing Products (back out of ProfileData/UUID-dir)
428
+ search_dir = File.join(search_dir, '../..')
429
+ end
407
430
 
408
431
  search_list.each do |search_for|
409
- found_product = Dir["#{profdata_coverage_dir}/Products/#{configuration}*/#{search_for}*"].sort { |x, y|
432
+ found_product = Dir["#{search_dir}/Products/#{configuration}*/#{search_for}*"].sort { |x, y|
410
433
  # Sort the matches without the file extension to ensure better matches when there are multiple candidates
411
434
  # For example, if the binary_basename is Test then we want Test.app to be matched before Test Helper.app
412
435
  File.basename(x, File.extname(x)) <=> File.basename(y, File.extname(y))
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = '2.4.2' unless defined?(Slather::VERSION)
2
+ VERSION = '2.4.3' unless defined?(Slather::VERSION)
3
3
  end
@@ -4,33 +4,33 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'slather/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "slather"
7
+ spec.name = 'slather'
8
8
  spec.version = Slather::VERSION
9
- spec.authors = ["Mark Larsen"]
10
- spec.email = ["mark@venmo.com"]
9
+ spec.authors = ['Mark Larsen']
10
+ spec.email = ['mark@venmo.com']
11
11
  spec.summary = %q{Test coverage reports for Xcode projects}
12
- spec.homepage = "https://github.com/SlatherOrg/slather"
13
- spec.license = "MIT"
12
+ spec.homepage = 'https://github.com/SlatherOrg/slather'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.6"
21
- spec.add_development_dependency "coveralls"
22
- spec.add_development_dependency "simplecov"
23
- spec.add_development_dependency "rake", "~> 10.4"
24
- spec.add_development_dependency "rspec", "~> 3.4"
25
- spec.add_development_dependency "pry", "~> 0.9"
26
- spec.add_development_dependency "cocoapods", "~> 1.2"
27
- spec.add_development_dependency "json_spec", "~> 1.1.4"
28
- spec.add_development_dependency "equivalent-xml", "~> 0.5.1"
20
+ spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'coveralls'
22
+ spec.add_development_dependency 'simplecov'
23
+ spec.add_development_dependency 'rake', '~> 10.4'
24
+ spec.add_development_dependency 'rspec', '~> 3.4'
25
+ spec.add_development_dependency 'pry', '~> 0.9'
26
+ spec.add_development_dependency 'cocoapods', '~> 1.2'
27
+ spec.add_development_dependency 'json_spec', '~> 1.1.4'
28
+ spec.add_development_dependency 'equivalent-xml', '~> 0.5.1'
29
29
 
30
- spec.add_dependency "clamp", "~> 0.6"
31
- spec.add_dependency "xcodeproj", "~> 1.4"
32
- spec.add_dependency "nokogiri", "~> 1.6"
33
- spec.add_dependency "CFPropertyList", "~> 2.2"
30
+ spec.add_dependency 'clamp', '~> 0.6'
31
+ spec.add_dependency 'xcodeproj', '~> 1.4'
32
+ spec.add_dependency 'nokogiri', '>= 1.6', '< 1.7'
33
+ spec.add_dependency 'CFPropertyList', '~> 2.2'
34
34
 
35
35
  ## Version 5 needs Ruby 2.2, so we specify an upper bound to stay compatible with system ruby
36
36
  spec.add_runtime_dependency 'activesupport', '>= 4.0.2', '< 5'
@@ -0,0 +1 @@
1
+ [{"file":"spec/fixtures/fixtures/fixtures.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,null,null,0,0,0,null,null]},{"file":"spec/fixtures/fixtures/more_files/Branches.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,2,2,1,1,1,0,0,1,1,1,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,null,null]},{"file":"spec/fixtures/fixturesTests/BranchesTests.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,2,2,2,2,null,2,2,2,2,null,1,1,1,1,null,1,1,1,1,null,null]},{"file":"spec/fixtures/fixturesTests/fixturesTests.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,2,2,2,2,null,null,2,2,2,2,null,null,1,1,1,1,null,null,1,1,1,1,1,null,null]},{"file":"spec/fixtures/fixturesTests/peekaviewTests💣.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,1,null,null,1,1,1,1,null,null,1,1,1,null,null]},{"file":"spec/fixtures/fixturesTwo/fixturesTwo.m","coverage":[null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,1,1,1,null,null]}]
@@ -22,7 +22,7 @@ describe Slather::CoverageService::GutterJsonOutput do
22
22
  it "should print out the coverage for each file, and then total coverage" do
23
23
  fixtures_project.post
24
24
 
25
- fixture_json = File.read(FIXTURES_JSON_PATH)
25
+ fixture_json = File.read(FIXTURES_GUTTER_JSON_PATH)
26
26
  current_json = File.read('.gutter.json')
27
27
 
28
28
  expect(current_json).to be_json_eql(fixture_json)
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+ require 'json'
3
+
4
+ describe Slather::CoverageService::JsonOutput 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.binary_basename = ["fixturesTests", "libfixturesTwo"]
10
+ proj.input_format = "profdata"
11
+ proj.coverage_service = "json"
12
+ proj.configure
13
+ proj
14
+ end
15
+
16
+ describe '#coverage_file_class' do
17
+ it "should return ProfdataCoverageFile" do
18
+ expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
19
+ end
20
+ end
21
+
22
+ describe '#post' do
23
+ it "should create an JSON report spanning all coverage files" do
24
+ fixtures_project.post
25
+
26
+ output_json = JSON.parse(File.read('report.json'))
27
+ fixture_json = JSON.parse(File.read(FIXTURES_JSON_PATH))
28
+
29
+ expect(output_json).to eq(fixture_json)
30
+ FileUtils.rm('report.json')
31
+ end
32
+
33
+ it "should create an JSON report in the given output directory" do
34
+ fixtures_project.output_directory = "./output"
35
+ fixtures_project.post
36
+
37
+ filepath = "#{fixtures_project.output_directory}/report.json"
38
+ expect(File.exists?(filepath)).to be_truthy
39
+
40
+ FileUtils.rm_rf(fixtures_project.output_directory)
41
+ end
42
+ end
43
+ end
@@ -13,7 +13,8 @@ require 'equivalent-xml'
13
13
 
14
14
 
15
15
  FIXTURES_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/cobertura.xml')
16
- FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
16
+ FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/report.json')
17
+ FIXTURES_GUTTER_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
17
18
  FIXTURES_HTML_FOLDER_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures_html')
18
19
  FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
19
20
  FIXTURES_WORKSPACE_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcworkspace')
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.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-16 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -168,16 +168,22 @@ dependencies:
168
168
  name: nokogiri
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '1.6'
174
+ - - "<"
175
+ - !ruby/object:Gem::Version
176
+ version: '1.7'
174
177
  type: :runtime
175
178
  prerelease: false
176
179
  version_requirements: !ruby/object:Gem::Requirement
177
180
  requirements:
178
- - - "~>"
181
+ - - ">="
179
182
  - !ruby/object:Gem::Version
180
183
  version: '1.6'
184
+ - - "<"
185
+ - !ruby/object:Gem::Version
186
+ version: '1.7'
181
187
  - !ruby/object:Gem::Dependency
182
188
  name: CFPropertyList
183
189
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +252,7 @@ files:
246
252
  - lib/slather/coverage_service/gutter_json_output.rb
247
253
  - lib/slather/coverage_service/hardcover.rb
248
254
  - lib/slather/coverage_service/html_output.rb
255
+ - lib/slather/coverage_service/json_output.rb
249
256
  - lib/slather/coverage_service/simple_output.rb
250
257
  - lib/slather/coveralls_coverage.rb
251
258
  - lib/slather/profdata_coverage_file.rb
@@ -294,6 +301,7 @@ files:
294
301
  - spec/fixtures/fixtures_html/index.html
295
302
  - "spec/fixtures/fixtures_html/peekaviewTests\U0001F4A3.m.html"
296
303
  - spec/fixtures/gutter.json
304
+ - spec/fixtures/report.json
297
305
  - spec/slather/cocoapods_plugin_spec.rb
298
306
  - spec/slather/coverage_file_spec.rb
299
307
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -301,6 +309,7 @@ files:
301
309
  - spec/slather/coverage_service/gutter_json_spec.rb
302
310
  - spec/slather/coverage_service/hardcover_spec.rb
303
311
  - spec/slather/coverage_service/html_output_spec.rb
312
+ - spec/slather/coverage_service/json_spec.rb
304
313
  - spec/slather/coverage_service/simple_output_spec.rb
305
314
  - spec/slather/fixtures.gcno
306
315
  - spec/slather/profdata_coverage_spec.rb
@@ -373,6 +382,7 @@ test_files:
373
382
  - spec/fixtures/fixtures_html/index.html
374
383
  - "spec/fixtures/fixtures_html/peekaviewTests\U0001F4A3.m.html"
375
384
  - spec/fixtures/gutter.json
385
+ - spec/fixtures/report.json
376
386
  - spec/slather/cocoapods_plugin_spec.rb
377
387
  - spec/slather/coverage_file_spec.rb
378
388
  - spec/slather/coverage_service/cobertura_xml_spec.rb
@@ -380,6 +390,7 @@ test_files:
380
390
  - spec/slather/coverage_service/gutter_json_spec.rb
381
391
  - spec/slather/coverage_service/hardcover_spec.rb
382
392
  - spec/slather/coverage_service/html_output_spec.rb
393
+ - spec/slather/coverage_service/json_spec.rb
383
394
  - spec/slather/coverage_service/simple_output_spec.rb
384
395
  - spec/slather/fixtures.gcno
385
396
  - spec/slather/profdata_coverage_spec.rb