slather 2.0.2 → 2.1.0

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: c3091b591850a4c53ba0f5d19fea4f62b01f833e
4
- data.tar.gz: dc3b6ed662c319e4d3cb7f0abd463ab80047ad8d
3
+ metadata.gz: 3f63502fe53f807b2802d7cd0676e199f040b311
4
+ data.tar.gz: 9516ad8c703aa3d40f22e796e1c3a64a8dc780ca
5
5
  SHA512:
6
- metadata.gz: b9abc7f87812d4f98fff3bbc4f90fa04c68516885b187fe5d6a60066b3084e814059de68d418b7c971af219d16aedc7acdc24f8526e0ce56a98070872ea32000
7
- data.tar.gz: b3eac9e758b90f7b74e3cc3280ec4d9b21c668f1b6249d2568d89d411815054d4210e644ed7a0619c52f767af601f354e682ca059d898bee7e233257564faf48
6
+ metadata.gz: 2ced3c9407d4dd0e50150361f9870a3c211eda077667d5a4cca1287e5d685b4327c9be2a9a23b4b774ff99e2ef4e3826ccee1f5034fe93980a88fa69c3d3fd2e
7
+ data.tar.gz: ed0d9167ca9b8f9a7001d00a09b4c53a6c7b16c18653abac0a7c41c9ce81b1ddbd3a3cedfc8ce9537497d6d99da38192c825629e7ab034065215be92842b422f
@@ -3,6 +3,24 @@
3
3
  ## master
4
4
 
5
5
 
