slather 1.8.3 → 2.0.0
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 +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +21 -1
- data/README.md +15 -10
- data/README_Images/test_scheme.png +0 -0
- data/Rakefile +6 -0
- data/bin/slather +45 -6
- data/lib/slather/coverage_file.rb +37 -90
- data/lib/slather/coverage_info.rb +84 -0
- data/lib/slather/coverage_service/cobertura_xml_output.rb +10 -6
- data/lib/slather/coverage_service/coveralls.rb +5 -1
- data/lib/slather/coverage_service/gutter_json_output.rb +12 -8
- data/lib/slather/coverage_service/hardcover.rb +5 -1
- data/lib/slather/coverage_service/html_output.rb +32 -19
- data/lib/slather/coverage_service/simple_output.rb +5 -1
- data/lib/slather/{coveralls_coverage_file.rb → coveralls_coverage.rb} +1 -1
- data/lib/slather/profdata_coverage_file.rb +130 -0
- data/lib/slather/project.rb +191 -27
- data/lib/slather/version.rb +1 -1
- data/lib/slather.rb +9 -1
- data/slather.gemspec +4 -4
- data/spec/fixtures/cobertura.xml +56 -79
- data/spec/fixtures/fixtures/Fixtures.swift +15 -0
- data/spec/fixtures/fixtures/other_fixtures.m +23 -0
- data/spec/fixtures/fixtures_html/Branches.m.html +244 -258
- data/spec/fixtures/fixtures_html/BranchesTests.m.html +209 -225
- data/spec/fixtures/fixtures_html/fixtures.m.html +134 -148
- data/spec/fixtures/fixtures_html/fixturesTests.m.html +199 -213
- data/spec/fixtures/fixtures_html/index.html +68 -131
- data/spec/fixtures/fixtures_html/peekaviewTests.m.html +189 -203
- data/spec/fixtures/gutter.json +1 -1
- data/spec/slather/coverage_file_spec.rb +20 -12
- data/spec/slather/coverage_service/cobertura_xml_spec.rb +7 -3
- data/spec/slather/coverage_service/coveralls_spec.rb +61 -20
- data/spec/slather/coverage_service/gutter_json_spec.rb +6 -2
- data/spec/slather/coverage_service/hardcover_spec.rb +33 -3
- data/spec/slather/coverage_service/html_output_spec.rb +48 -7
- data/spec/slather/coverage_service/simple_output_spec.rb +12 -13
- data/spec/slather/profdata_coverage_spec.rb +128 -0
- data/spec/slather/project_spec.rb +222 -49
- data/spec/spec_helper.rb +28 -2
- metadata +58 -46
- data/spec/fixtures/fixtures_html/Empty.m.html +0 -30
- data/spec/fixtures/fixtures_html/fixtures_cpp.cpp.html +0 -30
- data/spec/fixtures/fixtures_html/fixtures_m.m.html +0 -30
- data/spec/fixtures/fixtures_html/fixtures_mm.mm.html +0 -30
- data/spec/fixtures/fixtures_html/peekaview.m.html +0 -190
@@ -2,21 +2,15 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
2
2
|
|
3
3
|
describe Slather::Project do
|
4
4
|
|
5
|
+
FIXTURES_PROJECT_SETUP_PATH = 'fixtures_setup.xcodeproj'
|
6
|
+
|
5
7
|
let(:fixtures_project) do
|
6
|
-
Slather::Project.any_instance.stub(:configure_from_yml)
|
7
8
|
Slather::Project.open(FIXTURES_PROJECT_PATH)
|
8
9
|
end
|
9
10
|
|
10
|
-
describe "
|
11
|
-
it "should return a project instance that has been configured from yml" do
|
12
|
-
expect_any_instance_of(Slather::Project).to receive(:configure_from_yml)
|
13
|
-
expect(fixtures_project).not_to be_nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#derived_data_dir" do
|
11
|
+
describe "#derived_data_path" do
|
18
12
|
it "should return the system's derived data directory" do
|
19
|
-
expect(fixtures_project.send(:
|
13
|
+
expect(fixtures_project.send(:derived_data_path)).to eq(File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/")
|
20
14
|
end
|
21
15
|
end
|
22
16
|
|
@@ -27,10 +21,10 @@ describe Slather::Project do
|
|
27
21
|
expect(fixtures_project.build_directory).to eq(build_directory_mock)
|
28
22
|
end
|
29
23
|
|
30
|
-
it "should return the
|
31
|
-
|
32
|
-
fixtures_project.
|
33
|
-
expect(fixtures_project.build_directory).to eq(
|
24
|
+
it "should return the derived_data_path if no build_directory has been set" do
|
25
|
+
derived_data_path = File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/"
|
26
|
+
fixtures_project.send(:configure_build_directory)
|
27
|
+
expect(fixtures_project.build_directory).to eq(derived_data_path)
|
34
28
|
end
|
35
29
|
end
|
36
30
|
|
@@ -82,6 +76,136 @@ describe Slather::Project do
|
|
82
76
|
end
|
83
77
|
end
|
84
78
|
|
79
|
+
describe "#profdata_coverage_files" do
|
80
|
+
class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
|
81
|
+
end
|
82
|
+
|
83
|
+
before(:each) do
|
84
|
+
Dir.stub(:[]).and_call_original
|
85
|
+
Dir.stub(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
|
86
|
+
fixtures_project.stub(:profdata_llvm_cov_output).and_return("#{FIXTURES_SWIFT_FILE_PATH}:
|
87
|
+
| 0|
|
88
|
+
| 1|import UIKit
|
89
|
+
| 2|
|
90
|
+
| 3|@UIApplicationMain
|
91
|
+
| 4|class AppDelegate: UIResponder, UIApplicationDelegate {
|
92
|
+
| 5|
|
93
|
+
| 6| var window: UIWindow?
|
94
|
+
| 7|
|
95
|
+
1| 8| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
96
|
+
1| 9| return true
|
97
|
+
1| 10| }
|
98
|
+
| 11|
|
99
|
+
0| 12| func applicationWillResignActive(application: UIApplication) {
|
100
|
+
0| 13| }
|
101
|
+
0| 14|}")
|
102
|
+
fixtures_project.stub(:coverage_file_class).and_return(SpecXcode7CoverageFile)
|
103
|
+
fixtures_project.stub(:ignore_list).and_return([])
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return Coverage.profdata file objects" do
|
107
|
+
profdata_coverage_files = fixtures_project.send(:profdata_coverage_files)
|
108
|
+
profdata_coverage_files.each { |cf| expect(cf.kind_of?(SpecXcode7CoverageFile)).to be_truthy }
|
109
|
+
expect(profdata_coverage_files.map { |cf| cf.source_file_pathname.basename.to_s }).to eq(["Fixtures.swift"])
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should ignore files from the ignore list" do
|
113
|
+
fixtures_project.stub(:ignore_list).and_return(["**/Fixtures.swift"])
|
114
|
+
profdata_coverage_files = fixtures_project.send(:profdata_coverage_files)
|
115
|
+
expect(profdata_coverage_files.count).to eq(0)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#invalid_characters" do
|
120
|
+
it "should correctly encode invalid characters" do
|
121
|
+
fixtures_project.stub(:input_format).and_return("profdata")
|
122
|
+
fixtures_project.stub(:ignore_list).and_return([])
|
123
|
+
Dir.stub(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
|
124
|
+
fixtures_project.stub(:unsafe_profdata_llvm_cov_output).and_return("#{FIXTURES_SWIFT_FILE_PATH}:
|
125
|
+
1| 8| func application(application: \255, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
126
|
+
1| 9| return true
|
127
|
+
0| 14|}")
|
128
|
+
fixtures_project.extend(Slather::CoverageService::HtmlOutput)
|
129
|
+
profdata_coverage_files = fixtures_project.send(:profdata_coverage_files)
|
130
|
+
expect(profdata_coverage_files.count).to eq(1)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#binary_file" do
|
135
|
+
|
136
|
+
let(:build_directory) do
|
137
|
+
TEMP_DERIVED_DATA_PATH
|
138
|
+
end
|
139
|
+
|
140
|
+
before(:each) do
|
141
|
+
Dir.stub(:[]).and_call_original
|
142
|
+
fixtures_project.stub(:build_directory).and_return(build_directory)
|
143
|
+
fixtures_project.stub(:input_format).and_return("profdata")
|
144
|
+
fixtures_project.stub(:scheme).and_return("FixtureScheme")
|
145
|
+
Dir.stub(:[]).with("#{build_directory}/**/CodeCoverage/FixtureScheme").and_return(["#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme"])
|
146
|
+
Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/**/*.xctest").and_return(["#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/FixtureAppTests.xctest"])
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return the binary file location for an app bundle provided a scheme" do
|
150
|
+
Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/*.app").and_return(["/FixtureScheme/FixtureApp.app"])
|
151
|
+
Dir.stub(:[]).with("/FixtureScheme/FixtureApp.app/**/FixtureApp").and_return(["/FixtureScheme/FixtureApp.app/FixtureApp"])
|
152
|
+
fixtures_project.send(:configure_binary_file)
|
153
|
+
binary_file_location = fixtures_project.send(:binary_file)
|
154
|
+
expect(binary_file_location).to eq("/FixtureScheme/FixtureApp.app/FixtureApp")
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should return the binary file location for a framework bundle provided a scheme" do
|
158
|
+
Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/*.framework").and_return(["/FixtureScheme/FixtureFramework.framework"])
|
159
|
+
fixtures_project.send(:configure_binary_file)
|
160
|
+
binary_file_location = fixtures_project.send(:binary_file)
|
161
|
+
expect(binary_file_location).to eq("/FixtureScheme/FixtureFramework.framework/FixtureFramework")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should return the binary file location for a test bundle provided a scheme" do
|
165
|
+
Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/FixtureAppTests.xctest/**/FixtureAppTests").and_return(["/FixtureScheme/FixtureAppTests.xctest/Contents/MacOS/FixtureAppTests"])
|
166
|
+
fixtures_project.send(:configure_binary_file)
|
167
|
+
binary_file_location = fixtures_project.send(:binary_file)
|
168
|
+
expect(binary_file_location).to eq("/FixtureScheme/FixtureAppTests.xctest/Contents/MacOS/FixtureAppTests")
|
169
|
+
end
|
170
|
+
|
171
|
+
let(:fixture_yaml) do
|
172
|
+
yaml_text = <<-EOF
|
173
|
+
binary_file: "/FixtureScheme/From/Yaml/Contents/MacOS/FixturesFromYaml"
|
174
|
+
EOF
|
175
|
+
yaml = YAML.load(yaml_text)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should configure the binary_file from yml" do
|
179
|
+
Slather::Project.stub(:yml).and_return(fixture_yaml)
|
180
|
+
fixtures_project.send(:configure_binary_file)
|
181
|
+
binary_file_location = fixtures_project.send(:binary_file)
|
182
|
+
expect(binary_file_location).to eq("/FixtureScheme/From/Yaml/Contents/MacOS/FixturesFromYaml")
|
183
|
+
end
|
184
|
+
|
185
|
+
let(:other_fixture_yaml) do
|
186
|
+
yaml_text = <<-EOF
|
187
|
+
binary_basename: "FixtureFramework"
|
188
|
+
EOF
|
189
|
+
yaml = YAML.load(yaml_text)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should configure the binary_basename from yml" do
|
193
|
+
Slather::Project.stub(:yml).and_return(other_fixture_yaml)
|
194
|
+
Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/FixtureFramework.framework").and_return(["/FixtureScheme/FixtureFramework.framework"])
|
195
|
+
fixtures_project.send(:configure_binary_file)
|
196
|
+
binary_file_location = fixtures_project.send(:binary_file)
|
197
|
+
expect(binary_file_location).to eq("/FixtureScheme/FixtureFramework.framework/FixtureFramework")
|
198
|
+
end
|
199
|
+
|
200
|
+
# it "should find the binary file without any yml setting" do
|
201
|
+
# fixtures_project.configure_binary_file
|
202
|
+
# Dir.stub(:[]).with("#{build_directory}/Build/Intermediates/CodeCoverage/FixtureScheme/*.app").and_return(["/FixtureScheme/FixtureApp.app"])
|
203
|
+
# Dir.stub(:[]).with("/FixtureScheme/FixtureApp.app/**/FixtureApp").and_return(["/FixtureScheme/FixtureApp.app/FixtureApp"])
|
204
|
+
# binary_file_location = fixtures_project.send(:binary_file)
|
205
|
+
# expect(binary_file_location).to eq("/FixtureScheme/FixtureApp.app/FixtureApp")
|
206
|
+
# end
|
207
|
+
end
|
208
|
+
|
85
209
|
describe "#dedupe" do
|
86
210
|
it "should return a deduplicated list of coverage files, favoring the file with higher coverage" do
|
87
211
|
coverage_file_1 = double(Slather::CoverageFile)
|
@@ -104,113 +228,115 @@ describe Slather::Project do
|
|
104
228
|
end
|
105
229
|
end
|
106
230
|
|
107
|
-
describe "#
|
231
|
+
describe "#configure" do
|
108
232
|
it "should configure all properties from the yml" do
|
109
233
|
unstubbed_project = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
110
|
-
expect(unstubbed_project).to receive(:
|
111
|
-
expect(unstubbed_project).to receive(:
|
112
|
-
expect(unstubbed_project).to receive(:
|
113
|
-
expect(unstubbed_project).to receive(:
|
114
|
-
expect(unstubbed_project).to receive(:
|
115
|
-
unstubbed_project.
|
234
|
+
expect(unstubbed_project).to receive(:configure_build_directory)
|
235
|
+
expect(unstubbed_project).to receive(:configure_source_directory)
|
236
|
+
expect(unstubbed_project).to receive(:configure_ignore_list)
|
237
|
+
expect(unstubbed_project).to receive(:configure_ci_service)
|
238
|
+
expect(unstubbed_project).to receive(:configure_coverage_service)
|
239
|
+
expect(unstubbed_project).to receive(:configure_input_format)
|
240
|
+
expect(unstubbed_project).to receive(:configure_scheme)
|
241
|
+
unstubbed_project.configure
|
116
242
|
end
|
117
243
|
end
|
118
244
|
|
119
|
-
describe "#
|
245
|
+
describe "#configure_ignore_list" do
|
120
246
|
it "should set the ignore_list if it has been provided in the yml and has not already been set" do
|
121
247
|
Slather::Project.stub(:yml).and_return({"ignore" => ["test", "ing"] })
|
122
|
-
fixtures_project.
|
248
|
+
fixtures_project.configure_ignore_list
|
123
249
|
expect(fixtures_project.ignore_list).to eq(["test", "ing"])
|
124
250
|
end
|
125
251
|
|
126
252
|
it "should force the ignore_list into an array" do
|
127
253
|
Slather::Project.stub(:yml).and_return({"ignore" => "test" })
|
128
|
-
fixtures_project.
|
254
|
+
fixtures_project.configure_ignore_list
|
129
255
|
expect(fixtures_project.ignore_list).to eq(["test"])
|
130
256
|
end
|
131
257
|
|
132
258
|
it "should not set the ignore_list if it has already been set" do
|
133
259
|
Slather::Project.stub(:yml).and_return({"ignore" => ["test", "ing"] })
|
134
260
|
fixtures_project.ignore_list = ["already", "set"]
|
135
|
-
fixtures_project.
|
261
|
+
fixtures_project.configure_ignore_list
|
136
262
|
expect(fixtures_project.ignore_list).to eq(["already", "set"])
|
137
263
|
end
|
138
264
|
|
139
265
|
it "should default the ignore_list to an empty array if nothing is provided in the yml" do
|
140
266
|
Slather::Project.stub(:yml).and_return({})
|
141
|
-
fixtures_project.
|
267
|
+
fixtures_project.configure_ignore_list
|
142
268
|
expect(fixtures_project.ignore_list).to eq([])
|
143
269
|
end
|
144
270
|
end
|
145
271
|
|
146
|
-
describe "#
|
272
|
+
describe "#configure_build_directory" do
|
147
273
|
it "should set the build_directory if it has been provided in the yml and has not already been set" do
|
148
274
|
Slather::Project.stub(:yml).and_return({"build_directory" => "/some/path"})
|
149
|
-
fixtures_project.
|
275
|
+
fixtures_project.configure_build_directory
|
150
276
|
expect(fixtures_project.build_directory).to eq("/some/path")
|
151
277
|
end
|
152
278
|
|
153
279
|
it "should not set the build_directory if it has already been set" do
|
154
280
|
Slather::Project.stub(:yml).and_return({"build_directory" => "/some/path"})
|
155
281
|
fixtures_project.build_directory = "/already/set"
|
156
|
-
fixtures_project.
|
282
|
+
fixtures_project.configure_build_directory
|
157
283
|
expect(fixtures_project.build_directory).to eq("/already/set")
|
158
284
|
end
|
159
285
|
|
160
286
|
it "should default the build_directory to derived data if nothing is provided in the yml" do
|
161
287
|
Slather::Project.stub(:yml).and_return({})
|
162
|
-
fixtures_project.
|
163
|
-
expect(fixtures_project.build_directory).to eq(fixtures_project.send(:
|
288
|
+
fixtures_project.configure_build_directory
|
289
|
+
expect(fixtures_project.build_directory).to eq(fixtures_project.send(:derived_data_path))
|
164
290
|
end
|
165
291
|
end
|
166
292
|
|
167
|
-
describe "#
|
293
|
+
describe "#configure_source_directory" do
|
168
294
|
it "should set the source_directory if it has been provided in the yml and has not already been set" do
|
169
295
|
Slather::Project.stub(:yml).and_return({"source_directory" => "/some/path"})
|
170
|
-
fixtures_project.
|
296
|
+
fixtures_project.configure_source_directory
|
171
297
|
expect(fixtures_project.source_directory).to eq("/some/path")
|
172
298
|
end
|
173
299
|
|
174
300
|
it "should not set the source_directory if it has already been set" do
|
175
301
|
Slather::Project.stub(:yml).and_return({"source_directory" => "/some/path"})
|
176
302
|
fixtures_project.source_directory = "/already/set"
|
177
|
-
fixtures_project.
|
303
|
+
fixtures_project.configure_source_directory
|
178
304
|
expect(fixtures_project.source_directory).to eq("/already/set")
|
179
305
|
end
|
180
306
|
end
|
181
307
|
|
182
|
-
describe "#
|
308
|
+
describe "#configure_output_directory" do
|
183
309
|
it "should set the output_directory if it has been provided in the yml and has not already been set" do
|
184
310
|
Slather::Project.stub(:yml).and_return({"output_directory" => "/some/path"})
|
185
|
-
fixtures_project.
|
311
|
+
fixtures_project.configure_output_directory
|
186
312
|
expect(fixtures_project.output_directory).to eq("/some/path")
|
187
313
|
end
|
188
314
|
|
189
315
|
it "should not set the output_directory if it has already been set" do
|
190
316
|
Slather::Project.stub(:yml).and_return({"output_directory" => "/some/path"})
|
191
317
|
fixtures_project.output_directory = "/already/set"
|
192
|
-
fixtures_project.
|
318
|
+
fixtures_project.configure_output_directory
|
193
319
|
expect(fixtures_project.output_directory).to eq("/already/set")
|
194
320
|
end
|
195
321
|
end
|
196
322
|
|
197
|
-
describe "#
|
323
|
+
describe "#configure_ci_service" do
|
198
324
|
it "should set the ci_service if it has been provided in the yml and has not already been set" do
|
199
325
|
Slather::Project.stub(:yml).and_return({"ci_service" => "some_service"})
|
200
|
-
fixtures_project.
|
326
|
+
fixtures_project.configure_ci_service
|
201
327
|
expect(fixtures_project.ci_service).to eq(:some_service)
|
202
328
|
end
|
203
329
|
|
204
330
|
it "should not set the ci_service if it has already been set" do
|
205
331
|
Slather::Project.stub(:yml).and_return({"ci_service" => "some service"})
|
206
332
|
fixtures_project.ci_service = "already_set"
|
207
|
-
fixtures_project.
|
333
|
+
fixtures_project.configure_ci_service
|
208
334
|
expect(fixtures_project.ci_service).to eq(:already_set)
|
209
335
|
end
|
210
336
|
|
211
337
|
it "should default the ci_service to :travis_ci if nothing is provided in the yml" do
|
212
338
|
Slather::Project.stub(:yml).and_return({})
|
213
|
-
fixtures_project.
|
339
|
+
fixtures_project.configure_ci_service
|
214
340
|
expect(fixtures_project.ci_service).to eq(:travis_ci)
|
215
341
|
end
|
216
342
|
end
|
@@ -222,24 +348,24 @@ describe Slather::Project do
|
|
222
348
|
end
|
223
349
|
end
|
224
350
|
|
225
|
-
describe "#
|
351
|
+
describe "#configure_coverage_service" do
|
226
352
|
it "should set the coverage_service if it has been provided by the yml" do
|
227
353
|
Slather::Project.stub(:yml).and_return({"coverage_service" => "some_service"})
|
228
354
|
expect(fixtures_project).to receive(:coverage_service=).with("some_service")
|
229
|
-
fixtures_project.
|
355
|
+
fixtures_project.configure_coverage_service
|
230
356
|
end
|
231
357
|
|
232
358
|
it "should default the coverage_service to :terminal if nothing is provided in the yml" do
|
233
359
|
Slather::Project.stub(:yml).and_return({})
|
234
360
|
expect(fixtures_project).to receive(:coverage_service=).with(:terminal)
|
235
|
-
fixtures_project.
|
361
|
+
fixtures_project.configure_coverage_service
|
236
362
|
end
|
237
363
|
|
238
364
|
it "should not set the coverage_service if it has already been set" do
|
239
365
|
Slather::Project.stub(:yml).and_return({"coverage_service" => "some_service" })
|
240
366
|
fixtures_project.stub(:coverage_service).and_return("already set")
|
241
367
|
expect(fixtures_project).to_not receive(:coverage_service=)
|
242
|
-
fixtures_project.
|
368
|
+
fixtures_project.configure_coverage_service
|
243
369
|
end
|
244
370
|
end
|
245
371
|
|
@@ -247,13 +373,13 @@ describe Slather::Project do
|
|
247
373
|
it "should set the coverage_access_token if it has been provided by the yml" do
|
248
374
|
Slather::Project.stub(:yml).and_return({"coverage_access_token" => "abc123"})
|
249
375
|
expect(fixtures_project).to receive(:coverage_access_token=).with("abc123")
|
250
|
-
fixtures_project.
|
376
|
+
fixtures_project.configure_coverage_access_token
|
251
377
|
end
|
252
378
|
|
253
379
|
it "should set the coverage_access_token if it is in the ENV" do
|
254
380
|
stub_const('ENV', ENV.to_hash.merge('COVERAGE_ACCESS_TOKEN' => 'asdf456'))
|
255
381
|
expect(fixtures_project).to receive(:coverage_access_token=).with("asdf456")
|
256
|
-
fixtures_project.
|
382
|
+
fixtures_project.configure_coverage_access_token
|
257
383
|
end
|
258
384
|
|
259
385
|
end
|
@@ -277,12 +403,59 @@ describe Slather::Project do
|
|
277
403
|
end
|
278
404
|
|
279
405
|
describe "#slather_setup_for_coverage" do
|
406
|
+
|
407
|
+
let(:fixtures_project_setup) do
|
408
|
+
FileUtils.cp_r "#{FIXTURES_PROJECT_PATH}/", "#{FIXTURES_PROJECT_SETUP_PATH}/"
|
409
|
+
Slather::Project.any_instance.stub(:configure)
|
410
|
+
Slather::Project.open(FIXTURES_PROJECT_SETUP_PATH)
|
411
|
+
end
|
412
|
+
|
413
|
+
after(:each) do
|
414
|
+
FileUtils.rm_rf(FIXTURES_PROJECT_SETUP_PATH)
|
415
|
+
end
|
416
|
+
|
280
417
|
it "should enable the correct flags to generate test coverage on all of the build_configurations build settings" do
|
281
|
-
|
282
|
-
|
418
|
+
fixtures_project_setup.slather_setup_for_coverage
|
419
|
+
fixtures_project_setup.build_configurations.each do |build_configuration|
|
283
420
|
expect(build_configuration.build_settings["GCC_INSTRUMENT_PROGRAM_FLOW_ARCS"]).to eq("YES")
|
284
421
|
expect(build_configuration.build_settings["GCC_GENERATE_TEST_COVERAGE_FILES"]).to eq("YES")
|
285
422
|
end
|
286
423
|
end
|
424
|
+
|
425
|
+
it "should apply Xcode7 enableCodeCoverage setting" do
|
426
|
+
fixtures_project_setup.slather_setup_for_coverage
|
427
|
+
schemes_path = Xcodeproj::XCScheme.shared_data_dir(fixtures_project_setup.path)
|
428
|
+
Xcodeproj::Project.schemes(fixtures_project_setup.path).each do |scheme_name|
|
429
|
+
xcscheme_path = "#{schemes_path + scheme_name}.xcscheme"
|
430
|
+
xcscheme = Xcodeproj::XCScheme.new(xcscheme_path)
|
431
|
+
expect(xcscheme.test_action.xml_element.attributes['codeCoverageEnabled']).to eq("YES")
|
432
|
+
end
|
433
|
+
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
describe "#verbose_mode" do
|
438
|
+
|
439
|
+
let(:fixtures_project) do
|
440
|
+
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
441
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
442
|
+
proj.input_format = "profdata"
|
443
|
+
proj.verbose_mode = true
|
444
|
+
proj.configure
|
445
|
+
proj
|
446
|
+
end
|
447
|
+
|
448
|
+
it "should print out environment info when in verbose_mode" do
|
449
|
+
|
450
|
+
project_root = Pathname("./").realpath
|
451
|
+
|
452
|
+
["\nProcessing coverage file: #{project_root}/spec/DerivedData/Build/Intermediates/CodeCoverage/fixtures/Coverage.profdata",
|
453
|
+
"Against binary file: #{project_root}/spec/DerivedData/Build/Intermediates/CodeCoverage/fixtures/Products/Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests\n\n"
|
454
|
+
].each do |line|
|
455
|
+
expect(fixtures_project).to receive(:puts).with(line)
|
456
|
+
end
|
457
|
+
|
458
|
+
fixtures_project.send(:configure)
|
459
|
+
end
|
287
460
|
end
|
288
461
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,14 +11,40 @@ FIXTURES_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/cobertura.xml')
|
|
11
11
|
FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
|
12
12
|
FIXTURES_HTML_FOLDER_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures_html')
|
13
13
|
FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
|
14
|
+
FIXTURES_SWIFT_FILE_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures/Fixtures.swift')
|
15
|
+
TEMP_DERIVED_DATA_PATH = File.join(File.dirname(__FILE__), 'DerivedData/')
|
16
|
+
TEMP_OBJC_GCNO_PATH = File.join(File.dirname(__FILE__), 'fixtures/ObjectiveC.gcno')
|
17
|
+
TEMP_OBJC_GCDA_PATH = File.join(File.dirname(__FILE__), 'fixtures/ObjectiveC.gcda')
|
18
|
+
|
19
|
+
module FixtureHelpers
|
20
|
+
def self.delete_derived_data
|
21
|
+
dir = Dir[TEMP_DERIVED_DATA_PATH].first
|
22
|
+
if dir
|
23
|
+
FileUtils.rm_rf(dir)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.delete_temp_gcov_files
|
28
|
+
if File.file?(TEMP_OBJC_GCNO_PATH)
|
29
|
+
FileUtils.rm(TEMP_OBJC_GCNO_PATH)
|
30
|
+
end
|
31
|
+
|
32
|
+
if File.file?(TEMP_OBJC_GCDA_PATH)
|
33
|
+
FileUtils.rm_f(TEMP_OBJC_GCDA_PATH)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
14
37
|
|
15
38
|
RSpec.configure do |config|
|
16
39
|
config.before(:suite) do
|
17
|
-
|
40
|
+
FixtureHelpers.delete_derived_data
|
41
|
+
FixtureHelpers.delete_temp_gcov_files
|
42
|
+
`xcodebuild -project "#{FIXTURES_PROJECT_PATH}" -scheme fixtures -configuration Debug -derivedDataPath #{TEMP_DERIVED_DATA_PATH} -enableCodeCoverage YES clean test`
|
18
43
|
end
|
19
44
|
|
20
45
|
config.after(:suite) do
|
21
|
-
|
46
|
+
FixtureHelpers.delete_derived_data
|
47
|
+
FixtureHelpers.delete_temp_gcov_files
|
22
48
|
end
|
23
49
|
end
|
24
50
|
|