slather 1.8.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -5,12 +5,16 @@ describe Slather::CoverageService::CoberturaXmlOutput do
|
|
5
5
|
|
6
6
|
let(:fixtures_project) do
|
7
7
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
8
|
-
proj.
|
8
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
9
|
+
proj.input_format = "profdata"
|
10
|
+
proj.coverage_service = "cobertura_xml"
|
11
|
+
proj.configure
|
12
|
+
proj
|
9
13
|
end
|
10
14
|
|
11
15
|
describe '#coverage_file_class' do
|
12
16
|
it "should return CoverageFile" do
|
13
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
17
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -33,7 +37,7 @@ describe Slather::CoverageService::CoberturaXmlOutput do
|
|
33
37
|
source_node.content = ''
|
34
38
|
end
|
35
39
|
|
36
|
-
EquivalentXml.equivalent?(current_xml_doc, fixture_xml_doc).
|
40
|
+
expect(EquivalentXml.equivalent?(current_xml_doc, fixture_xml_doc)).to be_truthy
|
37
41
|
end
|
38
42
|
|
39
43
|
it "should create an XML report in the given output directory" do
|
@@ -4,12 +4,16 @@ describe Slather::CoverageService::Coveralls do
|
|
4
4
|
|
5
5
|
let(:fixtures_project) do
|
6
6
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
7
|
-
proj.
|
7
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
8
|
+
proj.input_format = "profdata"
|
9
|
+
proj.coverage_service = "coveralls"
|
10
|
+
proj.send(:configure)
|
11
|
+
proj
|
8
12
|
end
|
9
13
|
|
10
14
|
describe "#coverage_file_class" do
|
11
15
|
it "should return CoverallsCoverageFile" do
|
12
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
16
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -27,7 +31,7 @@ describe Slather::CoverageService::Coveralls do
|
|
27
31
|
context "coverage_service is :travis_ci" do
|
28
32
|
before(:each) { fixtures_project.ci_service = :travis_ci }
|
29
33
|
|
30
|
-
it "should return valid json for coveralls coverage data" do
|
34
|
+
it "should return valid json for coveralls coverage gcov data" do
|
31
35
|
fixtures_project.stub(:travis_job_id).and_return("9182")
|
32
36
|
expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\"}").excluding("source_files")
|
33
37
|
expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.send(:coverage_files).map(&:as_json).to_json).at_path("source_files")
|
@@ -98,25 +102,62 @@ describe Slather::CoverageService::Coveralls do
|
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
|
-
describe '#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
describe '#coveralls_coverage_data' do
|
106
|
+
context "coverage_service is :travis_ci" do
|
107
|
+
before(:each) {
|
108
|
+
fixtures_project.ci_service = :travis_ci
|
109
|
+
project_root = Pathname("./").realpath
|
110
|
+
fixtures_project.stub(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
|
111
|
+
| 1|//
|
112
|
+
| 2|// fixtures.m
|
113
|
+
| 3|// fixtures
|
114
|
+
| 4|//
|
115
|
+
| 5|// Created by Mark Larsen on 6/24/14.
|
116
|
+
| 6|// Copyright (c) 2014 marklarr. All rights reserved.
|
117
|
+
| 7|//
|
118
|
+
| 8|
|
119
|
+
| 9|#import \"fixtures.h\"
|
120
|
+
| 10|
|
121
|
+
| 11|@implementation fixtures
|
122
|
+
| 12|
|
123
|
+
| 13|- (void)testedMethod
|
124
|
+
1| 14|{
|
125
|
+
1| 15| NSLog(@\"tested\");
|
126
|
+
1| 16|}
|
127
|
+
| 17|
|
128
|
+
| 18|- (void)untestedMethod
|
129
|
+
0| 19|{
|
130
|
+
0| 20| NSLog(@\"untested\");
|
131
|
+
0| 21|}
|
132
|
+
| 22|
|
133
|
+
| 23|@end
|
134
|
+
")
|
135
|
+
}
|
136
|
+
|
137
|
+
it "should save the coveralls_coverage_data to a file and post it to coveralls" do
|
138
|
+
fixtures_project.stub(:travis_job_id).and_return("9182")
|
139
|
+
expect(fixtures_project).to receive(:`) do |cmd|
|
140
|
+
expect(cmd).to eq("curl -s --form json_file=@coveralls_json_file https://coveralls.io/api/v1/jobs")
|
141
|
+
expect(File.read('coveralls_json_file')).to be_json_eql(fixtures_project.send(:coveralls_coverage_data))
|
142
|
+
end.once
|
143
|
+
fixtures_project.post
|
144
|
+
end
|
110
145
|
|
111
|
-
|
112
|
-
|
146
|
+
it "should always remove the coveralls_json_file after it's done" do
|
147
|
+
fixtures_project.stub(:`)
|
148
|
+
fixtures_project.stub(:travis_job_id).and_return("9182")
|
149
|
+
fixtures_project.post
|
150
|
+
expect(File.exist?("coveralls_json_file")).to be_falsy
|
151
|
+
fixtures_project.stub(:travis_job_id).and_return(nil)
|
152
|
+
expect { fixtures_project.post }.to raise_error(StandardError)
|
153
|
+
expect(File.exist?("coveralls_json_file")).to be_falsy
|
154
|
+
end
|
113
155
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
expect(File.exist?("coveralls_json_file")).to be_falsy
|
156
|
+
it "should return valid json for coveralls coverage profdata data" do
|
157
|
+
fixtures_project.stub(:travis_job_id).and_return("9182")
|
158
|
+
expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\"}").excluding("source_files")
|
159
|
+
expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.send(:coverage_files).map(&:as_json).to_json).at_path("source_files")
|
160
|
+
end
|
120
161
|
end
|
121
162
|
end
|
122
163
|
end
|
@@ -5,12 +5,16 @@ describe Slather::CoverageService::GutterJsonOutput do
|
|
5
5
|
|
6
6
|
let(:fixtures_project) do
|
7
7
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
8
|
-
proj.
|
8
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
9
|
+
proj.input_format = "profdata"
|
10
|
+
proj.coverage_service = "gutter_json"
|
11
|
+
proj.configure
|
12
|
+
proj
|
9
13
|
end
|
10
14
|
|
11
15
|
describe '#coverage_file_class' do
|
12
16
|
it "should return CoverageFile" do
|
13
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
17
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -4,7 +4,11 @@ describe Slather::CoverageService::Hardcover do
|
|
4
4
|
|
5
5
|
let(:fixtures_project) do
|
6
6
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
7
|
-
proj.
|
7
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
8
|
+
proj.input_format = "profdata"
|
9
|
+
proj.coverage_service = "hardcover"
|
10
|
+
proj.configure
|
11
|
+
proj
|
8
12
|
end
|
9
13
|
|
10
14
|
let(:fixture_yaml) do
|
@@ -17,7 +21,7 @@ describe Slather::CoverageService::Hardcover do
|
|
17
21
|
|
18
22
|
describe "#coverage_file_class" do
|
19
23
|
it "should return CoverallsCoverageFile" do
|
20
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
24
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -61,6 +65,32 @@ describe Slather::CoverageService::Hardcover do
|
|
61
65
|
before(:each) do
|
62
66
|
Slather::Project.stub(:yml).and_return(fixture_yaml)
|
63
67
|
fixtures_project.ci_service = :jenkins_ci
|
68
|
+
project_root = Pathname("./").realpath
|
69
|
+
fixtures_project.stub(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
|
70
|
+
| 1|//
|
71
|
+
| 2|// fixtures.m
|
72
|
+
| 3|// fixtures
|
73
|
+
| 4|//
|
74
|
+
| 5|// Created by Mark Larsen on 6/24/14.
|
75
|
+
| 6|// Copyright (c) 2014 marklarr. All rights reserved.
|
76
|
+
| 7|//
|
77
|
+
| 8|
|
78
|
+
| 9|#import \"fixtures.h\"
|
79
|
+
| 10|
|
80
|
+
| 11|@implementation fixtures
|
81
|
+
| 12|
|
82
|
+
| 13|- (void)testedMethod
|
83
|
+
1| 14|{
|
84
|
+
1| 15| NSLog(@\"tested\");
|
85
|
+
1| 16|}
|
86
|
+
| 17|
|
87
|
+
| 18|- (void)untestedMethod
|
88
|
+
0| 19|{
|
89
|
+
0| 20| NSLog(@\"untested\");
|
90
|
+
0| 21|}
|
91
|
+
| 22|
|
92
|
+
| 23|@end
|
93
|
+
")
|
64
94
|
end
|
65
95
|
|
66
96
|
it "should save the hardcover_coverage_data to a file and post it to hardcover" do
|
@@ -80,7 +110,7 @@ describe Slather::CoverageService::Hardcover do
|
|
80
110
|
fixtures_project.post
|
81
111
|
expect(File.exist?("hardcover_json_file")).to be_falsy
|
82
112
|
fixtures_project.stub(:jenkins_job_id).and_return(nil)
|
83
|
-
expect { fixtures_project.post }.to raise_error
|
113
|
+
expect { fixtures_project.post }.to raise_error(StandardError)
|
84
114
|
expect(File.exist?("hardcover_json_file")).to be_falsy
|
85
115
|
end
|
86
116
|
end
|
@@ -8,12 +8,7 @@ describe Slather::CoverageService::HtmlOutput do
|
|
8
8
|
let(:fixture_html_files) do
|
9
9
|
["index",
|
10
10
|
"fixtures.m",
|
11
|
-
"peekaview.m",
|
12
|
-
"fixtures_cpp.cpp",
|
13
|
-
"fixtures_mm.mm",
|
14
|
-
"fixtures_m.m",
|
15
11
|
"Branches.m",
|
16
|
-
"Empty.m",
|
17
12
|
"fixturesTests.m",
|
18
13
|
"peekaviewTests.m",
|
19
14
|
"BranchesTests.m"].map { |file| "#{file}.html"}
|
@@ -21,18 +16,22 @@ describe Slather::CoverageService::HtmlOutput do
|
|
21
16
|
|
22
17
|
let(:fixtures_project) do
|
23
18
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
24
|
-
proj.
|
19
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
20
|
+
proj.input_format = "profdata"
|
21
|
+
proj.coverage_service = "html"
|
22
|
+
proj
|
25
23
|
end
|
26
24
|
|
27
25
|
describe '#coverage_file_class' do
|
28
26
|
it "should return CoverageFile" do
|
29
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
27
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
describe '#post' do
|
34
32
|
before(:each) {
|
35
33
|
fixtures_project.stub(:print_path_coverage)
|
34
|
+
fixtures_project.send(:configure)
|
36
35
|
}
|
37
36
|
|
38
37
|
after(:each) {
|
@@ -175,5 +174,47 @@ describe Slather::CoverageService::HtmlOutput do
|
|
175
174
|
expect(Dir.exist?(OUTPUT_DIR_PATH)).to be_truthy
|
176
175
|
end
|
177
176
|
|
177
|
+
it "should create a valid report when using profdata format" do
|
178
|
+
|
179
|
+
def extract_filepath(doc)
|
180
|
+
(path = doc.at_css('h4.cov_filepath'))? path.text : ""
|
181
|
+
end
|
182
|
+
|
183
|
+
fixtures_project.stub(:input_format).and_return("profdata")
|
184
|
+
fixtures_project.stub(:profdata_llvm_cov_output).and_return("./spec/fixtures/fixtures/other_fixtures.m:
|
185
|
+
| 1|//
|
186
|
+
| 2|// other_fixtures.m
|
187
|
+
| 3|// fixtures
|
188
|
+
| 4|//
|
189
|
+
| 5|// Created by Mark Larsen on 6/24/14.
|
190
|
+
| 6|// Copyright (c) 2014 marklarr. All rights reserved.
|
191
|
+
| 7|//
|
192
|
+
| 8|
|
193
|
+
| 9|#import \"other_fixtures.h\"
|
194
|
+
| 10|
|
195
|
+
| 11|@implementation other_fixtures
|
196
|
+
| 12|
|
197
|
+
| 13|- (void)testedMethod
|
198
|
+
1| 14|{
|
199
|
+
1| 15| NSLog(@\"tested\");
|
200
|
+
1| 16|}
|
201
|
+
| 17|
|
202
|
+
| 18|- (void)untestedMethod
|
203
|
+
0| 19|{
|
204
|
+
0| 20| NSLog(@\"untested\");
|
205
|
+
0| 21|}
|
206
|
+
| 22|
|
207
|
+
| 23|@end
|
208
|
+
")
|
209
|
+
fixtures_project.post
|
210
|
+
|
211
|
+
file = File.open(File.join(OUTPUT_DIR_PATH, "other_fixtures.m.html"))
|
212
|
+
doc = Nokogiri::HTML(file)
|
213
|
+
file.close
|
214
|
+
|
215
|
+
expect(extract_header_title(doc)).to eq("other_fixtures.m - Slather")
|
216
|
+
expect(extract_filepath(doc)).to eq("spec/fixtures/fixtures/other_fixtures.m")
|
217
|
+
end
|
218
|
+
|
178
219
|
end
|
179
220
|
end
|
@@ -4,28 +4,27 @@ describe Slather::CoverageService::SimpleOutput do
|
|
4
4
|
|
5
5
|
let(:fixtures_project) do
|
6
6
|
proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
|
7
|
-
proj.
|
7
|
+
proj.build_directory = TEMP_DERIVED_DATA_PATH
|
8
|
+
proj.input_format = "profdata"
|
9
|
+
proj.configure
|
10
|
+
proj
|
8
11
|
end
|
9
12
|
|
10
13
|
describe '#coverage_file_class' do
|
11
14
|
it "should return CoverageFile" do
|
12
|
-
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::
|
15
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
19
|
describe '#post' do
|
17
20
|
it "should print out the coverage for each file, and then total coverage" do
|
18
|
-
["spec/fixtures/fixtures/fixtures.m:
|
19
|
-
"spec/fixtures/fixtures/more_files/
|
20
|
-
"spec/fixtures/
|
21
|
-
"spec/fixtures/
|
22
|
-
"spec/fixtures/
|
23
|
-
"
|
24
|
-
|
25
|
-
"spec/fixtures/fixturesTests/fixturesTests.m: 7 of 7 lines (100.00%)",
|
26
|
-
"spec/fixtures/fixturesTests/peekaviewTests.m: 6 of 6 lines (100.00%)",
|
27
|
-
"spec/fixtures/fixturesTests/BranchesTests.m: 10 of 10 lines (100.00%)",
|
28
|
-
"Test Coverage: 66.04%"].each do |line|
|
21
|
+
["spec/fixtures/fixtures/fixtures.m: 3 of 6 lines (50.00%)",
|
22
|
+
"spec/fixtures/fixtures/more_files/Branches.m: 13 of 30 lines (43.33%)",
|
23
|
+
"spec/fixtures/fixturesTests/BranchesTests.m: 16 of 16 lines (100.00%)",
|
24
|
+
"spec/fixtures/fixturesTests/fixturesTests.m: 12 of 12 lines (100.00%)",
|
25
|
+
"spec/fixtures/fixturesTests/peekaviewTests.m: 11 of 11 lines (100.00%)",
|
26
|
+
"Test Coverage: 73.33%"
|
27
|
+
].each do |line|
|
29
28
|
expect(fixtures_project).to receive(:puts).with(line)
|
30
29
|
end
|
31
30
|
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Slather::ProfdataCoverageFile do
|
4
|
+
|
5
|
+
let(:fixtures_project) do
|
6
|
+
Slather::Project.open(FIXTURES_PROJECT_PATH)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:profdata_coverage_file) do
|
10
|
+
Slather::ProfdataCoverageFile.new(fixtures_project, "/Users/venmo/ExampleProject/AppDelegate.swift:
|
11
|
+
| 1|//
|
12
|
+
| 2|// AppDelegate.swift
|
13
|
+
| 3|// xcode7workbench01
|
14
|
+
| 4|//
|
15
|
+
| 5|// Created by Simone Civetta on 08/06/15.
|
16
|
+
| 6|// Copyright © 2015 Xebia IT Architects. All rights reserved.
|
17
|
+
| 7|//
|
18
|
+
| 8|
|
19
|
+
| 9|import UIKit
|
20
|
+
| 10|
|
21
|
+
| 11|@UIApplicationMain
|
22
|
+
| 12|class AppDelegate: UIResponder, UIApplicationDelegate {
|
23
|
+
| 13|
|
24
|
+
| 14| var window: UIWindow?
|
25
|
+
| 15|
|
26
|
+
| 16|
|
27
|
+
1| 17| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
28
|
+
1| 18| // Override point for customization after application launch.
|
29
|
+
1| 19| return true
|
30
|
+
1| 20| }
|
31
|
+
| 21|
|
32
|
+
0| 22| func applicationWillResignActive(application: UIApplication) {
|
33
|
+
0| 23| // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
34
|
+
0| 24| // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
35
|
+
0| 25| }
|
36
|
+
| 26|
|
37
|
+
0| 27| func applicationDidEnterBackground(application: UIApplication) {
|
38
|
+
0| 28| // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
39
|
+
0| 29| // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
40
|
+
0| 30| }
|
41
|
+
| 31|
|
42
|
+
0| 32| func applicationWillEnterForeground(application: UIApplication) {
|
43
|
+
0| 33| // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
44
|
+
0| 34| }
|
45
|
+
| 35|
|
46
|
+
1| 36| func applicationDidBecomeActive(application: UIApplication) {
|
47
|
+
0| 37| // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
48
|
+
0| 38| }
|
49
|
+
| 39|
|
50
|
+
0| 40| func applicationWillTerminate(application: UIApplication) {
|
51
|
+
0| 41| }
|
52
|
+
| 42|
|
53
|
+
| 43|
|
54
|
+
| 44|}
|
55
|
+
| 45|")
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#initialize" do
|
59
|
+
it "should create a list of lines" do
|
60
|
+
expect(profdata_coverage_file.line_data.length).to eq(45)
|
61
|
+
expect(profdata_coverage_file.line_data[9]).to eq(" | 9|import UIKit")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#all_lines" do
|
66
|
+
it "should return a list of all the lines" do
|
67
|
+
expect(profdata_coverage_file.all_lines.length).to eq(45)
|
68
|
+
expect(profdata_coverage_file.all_lines[8]).to eq(" | 9|import UIKit")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#line_number_in_line" do
|
73
|
+
it "should return the correct line number" do
|
74
|
+
expect(profdata_coverage_file.line_number_in_line(" 0| 40| func applicationWillTerminate(application: UIApplication) {")).to eq(40)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#coverage_for_line" do
|
79
|
+
it "should return the number of hits for the line" do
|
80
|
+
expect(profdata_coverage_file.coverage_for_line(" 10| 40| func applicationWillTerminate(application: UIApplication) {")).to eq(10)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#num_lines_tested" do
|
85
|
+
it "should count the actual number of line tested" do
|
86
|
+
expect(profdata_coverage_file.num_lines_tested).to eq(5)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#num_lines_testable" do
|
91
|
+
it "should count the actual testable number of line" do
|
92
|
+
expect(profdata_coverage_file.num_lines_testable).to eq(20)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#percentage_line_tested" do
|
97
|
+
it "should count the percentage of tested lines" do
|
98
|
+
expect(profdata_coverage_file.percentage_lines_tested).to eq(25)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#ignored" do
|
103
|
+
|
104
|
+
before(:each) {
|
105
|
+
fixtures_project.stub(:ignore_list).and_return([])
|
106
|
+
}
|
107
|
+
|
108
|
+
it "shouldn't ignore project files" do
|
109
|
+
ignorable_file = Slather::ProfdataCoverageFile.new(fixtures_project, "/Users/venmo/ExampleProject/AppDelegate.swift:
|
110
|
+
| 1|//
|
111
|
+
| 2|// AppDelegate.swift
|
112
|
+
| 3|// xcode7workbench01")
|
113
|
+
|
114
|
+
expect(ignorable_file.ignored?).to be_falsy
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should ignore platform files" do
|
118
|
+
ignorable_file = Slather::ProfdataCoverageFile.new(fixtures_project, "../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTestAssertionsImpl.h:
|
119
|
+
| 1|//
|
120
|
+
| 2|// AppDelegate.swift
|
121
|
+
| 3|// xcode7workbench01")
|
122
|
+
|
123
|
+
expect(ignorable_file.ignored?).to be_truthy
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|