6
+ ## v2.1.0
7
+
8
+ * Support for Xcode workspaces. Define `workspace` configuration in `.slather.yml` or use the `--workspace` argument if you build in a workspace.
9
+ * Improved slather error messages
10
+ [Kent Sutherland](https://github.com/ksuther)
11
+ [#178](https://github.com/SlatherOrg/slather/issues/178)
12
+
13
+ * Re-add Teamcity support
14
+ [Boris Bügling](https://github.com/neonichu)
15
+ [#180](https://github.com/SlatherOrg/slather/pull/180)
16
+
17
+ * Show lines that are hit thousands or millions of time in llvm-cov
18
+ [Kent Sutherland](https://github.com/ksuther)
19
+ [#179](https://github.com/SlatherOrg/slather/pull/179)
20
+
21
+ * Fix for setting scheme/workspace from configuration file.
22
+ [Boris Bügling](https://github.com/neonichu)
23
+ [#183](https://github.com/SlatherOrg/slather/pull/183)
6
24
 
7
25
  ## v2.0.2
8
26
 
data/README.md CHANGED
@@ -31,28 +31,38 @@ And then execute:
31
31
  $ bundle
32
32
  ```
33
33
 
34
+ Or install the gem:
35
+
36
+ ```sh
37
+ gem install slather
38
+ ```
39
+
34
40
  ## Usage
35
41
 
36
- Apple drastically improved the support for code coverage in Xcode 7, including dedicated UI for enabling it. You can now setup your project for test coverage inside the scheme editor, by ticking the *"Gather coverage data"* checkbox:
42
+ Enable test coverage by ticking the *"Gather coverage data"* checkbox when editing a scheme:
37
43
 
38
44
  ![](README_Images/test_scheme.png)
39
45
 
40
46
  To verify you're ready to generate test coverage, run your test suite on your project, and then run:
41
47
 
42
48
  ```sh
43
- $ slather coverage -s path/to/project.xcodeproj
49
+ $ slather coverage -s --scheme YourXcodeSchemeName path/to/project.xcodeproj
50
+ ```
51
+
52
+ If you use a workspace in Xcode you need to specify it:
53
+
54
+ ```sh
55
+ $ slather coverage -s --scheme YourXcodeSchemeName --workspace path/to/workspace.xcworkspace path/to/project.xcodeproj
44
56
  ```
45
57
 
46
- ### Previous versions of Xcode
58
+ ### Setup for Xode 5 and 6
47
59
 
48
- Set up your project for test coverage:
60
+ Run this command to enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project:
49
61
 
50
62
  ```sh
51
63
  $ slather setup path/to/project.xcodeproj
52
64
  ```
53
65
 
54
- This will enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project.
55
-
56
66
  ### Usage with Codecov
57
67
 
58
68
  Login to [Codecov](https://codecov.io/) (no need to activate a repository, this happens automatically). Right now, `slather` supports Codecov via **all** supported CI providers [listed here](https://github.com/codecov/codecov-bash#ci-providers).
@@ -64,6 +74,7 @@ Make a `.slather.yml` file:
64
74
 
65
75
  coverage_service: cobertura_xml
66
76
  xcodeproj: path/to/project.xcodeproj
77
+ scheme: YourXcodeSchemeName
67
78
  source_directory: path/to/sources/to/include
68
79
  output_directory: path/to/xml_report
69
80
  ignore:
@@ -105,6 +116,7 @@ Make a `.slather.yml` file:
105
116
 
106
117
  coverage_service: coveralls
107
118
  xcodeproj: path/to/project.xcodeproj
119
+ scheme: YourXcodeSchemeName
108
120
  ignore:
109
121
  - ExamplePodCode/*
110
122
  - ProjectTestsGroup/*
@@ -151,6 +163,7 @@ To create a Cobertura XML report set `cobertura_xml` as coverage service inside
151
163
 
152
164
  coverage_service: cobertura_xml
153
165
  xcodeproj: path/to/project.xcodeproj
166
+ scheme: YourXcodeSchemeName
154
167
  source_directory: path/to/sources/to/include
155
168
  output_directory: path/to/xml_report
156
169
  ignore:
@@ -169,7 +182,7 @@ $ slather coverage -x --output-directory path/to/xml_report
169
182
  To create a report as static html pages, use the command line options `--html`:
170
183
 
171
184
  ```sh
172
- $ slather coverage --html path/to/project.xcodeproj
185
+ $ slather coverage --html --scheme YourXcodeSchemeName path/to/project.xcodeproj
173
186
  ```
174
187
 
175
188
  This will make a directory named `html` in your root directory (unless `--output-directory` is specified) and will generate all the reports as static html pages inside the directory. It will print out the report's path by default, but you can also specify `--show` flag to open it in your browser automatically.
@@ -179,7 +192,7 @@ This will make a directory named `html` in your root directory (unless `--output
179
192
  To report the coverage statistics to TeamCity:
180
193
 
181
194
  ```sh
182
- $ slather coverage --teamcity -s
195
+ $ slather coverage --teamcity -s --scheme YourXcodeSchemeName
183
196
  ```
184
197
 
185
198
  ### Coverage for code included via CocoaPods
@@ -204,6 +217,14 @@ source_directory: Pods/AFNetworking
204
217
 
205
218
  Slather will look for the test coverage files in `DerivedData` by default. If you send build output to a custom location, like [this](https://github.com/erikdoe/ocmock/blob/7f4d22b38eedf1bb9a12ab1591ac0a5d436db61a/Tools/travis.sh#L12), then you should also set the `build_directory` property in `.slather.yml`
206
219
 
220
+ ### Building in a workspace
221
+
222
+ Include the `--workspace` argument or add `workspace` to `.slather.yml` if you build your project in a workspace. For example:
223
+
224
+ ```sh
225
+ $ slather coverage --html --scheme YourXcodeSchemeName --workspace path/to/workspace.xcworkspace path/to/project.xcodeproj
226
+ ```
227
+
207
228
  ## Contributing
208
229
 
209
230
  We’d love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We’ll do our best to respond to your patch as soon as possible. You can also submit a [new GitHub issue](https://github.com/SlatherOrg/slather/issues/new) if you find bugs or have questions. :octocat:
@@ -6,6 +6,7 @@ class CoverageCommand < Clamp::Command
6
6
  option ["--circleci"], :flag, "Indicate that the builds are running on CircleCI"
7
7
  option ["--jenkins"], :flag, "Indicate that the builds are running on Jenkins"
8
8
  option ["--buildkite"], :flag, "Indicate that the builds are running on Buildkite"
9
+ option ["--teamcity"], :flag, "Indicate that the builds are running on TeamCity"
9
10
 
10
11
  option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
11
12
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
@@ -22,6 +23,7 @@ class CoverageCommand < Clamp::Command
22
23
 
23
24
  option ["--input-format"], "INPUT_FORMAT", "Input format (gcov, profdata)"
24
25
  option ["--scheme"], "SCHEME", "The scheme for which the coverage was generated"
26
+ option ["--workspace"], "WORKSPACE", "The workspace that the project was built in"
25
27
  option ["--binary-file"], "BINARY_FILE", "The binary file against the which the coverage will be run"
26
28
  option ["--binary-basename"], "BINARY_BASENAME", "Basename of the file against which the coverage will be run"
27
29
 
@@ -37,6 +39,7 @@ class CoverageCommand < Clamp::Command
37
39
  setup_verbose_mode
38
40
  setup_input_format
39
41
  setup_scheme
42
+ setup_workspace
40
43
  setup_binary_file
41
44
  setup_binary_basename
42
45
 
@@ -72,6 +75,8 @@ class CoverageCommand < Clamp::Command
72
75
  project.ci_service = :jenkins
73
76
  elsif buildkite?
74
77
  project.ci_service = :buildkite
78
+ elsif teamcity?
79
+ project.ci_service = :teamcity
75
80
  end
76
81
  end
77
82
 
@@ -117,6 +122,10 @@ class CoverageCommand < Clamp::Command
117
122
  project.scheme = scheme
118
123
  end
119
124
 
125
+ def setup_workspace
126
+ project.workspace = workspace
127
+ end
128
+
120
129
  def setup_binary_file
121
130
  project.binary_file = binary_file
122
131
  end
@@ -76,17 +76,27 @@ module Slather
76
76
  line =~ /^(\s*)(\d*)\|/
77
77
 
78
78
  if $2 == nil
79
- return nil
80
- end
79
+ # Check for thousands or millions (llvm-cov outputs hit counts as 25.3k or 3.8M)
80
+ did_match = line =~ /^(\s*)(\d+\.\d+)(k|M)\|/
81
+
82
+ if did_match
83
+ count = $2.strip
84
+ units = $3 == 'k' ? 1000 : 1000000
81
85
 
82
- match = $2.strip
83
- case match
84
- when /[0-9]+/
85
- match.to_i
86
- when /#+/
87
- 0
88
- when "-"
89
- nil
86
+ count.to_f * units
87
+ else
88
+ return nil
89
+ end
90
+ else
91
+ match = $2.strip
92
+ case match
93
+ when /[0-9]+/
94
+ match.to_i
95
+ when /#+/
96
+ 0
97
+ when "-"
98
+ nil
99
+ end
90
100
  end
91
101
  end
92
102
 
@@ -51,7 +51,7 @@ module Slather
51
51
  class Project < Xcodeproj::Project
52
52
 
53
53
  attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory,
54
- :output_directory, :xcodeproj, :show_html, :verbose_mode, :input_format, :scheme, :binary_file, :binary_basename
54
+ :output_directory, :xcodeproj, :show_html, :verbose_mode, :input_format, :scheme, :workspace, :binary_file, :binary_basename
55
55
 
56
56
  alias_method :setup_for_coverage, :slather_setup_for_coverage
57
57
 
@@ -61,15 +61,29 @@ module Slather
61
61
  proj
62
62
  end
63
63
 
64
+ def failure_help_string
65
+ "\n\tAre you sure your project is generating coverage? Make sure you enable code coverage in the Test section of your Xcode scheme.\n\tDid you specify your Xcode scheme? (--scheme or 'scheme' in .slather.yml)\n\tIf you're using a workspace, did you specify it? (--workspace or 'workspace' in .slather.yml)"
66
+ end
67
+
64
68
  def derived_data_path
65
69
  # Get the derived data path from xcodebuild
66
70
  # Use OBJROOT when possible, as it provides regardless of whether or not the Derived Data location is customized
71
+ if self.workspace
72
+ projectOrWorkspaceArgument = "-workspace \"#{self.workspace}\""
73
+ else
74
+ projectOrWorkspaceArgument = "-project \"#{self.path}\""
75
+ end
76
+
67
77
  if self.scheme
68
- build_settings = `xcodebuild -project "#{self.path}" -scheme "#{self.scheme}" -showBuildSettings`
78
+ schemeArgument = "-scheme \"#{self.scheme}\""
79
+ buildAction = "test"
69
80
  else
70
- build_settings = `xcodebuild -project "#{self.path}" -showBuildSettings`
81
+ schemeArgument = nil
82
+ buildAction = nil
71
83
  end
72
84
 
85
+ build_settings = `xcodebuild #{projectOrWorkspaceArgument} #{schemeArgument} -showBuildSettings #{buildAction}`
86
+
73
87
  if build_settings
74
88
  derived_data_path = build_settings.match(/ OBJROOT = (.+)/)[1]
75
89
  end
@@ -99,7 +113,7 @@ module Slather
99
113
  end.compact
100
114
 
101
115
  if coverage_files.empty?
102
- raise StandardError, "No coverage files found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.xcodeproj`"
116
+ raise StandardError, "No coverage files found."
103
117
  else
104
118
  dedupe(coverage_files)
105
119
  end
@@ -141,7 +155,7 @@ module Slather
141
155
  dir = Dir[File.join("#{build_directory}","/**/CodeCoverage")].first
142
156
  end
143
157
 
144
- raise StandardError, "No coverage directory found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.xcodeproj`" unless dir != nil
158
+ raise StandardError, "No coverage directory found." unless dir != nil
145
159
  dir
146
160
  end
147
161
 
@@ -193,16 +207,24 @@ module Slather
193
207
  end
194
208
 
195
209
  def configure
196
- configure_build_directory
197
- configure_ignore_list
198
- configure_ci_service
199
- configure_coverage_access_token
200
- configure_coverage_service
201
- configure_source_directory
202
- configure_output_directory
203
- configure_input_format
204
- configure_scheme
205
- configure_binary_file
210
+ begin
211
+ configure_scheme
212
+ configure_workspace
213
+ configure_build_directory
214
+ configure_ignore_list
215
+ configure_ci_service
216
+ configure_coverage_access_token
217
+ configure_coverage_service
218
+ configure_source_directory
219
+ configure_output_directory
220
+ configure_input_format
221
+ configure_binary_file
222
+ rescue => e
223
+ puts e.message
224
+ puts failure_help_string
225
+ puts "\n"
226
+ raise
227
+ end
206
228
 
207
229
  if self.verbose_mode
208
230
  puts "\nProcessing coverage file: #{profdata_file}"
@@ -250,6 +272,10 @@ module Slather
250
272
  self.scheme ||= self.class.yml["scheme"] if self.class.yml["scheme"]
251
273
  end
252
274
 
275
+ def configure_workspace
276
+ self.workspace ||= self.class.yml["workspace"] if self.class.yml["workspace"]
277
+ end
278
+
253
279
  def ci_service=(service)
254
280
  @ci_service = service && service.to_sym
255
281
  end
@@ -301,9 +327,22 @@ module Slather
301
327
  if self.scheme
302
328
  schemes_path = Xcodeproj::XCScheme.shared_data_dir(self.path)
303
329
  xcscheme_path = "#{schemes_path + self.scheme}.xcscheme"
330
+
331
+ raise StandardError, "No shared scheme named '#{self.scheme}' found in #{self.path}" unless File.exists? xcscheme_path
332
+
304
333
  xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
305
334
 
306
- buildable_name = xcscheme.build_action.entries[0].buildable_references[0].buildable_name
335
+ begin
336
+ buildable_name = xcscheme.build_action.entries[0].buildable_references[0].buildable_name
337
+ rescue
338
+ # xcodeproj will raise an exception if there are no entries in the build action
339
+ end
340
+
341
+ if buildable_name == nil or buildable_name.end_with? ".a"
342
+ # Can't run code coverage on static libraries, look for an associated test bundle
343
+ buildable_name = xcscheme.test_action.testables[0].buildable_references[0].buildable_name
344
+ end
345
+
307
346
  configuration = xcscheme.test_action.build_configuration
308
347
 
309
348
  search_for = binary_basename || buildable_name
@@ -344,10 +383,9 @@ module Slather
344
383
  end
345
384
  end
346
385
 
347
- raise StandardError, "No product binary found in #{profdata_coverage_dir}. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.xcodeproj`" unless found_binary != nil
386
+ raise StandardError, "No product binary found in #{profdata_coverage_dir}." unless found_binary != nil
348
387
 
349
388
  found_binary
350
389
  end
351
-
352
390
  end
353
391
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.6"
21
21
  spec.add_development_dependency "coveralls"
22
+ spec.add_development_dependency "simplecov"
22
23
  spec.add_development_dependency "rake", "~> 10.4"
23
24
  spec.add_development_dependency "rspec", "~> 3.4"
24
25
  spec.add_development_dependency "pry", "~> 0.9"
@@ -23,10 +23,10 @@
23
23
  </BuildActionEntries>
24
24
  </BuildAction>
25
25
  <TestAction
26
+ buildConfiguration = "Debug"
26
27
  selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
27
28
  selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28
- shouldUseLaunchSchemeArgsEnv = "YES"
29
- buildConfiguration = "Debug">
29
+ shouldUseLaunchSchemeArgsEnv = "YES">
30
30
  <Testables>
31
31
  <TestableReference
32
32
  skipped = "NO">
@@ -39,24 +39,36 @@
39
39
  </BuildableReference>
40
40
  </TestableReference>
41
41
  </Testables>
42
+ <AdditionalOptions>
43
+ </AdditionalOptions>
42
44
  </TestAction>
43
45
  <LaunchAction
46
+ buildConfiguration = "Debug"
44
47
  selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
45
48
  selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
46
49
  launchStyle = "0"
47
50
  useCustomWorkingDirectory = "NO"
48
- buildConfiguration = "Debug"
49
51
  ignoresPersistentStateOnLaunch = "NO"
50
52
  debugDocumentVersioning = "YES"
53
+ debugServiceExtension = "internal"
51
54
  allowLocationSimulation = "YES">
55
+ <MacroExpansion>
56
+ <BuildableReference
57
+ BuildableIdentifier = "primary"
58
+ BlueprintIdentifier = "8C9A202C195965F10013B6B3"
59
+ BuildableName = "libfixtures.a"
60
+ BlueprintName = "fixtures"
61
+ ReferencedContainer = "container:fixtures.xcodeproj">
62
+ </BuildableReference>
63
+ </MacroExpansion>
52
64
  <AdditionalOptions>
53
65
  </AdditionalOptions>
54
66
  </LaunchAction>
55
67
  <ProfileAction
68
+ buildConfiguration = "Release"
56
69
  shouldUseLaunchSchemeArgsEnv = "YES"
57
70
  savedToolIdentifier = ""
58
71
  useCustomWorkingDirectory = "NO"
59
- buildConfiguration = "Release"
60
72
  debugDocumentVersioning = "YES">
61
73
  </ProfileAction>
62
74
  <AnalyzeAction
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "0600"
4
+ version = "1.3">
5
+ <BuildAction
6
+ parallelizeBuildables = "YES"
7
+ buildImplicitDependencies = "YES">
8
+ </BuildAction>
9
+ <TestAction
10
+ buildConfiguration = "Debug"
11
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13
+ shouldUseLaunchSchemeArgsEnv = "YES">
14
+ <Testables>
15
+ <TestableReference
16
+ skipped = "NO">
17
+ <BuildableReference
18
+ BuildableIdentifier = "primary"
19
+ BlueprintIdentifier = "8C9A203F195965F10013B6B3"
20
+ BuildableName = "fixturesTests.xctest"
21
+ BlueprintName = "fixturesTests"
22
+ ReferencedContainer = "container:fixtures.xcodeproj">
23
+ </BuildableReference>
24
+ </TestableReference>
25
+ </Testables>
26
+ <AdditionalOptions>
27
+ </AdditionalOptions>
28
+ </TestAction>
29
+ <LaunchAction
30
+ buildConfiguration = "Debug"
31
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33
+ launchStyle = "0"
34
+ useCustomWorkingDirectory = "NO"
35
+ ignoresPersistentStateOnLaunch = "NO"
36
+ debugDocumentVersioning = "YES"
37
+ debugServiceExtension = "internal"
38
+ allowLocationSimulation = "YES">
39
+ <AdditionalOptions>
40
+ </AdditionalOptions>
41
+ </LaunchAction>
42
+ <ProfileAction
43
+ buildConfiguration = "Release"
44
+ shouldUseLaunchSchemeArgsEnv = "YES"
45
+ savedToolIdentifier = ""
46
+ useCustomWorkingDirectory = "NO"
47
+ debugDocumentVersioning = "YES">
48
+ </ProfileAction>
49
+ <AnalyzeAction
50
+ buildConfiguration = "Debug">
51
+ </AnalyzeAction>
52
+ <ArchiveAction
53
+ buildConfiguration = "Release"
54
+ revealArchiveInOrganizer = "YES">
55
+ </ArchiveAction>
56
+ </Scheme>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:fixtures.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
@@ -1,6 +1,6 @@
1
1
  require 'cocoapods'
2
- require File.join(File.dirname(__FILE__), '../../lib/cocoapods_plugin')
3
2
  require File.join(File.dirname(__FILE__), '..', 'spec_helper')
3
+ require File.join(File.dirname(__FILE__), '../../lib/cocoapods_plugin')
4
4
 
5
5
  describe Slather do
6
6
  describe 'CocoaPods Plugin' do
@@ -79,6 +79,18 @@ describe Slather::ProfdataCoverageFile do
79
79
  it "should return the number of hits for the line" do
80
80
  expect(profdata_coverage_file.coverage_for_line(" 10| 40| func applicationWillTerminate(application: UIApplication) {")).to eq(10)
81
81
  end
82
+
83
+ it "should return the number of hits for a line in thousands" do
84
+ expect(profdata_coverage_file.coverage_for_line(" 11.8k| 49| return result;")).to eq(11800)
85
+ end
86
+
87
+ it "should return the number of hits for a line in millions" do
88
+ expect(profdata_coverage_file.coverage_for_line(" 2.58M| 49| return result;")).to eq(2580000)
89
+ end
90
+
91
+ it "should return the number of hits for an uncovered line" do
92
+ expect(profdata_coverage_file.coverage_for_line(" 0| 49| return result;")).to eq(0)
93
+ end
82
94
  end
83
95
 
84
96
  describe "#num_lines_tested" do
@@ -135,9 +135,25 @@ describe Slather::Project do
135
135
  end
136
136
 
137
137
  it "should find the product path provided a scheme" do
138
+ allow(fixtures_project).to receive(:scheme).and_return("fixtures")
139
+ fixtures_project.send(:configure_binary_file)
140
+ binary_file_location = fixtures_project.send(:binary_file)
141
+ expect(binary_file_location).to end_with("Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests")
142
+ end
143
+
144
+ it "should find the product path provided a workspace and scheme" do
145
+ allow(fixtures_project).to receive(:workspace).and_return("fixtures.xcworkspace")
146
+ allow(fixtures_project).to receive(:scheme).and_return("fixtures")
147
+ fixtures_project.send(:configure_binary_file)
148
+ binary_file_location = fixtures_project.send(:binary_file)
149
+ expect(binary_file_location).to end_with("Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests")
150
+ end
151
+
152
+ it "should find the product path for a scheme with no buildable products" do
153
+ allow(fixtures_project).to receive(:scheme).and_return("fixturesTests")
138
154
  fixtures_project.send(:configure_binary_file)
139
155
  binary_file_location = fixtures_project.send(:binary_file)
140
- expect(binary_file_location).to end_with("Debug/libfixtures.a")
156
+ expect(binary_file_location).to end_with("Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests")
141
157
  end
142
158
 
143
159
  let(:fixture_yaml) do
@@ -202,6 +218,7 @@ describe Slather::Project do
202
218
  expect(unstubbed_project).to receive(:configure_coverage_service)
203
219
  expect(unstubbed_project).to receive(:configure_input_format)
204
220
  expect(unstubbed_project).to receive(:configure_scheme)
221
+ expect(unstubbed_project).to receive(:configure_workspace)
205
222
  unstubbed_project.configure
206
223
  end
207
224
  end
@@ -284,6 +301,21 @@ describe Slather::Project do
284
301
  end
285
302
  end
286
303
 
304
+ describe "#configure_workspace" do
305
+ it "should set the workspace if it has been provided in the yml and has not already been set" do
306
+ allow(Slather::Project).to receive(:yml).and_return({"workspace" => "fixtures.xcworkspace"})
307
+ fixtures_project.configure_workspace
308
+ expect(fixtures_project.workspace).to eq("fixtures.xcworkspace")
309
+ end
310
+
311
+ it "should not set the workspace if it has already been set" do
312
+ allow(Slather::Project).to receive(:yml).and_return({"workspace" => "fixtures.xcworkspace"})
313
+ fixtures_project.workspace = "MyWorkspace.xcworkspace"
314
+ fixtures_project.configure_workspace
315
+ expect(fixtures_project.workspace).to eq("MyWorkspace.xcworkspace")
316
+ end
317
+ end
318
+
287
319
  describe "#configure_ci_service" do
288
320
  it "should set the ci_service if it has been provided in the yml and has not already been set" do
289
321
  allow(Slather::Project).to receive(:yml).and_return({"ci_service" => "some_service"})
@@ -394,7 +426,10 @@ describe Slather::Project do
394
426
  xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
395
427
  expect(xcscheme.test_action.xml_element.attributes['codeCoverageEnabled']).to eq("YES")
396
428
  end
429
+ end
397
430
 
431
+ it "should fail for unknown coverage type" do
432
+ expect { fixtures_project_setup.slather_setup_for_coverage "this should fail" }.to raise_error(StandardError)
398
433
  end
399
434
  end
400
435
 
@@ -1,5 +1,10 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ if ENV['SIMPLECOV']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ else
5
+ require 'coveralls'
6
+ Coveralls.wear!
7
+ end
3
8
 
4
9
  require 'slather'
5
10
  require 'pry'
@@ -11,9 +16,11 @@ FIXTURES_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/cobertura.xml')
11
16
  FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
12
17
  FIXTURES_HTML_FOLDER_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures_html')
13
18
  FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
19
+ FIXTURES_WORKSPACE_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcworkspace')
14
20
  FIXTURES_SWIFT_FILE_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures/Fixtures.swift')
15
21
  TEMP_DERIVED_DATA_PATH = File.join(File.dirname(__FILE__), 'DerivedData')
16
22
  TEMP_PROJECT_BUILD_PATH = File.join(TEMP_DERIVED_DATA_PATH, "libfixtures")
23
+ TEMP_WORKSPACE_BUILD_PATH = File.join(TEMP_DERIVED_DATA_PATH, "libfixtures")
17
24
  TEMP_OBJC_GCNO_PATH = File.join(File.dirname(__FILE__), 'fixtures/ObjectiveC.gcno')
18
25
  TEMP_OBJC_GCDA_PATH = File.join(File.dirname(__FILE__), 'fixtures/ObjectiveC.gcda')
19
26
 
@@ -41,6 +48,7 @@ RSpec.configure do |config|
41
48
  FixtureHelpers.delete_derived_data
42
49
  FixtureHelpers.delete_temp_gcov_files
43
50
  `xcodebuild -project "#{FIXTURES_PROJECT_PATH}" -scheme fixtures -configuration Debug -derivedDataPath #{TEMP_PROJECT_BUILD_PATH} -enableCodeCoverage YES clean test`
51
+ `xcodebuild -workspace "#{FIXTURES_WORKSPACE_PATH}" -scheme fixtures -configuration Debug -derivedDataPath #{TEMP_WORKSPACE_BUILD_PATH} -enableCodeCoverage YES clean test`
44
52
  end
45
53
 
46
54
  config.after(:suite) do
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.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -219,6 +233,8 @@ files:
219
233
  - spec/fixtures/fixtures.xcodeproj/project.pbxproj
220
234
  - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
221
235
  - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
236
+ - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixturesTests.xcscheme
237
+ - spec/fixtures/fixtures.xcworkspace/contents.xcworkspacedata
222
238
  - spec/fixtures/fixtures/Fixtures.swift
223
239
  - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
224
240
  - spec/fixtures/fixtures/fixtures.h
@@ -289,6 +305,8 @@ test_files:
289
305
  - spec/fixtures/fixtures.xcodeproj/project.pbxproj
290
306
  - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
291
307
  - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
308
+ - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixturesTests.xcscheme
309
+ - spec/fixtures/fixtures.xcworkspace/contents.xcworkspacedata
292
310
  - spec/fixtures/fixtures/Fixtures.swift
293
311
  - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
294
312
  - spec/fixtures/fixtures/fixtures.h