slather 2.4.0 → 2.4.1

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: 0b3fb54ecb063ddb137572a81d78d071c3abe64c
4
- data.tar.gz: 7f18e0dce826e19e5929eff17d02368e5d0b27cc
3
+ metadata.gz: f16b2538dcd029639010c327e4ee5c98ee8c8d5e
4
+ data.tar.gz: 9f50f7cc111bbdd690d812490673ab71ebcf6d9c
5
5
  SHA512:
6
- metadata.gz: 47ae378522e002970dea520e193b5de1bed30ed69a259cc1ddc492a54b703a796295faba7535c5749dc5323e18a3f583b1674700ca893a3d6082b0cb2f73b1cd
7
- data.tar.gz: b87f45afcafb2d8add2baff4b01eaa21e45ed1ae630c017aff8447b6c9703197019e531420e5507a7013acebec6f73059b4e2ab26feb3ad9e92024d9c23a8d15
6
+ metadata.gz: 5a31043e931bd04938a32e4c0a78375f764a7bf9275425b2d7c5a9f943382434542eb0c3bb4fe858836b87fba69795f2af87992c0d491a6d9777fd2ad8bf1ace
7
+ data.tar.gz: 173b017b6e51a8f61506278abc7a44a3acb11d7896aaa779dd18f3c3182346b980f1029ff9fb9a34789a98f72a4ede6bd2e884086021803c5a7f22548be79522
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## v2.4.1
6
+
7
+ * Add `--configuration` option
8
+ [thasegaw](https://github.com/thasegaw)
9
+ [#294](https://github.com/slatherOrg/slather/pull/294)
10
+
11
+ * Fix misdetection of Xcode version if Spotlight hasn't indexed Xcode yet
12
+ [ksuther](https://github.com/ksuther)
13
+ [#298](https://github.com/slatherOrg/slather/pull/298)
14
+
15
+ * Better verbose message when no binaries are found
16
+ [ksuther](https://github.com/ksuther)
17
+ [#300](https://github.com/slatherOrg/slather/pull/300)
18
+
5
19
  ## v2.4.0
6
20
 
7
21
  * Xcode 8.3 support.
data/README.md CHANGED
@@ -55,6 +55,12 @@ If you use a workspace in Xcode you need to specify it:
55
55
  $ slather coverage -s --scheme YourXcodeSchemeName --workspace path/to/workspace.xcworkspace path/to/project.xcodeproj
56
56
  ```
57
57
 
58
+ If you use a different configuration for your tests:
59
+
60
+ ```sh
61
+ $ slather coverage -s --scheme YourXcodeSchemeName --configuration YourBuildConfigurationName path/to/project.xcodeproj
62
+ ```
63
+
58
64
  ### Setup for Xcode 5 and 6
59
65
 
60
66
  Run this command to enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project:
@@ -75,6 +81,7 @@ Make a `.slather.yml` file:
75
81
  coverage_service: cobertura_xml
76
82
  xcodeproj: path/to/project.xcodeproj
77
83
  scheme: YourXcodeSchemeName
84
+ configuration: TestedConfiguration
78
85
  source_directory: path/to/sources/to/include
79
86
  output_directory: path/to/xml_report
80
87
  ignore:
data/lib/slather.rb CHANGED
@@ -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 'cfpropertylist'
13
14
 
14
15
  module Slather
15
16
 
@@ -21,7 +22,8 @@ module Slather
21
22
 
22
23
  def self.xcode_version
23
24
  xcode_path = `xcode-select -p`.strip
24
- xcode_version = `mdls -name kMDItemVersion -raw #{xcode_path.shellescape}/../..`.strip
25
+ plist = CFPropertyList::List.new(:file => File.join(xcode_path, '..', 'Info.plist'))
26
+ xcode_version = CFPropertyList.native_types(plist.value)["CFBundleShortVersionString"]
25
27
  xcode_version.split('.').map(&:to_i)
26
28
  end
27
29
 
@@ -24,6 +24,7 @@ class CoverageCommand < Clamp::Command
24
24
 
25
25
  option ["--input-format"], "INPUT_FORMAT", "Input format (gcov, profdata)"
26
26
  option ["--scheme"], "SCHEME", "The scheme for which the coverage was generated"
27
+ option ["--configuration"], "CONFIGURATION", "The configuration for test that the project was set"
27
28
  option ["--workspace"], "WORKSPACE", "The workspace that the project was built in"
28
29
  option ["--binary-file"], "BINARY_FILE", "The binary file against the which the coverage will be run", :multivalued => true
29
30
  option ["--binary-basename"], "BINARY_BASENAME", "Basename of the file against which the coverage will be run", :multivalued => true
@@ -42,6 +43,7 @@ class CoverageCommand < Clamp::Command
42
43
  setup_verbose_mode
43
44
  setup_input_format
44
45
  setup_scheme
46
+ setup_configuration
45
47
  setup_workspace
46
48
  setup_binary_file
47
49
  setup_binary_basename
@@ -129,6 +131,10 @@ class CoverageCommand < Clamp::Command
129
131
  project.scheme = scheme
130
132
  end
131
133
 
134
+ def setup_configuration
135
+ project.configuration = configuration
136
+ end
137
+
132
138
  def setup_workspace
133
139
  project.workspace = workspace
134
140
  end
@@ -27,19 +27,12 @@ module Xcodeproj
27
27
 
28
28
  # Patch xcschemes too
29
29
  if format == :clang
30
- if Gem::Requirement.new('>= 0.28.2') =~ Gem::Version.new(Xcodeproj::VERSION)
31
- # @todo This will require to bump the xcodeproj dependency to >= 0.28.2
32
- # (which would require to bump cocoapods too)
33
- schemes_path = Xcodeproj::XCScheme.shared_data_dir(self.path)
34
- Xcodeproj::Project.schemes(self.path).each do |scheme_name|
35
- xcscheme_path = "#{schemes_path + scheme_name}.xcscheme"
36
- xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
37
- xcscheme.test_action.xml_element.attributes['codeCoverageEnabled'] = 'YES'
38
- xcscheme.save_as(self.path, scheme_name)
39
- end
40
- else
41
- # @todo In the meantime, simply inform the user to do it manually
42
- puts %Q(Ensure you enabled "Gather coverage data" in each of your scheme's Test action)
30
+ schemes_path = Xcodeproj::XCScheme.shared_data_dir(self.path)
31
+ Xcodeproj::Project.schemes(self.path).each do |scheme_name|
32
+ xcscheme_path = "#{schemes_path + scheme_name}.xcscheme"
33
+ xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
34
+ xcscheme.test_action.xml_element.attributes['codeCoverageEnabled'] = 'YES'
35
+ xcscheme.save_as(self.path, scheme_name)
43
36
  end
44
37
  end
45
38
  end
@@ -52,7 +45,7 @@ module Slather
52
45
 
53
46
  attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory,
54
47
  :output_directory, :xcodeproj, :show_html, :verbose_mode, :input_format, :scheme, :workspace, :binary_file, :binary_basename, :source_files,
55
- :decimals, :llvm_version
48
+ :decimals, :llvm_version, :configuration
56
49
 
57
50
  alias_method :setup_for_coverage, :slather_setup_for_coverage
58
51
 
@@ -230,6 +223,7 @@ module Slather
230
223
  def configure
231
224
  begin
232
225
  configure_scheme
226
+ configure_configuration
233
227
  configure_workspace
234
228
  configure_build_directory
235
229
  configure_ignore_list
@@ -252,9 +246,13 @@ module Slather
252
246
 
253
247
  if self.verbose_mode
254
248
  puts "\nProcessing coverage file: #{profdata_file}"
255
- puts "Against binary files:"
256
- self.binary_file.each do |binary_file|
257
- puts "\t#{binary_file}"
249
+ if self.binary_file
250
+ puts "Against binary files:"
251
+ self.binary_file.each do |binary_file|
252
+ puts "\t#{binary_file}"
253
+ end
254
+ else
255
+ puts "No binary files found."
258
256
  end
259
257
  puts "\n"
260
258
  end
@@ -300,6 +298,10 @@ module Slather
300
298
  self.scheme ||= self.class.yml["scheme"] if self.class.yml["scheme"]
301
299
  end
302
300
 
301
+ def configure_configuration
302
+ self.configuration ||= self.class.yml["configuration"] if self.class.yml["configuration"]
303
+ end
304
+
303
305
  def configure_decimals
304
306
  return if self.decimals
305
307
  self.decimals ||= self.class.yml["decimals"] if self.class.yml["decimals"]
@@ -395,7 +397,11 @@ module Slather
395
397
 
396
398
  xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
397
399
 
398
- configuration = xcscheme.test_action.build_configuration
400
+ if self.configuration
401
+ configuration = self.configuration
402
+ else
403
+ configuration = xcscheme.test_action.build_configuration
404
+ end
399
405
 
400
406
  search_list = binary_basename || find_buildable_names(xcscheme)
401
407
 
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = '2.4.0' unless defined?(Slather::VERSION)
2
+ VERSION = '2.4.1' unless defined?(Slather::VERSION)
3
3
  end
data/slather.gemspec CHANGED
@@ -23,13 +23,14 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 10.4"
24
24
  spec.add_development_dependency "rspec", "~> 3.4"
25
25
  spec.add_development_dependency "pry", "~> 0.9"
26
- spec.add_development_dependency "cocoapods", "~> 1.0"
26
+ spec.add_development_dependency "cocoapods", "~> 1.2"
27
27
  spec.add_development_dependency "json_spec", "~> 1.1.4"
28
28
  spec.add_development_dependency "equivalent-xml", "~> 0.5.1"
29
29
 
30
30
  spec.add_dependency "clamp", "~> 0.6"
31
- spec.add_dependency "xcodeproj", "< 2.0.0", ">= 0.20"
31
+ spec.add_dependency "xcodeproj", "~> 1.4"
32
32
  spec.add_dependency "nokogiri", "~> 1.6"
33
+ spec.add_dependency "CFPropertyList", "~> 2.2"
33
34
 
34
35
  ## Version 5 needs Ruby 2.2, so we specify an upper bound to stay compatible with system ruby
35
36
  spec.add_runtime_dependency 'activesupport', '>= 4.0.2', '< 5'
@@ -242,6 +242,7 @@ describe Slather::Project do
242
242
  expect(unstubbed_project).to receive(:configure_coverage_service)
243
243
  expect(unstubbed_project).to receive(:configure_input_format)
244
244
  expect(unstubbed_project).to receive(:configure_scheme)
245
+ expect(unstubbed_project).to receive(:configure_configuration)
245
246
  expect(unstubbed_project).to receive(:configure_workspace)
246
247
  unstubbed_project.configure
247
248
  end
@@ -325,6 +326,21 @@ describe Slather::Project do
325
326
  end
326
327
  end
327
328
 
329
+ describe "#configure_configuration" do
330
+ it "should set the configuration if it has been provided in the yml and has not already been set" do
331
+ allow(Slather::Project).to receive(:yml).and_return({"configuration" => "Release"})
332
+ fixtures_project.configure_configuration
333
+ expect(fixtures_project.configuration).to eq("Release")
334
+ end
335
+
336
+ it "should not set the configuration if it has already been set" do
337
+ allow(Slather::Project).to receive(:yml).and_return({"configuration" => "Release"})
338
+ fixtures_project.configuration = "Debug"
339
+ fixtures_project.configure_configuration
340
+ expect(fixtures_project.configuration).to eq("Debug")
341
+ end
342
+ end
343
+
328
344
  describe "#configure_workspace" do
329
345
  it "should set the workspace if it has been provided in the yml and has not already been set" do
330
346
  allow(Slather::Project).to receive(:yml).and_return({"workspace" => "fixtures.xcworkspace"})
@@ -503,6 +519,21 @@ describe Slather::Project do
503
519
 
504
520
  fixtures_project.send(:configure)
505
521
  end
522
+
523
+ it "should print error when no binaries found" do
524
+ allow(fixtures_project).to receive(:binary_file).and_return(nil)
525
+
526
+ project_root = Pathname("./").realpath
527
+
528
+ ["\nProcessing coverage file: #{project_root}/spec/DerivedData/libfixtures/Build/Intermediates/CodeCoverage/Coverage.profdata",
529
+ "No binary files found.",
530
+ "\n",
531
+ ].each do |line|
532
+ expect(fixtures_project).to receive(:puts).with(line)
533
+ end
534
+
535
+ fixtures_project.send(:configure)
536
+ end
506
537
  end
507
538
 
508
539
  describe "#source_files" do
@@ -551,4 +582,34 @@ describe Slather::Project do
551
582
  expect(decimal_f('50.00000')).to eq('50.0')
552
583
  end
553
584
  end
585
+
586
+ describe '#find_binary_files' do
587
+ let(:configuration) { 'Debug' }
588
+ let(:project_root) { Pathname("./").realpath }
589
+ let(:coverage_dir) { "#{project_root}/spec/DerivedData/DerivedData/Build/Intermediates/CodeCoverage" }
590
+ let(:search_dir) { "#{coverage_dir}/Products/#{configuration}*/fixtures*" }
591
+ let(:binary_file) { "#{coverage_dir}/Products/#{configuration}-iphonesimulator/fixtures.app/fixtures" }
592
+
593
+ before do
594
+ allow(fixtures_project).to receive(:scheme).and_return("fixtures")
595
+ allow(fixtures_project).to receive(:workspace).and_return("fixtures.xcworkspace")
596
+ allow(fixtures_project).to receive(:binary_basename).and_return(["fixtures"])
597
+ allow(fixtures_project).to receive(:profdata_coverage_dir).and_return(coverage_dir)
598
+ allow(Dir).to receive(:[]).with(search_dir).and_return([binary_file])
599
+ end
600
+
601
+ context 'load configuration from xcsheme' do
602
+ it "search binary from 'Products/Debug*'" do
603
+ expect(fixtures_project.find_binary_files).to eq([binary_file])
604
+ end
605
+ end
606
+
607
+ context 'load configuration from option' do
608
+ let(:configuration) { 'Release' }
609
+ it "search binary from 'Products/Release*'" do
610
+ fixtures_project.configuration = configuration
611
+ expect(fixtures_project.find_binary_files).to eq([binary_file])
612
+ end
613
+ end
614
+ end
554
615
  end
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.0
4
+ version: 2.4.1
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-03-30 00:00:00.000000000 Z
11
+ date: 2017-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
103
+ version: '1.2'
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.0'
110
+ version: '1.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json_spec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -154,22 +154,16 @@ dependencies:
154
154
  name: xcodeproj
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "<"
158
- - !ruby/object:Gem::Version
159
- version: 2.0.0
160
- - - ">="
157
+ - - "~>"
161
158
  - !ruby/object:Gem::Version
162
- version: '0.20'
159
+ version: '1.4'
163
160
  type: :runtime
164
161
  prerelease: false
165
162
  version_requirements: !ruby/object:Gem::Requirement
166
163
  requirements:
167
- - - "<"
168
- - !ruby/object:Gem::Version
169
- version: 2.0.0
170
- - - ">="
164
+ - - "~>"
171
165
  - !ruby/object:Gem::Version
172
- version: '0.20'
166
+ version: '1.4'
173
167
  - !ruby/object:Gem::Dependency
174
168
  name: nokogiri
175
169
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +178,20 @@ dependencies:
184
178
  - - "~>"
185
179
  - !ruby/object:Gem::Version
186
180
  version: '1.6'
181
+ - !ruby/object:Gem::Dependency
182
+ name: CFPropertyList
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.2'
187
195
  - !ruby/object:Gem::Dependency
188
196
  name: activesupport
189
197
  requirement: !ruby/object:Gem::Requirement