slather 2.4.4 → 2.4.9
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 +5 -5
- data/.gitignore +5 -1
- data/.travis.yml +2 -12
- data/CHANGELOG.md +63 -1
- data/README.md +20 -0
- data/README_Images/test_scheme.png +0 -0
- data/assets/list.min.js +1 -1
- data/lib/slather.rb +1 -0
- data/lib/slather/command/coverage_command.rb +9 -0
- data/lib/slather/coverage_service/simple_output.rb +1 -0
- data/lib/slather/coverage_service/sonarqube_xml_output.rb +61 -0
- data/lib/slather/profdata_coverage_file.rb +24 -10
- data/lib/slather/project.rb +133 -44
- data/lib/slather/version.rb +1 -1
- data/slather.gemspec +14 -15
- data/spec/fixtures/sonarqube-generic-coverage.xml +93 -0
- data/spec/slather/cocoapods_plugin_spec.rb +1 -1
- data/spec/slather/coverage_service/coveralls_spec.rb +9 -0
- data/spec/slather/coverage_service/hardcover_spec.rb +9 -1
- data/spec/slather/coverage_service/simple_output_spec.rb +2 -0
- data/spec/slather/coverage_service/sonarqube_xml_spec.rb +46 -0
- data/spec/slather/profdata_coverage_spec.rb +21 -0
- data/spec/slather/project_spec.rb +126 -7
- data/spec/spec_helper.rb +1 -0
- metadata +50 -46
data/lib/slather/version.rb
CHANGED
data/slather.gemspec
CHANGED
|
@@ -17,21 +17,20 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
spec.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
|
21
|
-
spec.add_development_dependency 'coveralls'
|
|
22
|
-
spec.add_development_dependency 'simplecov'
|
|
23
|
-
spec.add_development_dependency 'rake', '~>
|
|
24
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
|
25
|
-
spec.add_development_dependency 'pry', '~> 0.
|
|
26
|
-
spec.add_development_dependency 'cocoapods', '~> 1.
|
|
27
|
-
spec.add_development_dependency 'json_spec', '~> 1.1
|
|
28
|
-
spec.add_development_dependency 'equivalent-xml', '~> 0.
|
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
|
21
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
|
22
|
+
spec.add_development_dependency 'simplecov', '~> 0'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
|
25
|
+
spec.add_development_dependency 'pry', '~> 0.12'
|
|
26
|
+
spec.add_development_dependency 'cocoapods', '~> 1.5'
|
|
27
|
+
spec.add_development_dependency 'json_spec', '~> 1.1'
|
|
28
|
+
spec.add_development_dependency 'equivalent-xml', '~> 0.6'
|
|
29
29
|
|
|
30
|
-
spec.add_dependency 'clamp', '~>
|
|
31
|
-
spec.add_dependency 'xcodeproj', '~> 1.
|
|
32
|
-
spec.add_dependency 'nokogiri', '
|
|
33
|
-
spec.add_dependency 'CFPropertyList', '
|
|
30
|
+
spec.add_dependency 'clamp', '~> 1.3'
|
|
31
|
+
spec.add_dependency 'xcodeproj', '~> 1.7'
|
|
32
|
+
spec.add_dependency 'nokogiri', '~> 1.8'
|
|
33
|
+
spec.add_dependency 'CFPropertyList', '>= 2.2', '< 4'
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
spec.add_runtime_dependency 'activesupport', '>= 4.0.2', '< 5'
|
|
35
|
+
spec.add_runtime_dependency 'activesupport', '< 5', '>= 4.0.2'
|
|
37
36
|
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<coverage version="1">
|
|
3
|
+
<file path="spec/fixtures/fixtures/fixtures.m">
|
|
4
|
+
<lineToCover lineNumber="14" covered="true"/>
|
|
5
|
+
<lineToCover lineNumber="15" covered="true"/>
|
|
6
|
+
<lineToCover lineNumber="16" covered="true"/>
|
|
7
|
+
<lineToCover lineNumber="19" covered="false"/>
|
|
8
|
+
<lineToCover lineNumber="20" covered="false"/>
|
|
9
|
+
<lineToCover lineNumber="21" covered="false"/>
|
|
10
|
+
</file>
|
|
11
|
+
<file path="spec/fixtures/fixtures/more_files/Branches.m">
|
|
12
|
+
<lineToCover lineNumber="14" covered="true"/>
|
|
13
|
+
<lineToCover lineNumber="15" covered="true"/>
|
|
14
|
+
<lineToCover lineNumber="16" covered="true"/>
|
|
15
|
+
<lineToCover lineNumber="17" covered="true"/>
|
|
16
|
+
<lineToCover lineNumber="18" covered="true"/>
|
|
17
|
+
<lineToCover lineNumber="19" covered="false"/>
|
|
18
|
+
<lineToCover lineNumber="20" covered="false"/>
|
|
19
|
+
<lineToCover lineNumber="21" covered="true"/>
|
|
20
|
+
<lineToCover lineNumber="22" covered="true"/>
|
|
21
|
+
<lineToCover lineNumber="23" covered="true"/>
|
|
22
|
+
<lineToCover lineNumber="24" covered="true"/>
|
|
23
|
+
<lineToCover lineNumber="25" covered="true"/>
|
|
24
|
+
<lineToCover lineNumber="26" covered="true"/>
|
|
25
|
+
<lineToCover lineNumber="27" covered="true"/>
|
|
26
|
+
<lineToCover lineNumber="28" covered="true"/>
|
|
27
|
+
<lineToCover lineNumber="29" covered="false"/>
|
|
28
|
+
<lineToCover lineNumber="30" covered="false"/>
|
|
29
|
+
<lineToCover lineNumber="31" covered="false"/>
|
|
30
|
+
<lineToCover lineNumber="32" covered="false"/>
|
|
31
|
+
<lineToCover lineNumber="33" covered="false"/>
|
|
32
|
+
<lineToCover lineNumber="34" covered="false"/>
|
|
33
|
+
<lineToCover lineNumber="35" covered="false"/>
|
|
34
|
+
<lineToCover lineNumber="36" covered="false"/>
|
|
35
|
+
<lineToCover lineNumber="37" covered="false"/>
|
|
36
|
+
<lineToCover lineNumber="38" covered="false"/>
|
|
37
|
+
<lineToCover lineNumber="39" covered="false"/>
|
|
38
|
+
<lineToCover lineNumber="40" covered="false"/>
|
|
39
|
+
<lineToCover lineNumber="41" covered="false"/>
|
|
40
|
+
<lineToCover lineNumber="42" covered="false"/>
|
|
41
|
+
<lineToCover lineNumber="43" covered="false"/>
|
|
42
|
+
</file>
|
|
43
|
+
<file path="spec/fixtures/fixturesTests/BranchesTests.m">
|
|
44
|
+
<lineToCover lineNumber="18" covered="true"/>
|
|
45
|
+
<lineToCover lineNumber="19" covered="true"/>
|
|
46
|
+
<lineToCover lineNumber="20" covered="true"/>
|
|
47
|
+
<lineToCover lineNumber="21" covered="true"/>
|
|
48
|
+
<lineToCover lineNumber="23" covered="true"/>
|
|
49
|
+
<lineToCover lineNumber="24" covered="true"/>
|
|
50
|
+
<lineToCover lineNumber="25" covered="true"/>
|
|
51
|
+
<lineToCover lineNumber="26" covered="true"/>
|
|
52
|
+
<lineToCover lineNumber="28" covered="true"/>
|
|
53
|
+
<lineToCover lineNumber="29" covered="true"/>
|
|
54
|
+
<lineToCover lineNumber="30" covered="true"/>
|
|
55
|
+
<lineToCover lineNumber="31" covered="true"/>
|
|
56
|
+
<lineToCover lineNumber="33" covered="true"/>
|
|
57
|
+
<lineToCover lineNumber="34" covered="true"/>
|
|
58
|
+
<lineToCover lineNumber="35" covered="true"/>
|
|
59
|
+
<lineToCover lineNumber="36" covered="true"/>
|
|
60
|
+
</file>
|
|
61
|
+
<file path="spec/fixtures/fixturesTests/fixturesTests.m">
|
|
62
|
+
<lineToCover lineNumber="20" covered="true"/>
|
|
63
|
+
<lineToCover lineNumber="21" covered="true"/>
|
|
64
|
+
<lineToCover lineNumber="22" covered="true"/>
|
|
65
|
+
<lineToCover lineNumber="23" covered="true"/>
|
|
66
|
+
<lineToCover lineNumber="26" covered="true"/>
|
|
67
|
+
<lineToCover lineNumber="27" covered="true"/>
|
|
68
|
+
<lineToCover lineNumber="28" covered="true"/>
|
|
69
|
+
<lineToCover lineNumber="29" covered="true"/>
|
|
70
|
+
<lineToCover lineNumber="32" covered="true"/>
|
|
71
|
+
<lineToCover lineNumber="33" covered="true"/>
|
|
72
|
+
<lineToCover lineNumber="34" covered="true"/>
|
|
73
|
+
<lineToCover lineNumber="35" covered="true"/>
|
|
74
|
+
<lineToCover lineNumber="38" covered="true"/>
|
|
75
|
+
<lineToCover lineNumber="39" covered="true"/>
|
|
76
|
+
<lineToCover lineNumber="40" covered="true"/>
|
|
77
|
+
<lineToCover lineNumber="41" covered="true"/>
|
|
78
|
+
<lineToCover lineNumber="42" covered="true"/>
|
|
79
|
+
</file>
|
|
80
|
+
<file path="spec/fixtures/fixturesTests/peekaviewTests💣.m">
|
|
81
|
+
<lineToCover lineNumber="18" covered="true"/>
|
|
82
|
+
<lineToCover lineNumber="19" covered="true"/>
|
|
83
|
+
<lineToCover lineNumber="20" covered="true"/>
|
|
84
|
+
<lineToCover lineNumber="21" covered="true"/>
|
|
85
|
+
<lineToCover lineNumber="24" covered="true"/>
|
|
86
|
+
<lineToCover lineNumber="25" covered="true"/>
|
|
87
|
+
<lineToCover lineNumber="26" covered="true"/>
|
|
88
|
+
<lineToCover lineNumber="27" covered="true"/>
|
|
89
|
+
<lineToCover lineNumber="30" covered="true"/>
|
|
90
|
+
<lineToCover lineNumber="31" covered="true"/>
|
|
91
|
+
<lineToCover lineNumber="32" covered="true"/>
|
|
92
|
+
</file>
|
|
93
|
+
</coverage>
|
|
@@ -13,7 +13,7 @@ describe Slather do
|
|
|
13
13
|
# Execute the post_install hook via CocoaPods
|
|
14
14
|
sandbox_root = 'Pods'
|
|
15
15
|
sandbox = Pod::Sandbox.new(sandbox_root)
|
|
16
|
-
context = Pod::Installer::PostInstallHooksContext.generate(sandbox, [])
|
|
16
|
+
context = Pod::Installer::PostInstallHooksContext.generate(sandbox, mock_project, [])
|
|
17
17
|
Pod::HooksManager.run(:post_install, context, {'slather' => nil})
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -158,6 +158,15 @@ describe Slather::CoverageService::Coveralls do
|
|
|
158
158
|
before(:each) {
|
|
159
159
|
fixtures_project.ci_service = :travis_ci
|
|
160
160
|
project_root = Pathname("./").realpath
|
|
161
|
+
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
|
|
162
|
+
{
|
|
163
|
+
"data":[
|
|
164
|
+
{
|
|
165
|
+
"files":[]
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
))
|
|
161
170
|
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
|
|
162
171
|
| 1|//
|
|
163
172
|
| 2|// fixtures.m
|
|
@@ -66,6 +66,15 @@ describe Slather::CoverageService::Hardcover do
|
|
|
66
66
|
allow(Slather::Project).to receive(:yml).and_return(fixture_yaml)
|
|
67
67
|
fixtures_project.ci_service = :jenkins_ci
|
|
68
68
|
project_root = Pathname("./").realpath
|
|
69
|
+
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
|
|
70
|
+
{
|
|
71
|
+
"data":[
|
|
72
|
+
{
|
|
73
|
+
"files":[]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
))
|
|
69
78
|
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
|
|
70
79
|
| 1|//
|
|
71
80
|
| 2|// fixtures.m
|
|
@@ -104,7 +113,6 @@ describe Slather::CoverageService::Hardcover do
|
|
|
104
113
|
|
|
105
114
|
it "should always remove the hardcover_json_file after it's done" do
|
|
106
115
|
allow(fixtures_project).to receive(:`)
|
|
107
|
-
|
|
108
116
|
allow(fixtures_project).to receive(:jenkins_job_id).and_return("slather-master/9182")
|
|
109
117
|
allow(fixtures_project).to receive(:coverage_service_url).and_return("http://api.hardcover.io")
|
|
110
118
|
fixtures_project.post
|
|
@@ -25,6 +25,7 @@ describe Slather::CoverageService::SimpleOutput do
|
|
|
25
25
|
"spec/fixtures/fixturesTests/fixturesTests.m: 17 of 17 lines (100.00%)",
|
|
26
26
|
"spec/fixtures/fixturesTests/peekaviewTests💣.m: 11 of 11 lines (100.00%)",
|
|
27
27
|
"spec/fixtures/fixturesTwo/fixturesTwo.m: 6 of 6 lines (100.00%)",
|
|
28
|
+
"Tested 66/86 statements",
|
|
28
29
|
"Test Coverage: 76.74%"
|
|
29
30
|
].each do |line|
|
|
30
31
|
expect(fixtures_project).to receive(:puts).with(line)
|
|
@@ -47,6 +48,7 @@ describe Slather::CoverageService::SimpleOutput do
|
|
|
47
48
|
"spec/fixtures/fixturesTwo/fixturesTwo.m: 6 of 6 lines (100.00%)",
|
|
48
49
|
"##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='66']",
|
|
49
50
|
"##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='86']",
|
|
51
|
+
"Tested 66/86 statements",
|
|
50
52
|
"Test Coverage: 76.74%"
|
|
51
53
|
].each do |line|
|
|
52
54
|
expect(fixtures_project).to receive(:puts).with(line)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
describe Slather::CoverageService::SonarqubeXmlOutput 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.input_format = "profdata"
|
|
10
|
+
proj.coverage_service = "sonarqube_xml"
|
|
11
|
+
proj.configure
|
|
12
|
+
proj
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#coverage_file_class' do
|
|
16
|
+
it "should return CoverageFile" do
|
|
17
|
+
expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#post' do
|
|
22
|
+
it "should create an XML report spanning all coverage files" do
|
|
23
|
+
fixtures_project.post
|
|
24
|
+
|
|
25
|
+
file = File.open(FIXTURES_SONARQUBE_XML_PATH)
|
|
26
|
+
fixture_xml_doc = Nokogiri::XML(file)
|
|
27
|
+
file.close
|
|
28
|
+
|
|
29
|
+
file = File.open('sonarqube-generic-coverage.xml')
|
|
30
|
+
current_xml_doc = Nokogiri::XML(file)
|
|
31
|
+
file.close
|
|
32
|
+
|
|
33
|
+
expect(EquivalentXml.equivalent?(current_xml_doc, fixture_xml_doc)).to be_truthy
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should create an XML report in the given output directory" do
|
|
37
|
+
fixtures_project.output_directory = "./output"
|
|
38
|
+
fixtures_project.post
|
|
39
|
+
|
|
40
|
+
filepath = "#{fixtures_project.output_directory}/sonarqube-generic-coverage.xml"
|
|
41
|
+
expect(File.exists?(filepath)).to be_truthy
|
|
42
|
+
|
|
43
|
+
FileUtils.rm_rf(fixtures_project.output_directory)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -90,6 +90,23 @@ describe Slather::ProfdataCoverageFile do
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
describe '#ignore_error_lines' do
|
|
94
|
+
it 'should ignore lines starting with - when line_numbers_first is true' do
|
|
95
|
+
expect(profdata_coverage_file.ignore_error_lines(['--------'], true)).to eq([])
|
|
96
|
+
expect(profdata_coverage_file.ignore_error_lines(['--------', 'not ignored'], true)).to eq(['not ignored'])
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'should ignore lines starting with | when line_numbers_first is true' do
|
|
100
|
+
expect(profdata_coverage_file.ignore_error_lines(['| Unexecuted instantiation'], true)).to eq([])
|
|
101
|
+
expect(profdata_coverage_file.ignore_error_lines(['| Unexecuted instantiation', 'not ignored'], true)).to eq(['not ignored'])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'should not ignore any lines when line_numbers_first is false' do
|
|
105
|
+
lines = ['| Unexecuted instantiation', '------']
|
|
106
|
+
expect(profdata_coverage_file.ignore_error_lines(lines, false)).to eq(lines)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
93
110
|
describe "#coverage_for_line" do
|
|
94
111
|
it "should return the number of hits for the line" do
|
|
95
112
|
expect(profdata_coverage_file.coverage_for_line(" 10| 40| func applicationWillTerminate(application: UIApplication) {", false)).to eq(10)
|
|
@@ -116,6 +133,10 @@ describe Slather::ProfdataCoverageFile do
|
|
|
116
133
|
expect(profdata_coverage_file.coverage_for_line(" 18| 11.8k| return a + b;", true)).to eq(11800)
|
|
117
134
|
expect(profdata_coverage_file.coverage_for_line(" 18| 2.58M| return a + b;", true)).to eq(2580000)
|
|
118
135
|
end
|
|
136
|
+
|
|
137
|
+
it 'should ignore errors in profdata' do
|
|
138
|
+
expect(profdata_coverage_file.coverage_for_line('------------------', true)).to eq(nil)
|
|
139
|
+
end
|
|
119
140
|
end
|
|
120
141
|
|
|
121
142
|
describe "#num_lines_tested" do
|
|
@@ -64,15 +64,91 @@ describe Slather::Project do
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
describe "#profdata_coverage_files" do
|
|
67
|
+
describe "#profdata_coverage_files with large file lists" do
|
|
68
68
|
class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
llvm_cov_export_output = %q(
|
|
72
|
+
{
|
|
73
|
+
"data":[
|
|
74
|
+
{
|
|
75
|
+
"files":[
|
|
76
|
+
{
|
|
77
|
+
"filename":"spec/fixtures/fixtures/Fixtures.swift"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"files":[
|
|
83
|
+
{
|
|
84
|
+
"filename":"spec/fixtures/fixtures/Fixtures.swift"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
profdata_llvm_cov_output = "#{FIXTURES_SWIFT_FILE_PATH}:
|
|
92
|
+
| 0|
|
|
93
|
+
| 1|import UIKit
|
|
94
|
+
| 2|
|
|
95
|
+
| 3|@UIApplicationMain
|
|
96
|
+
| 4|class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
97
|
+
| 5|
|
|
98
|
+
| 6| var window: UIWindow?
|
|
99
|
+
| 7|
|
|
100
|
+
1| 8| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
|
101
|
+
1| 9| return true
|
|
102
|
+
1| 10| }
|
|
103
|
+
| 11|
|
|
104
|
+
0| 12| func applicationWillResignActive(application: UIApplication) {
|
|
105
|
+
0| 13| }
|
|
106
|
+
0| 14|}"
|
|
107
|
+
|
|
71
108
|
before(:each) do
|
|
72
109
|
allow(Dir).to receive(:[]).and_call_original
|
|
73
110
|
allow(Dir).to receive(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
|
|
74
111
|
allow(fixtures_project).to receive(:binary_file).and_return(["Fixtures"])
|
|
75
|
-
allow(fixtures_project).to receive(:
|
|
112
|
+
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(llvm_cov_export_output)
|
|
113
|
+
allow(fixtures_project).to receive(:coverage_file_class).and_return(SpecXcode7CoverageFile)
|
|
114
|
+
allow(fixtures_project).to receive(:ignore_list).and_return([])
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "Should catch Errno::E2BIG and re-raise if the input is too large to split into multiple chunks" do
|
|
118
|
+
allow(fixtures_project).to receive(:unsafe_profdata_llvm_cov_output).and_raise(Errno::E2BIG)
|
|
119
|
+
expect { fixtures_project.send(:profdata_coverage_files) }.to raise_error(Errno::E2BIG, "Argument list too long. A path in your project is close to the E2BIG limit. https://github.com/SlatherOrg/slather/pull/414")
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "Should catch Errno::E2BIG and return Coverage.profdata file objects when the work can be split into two" do
|
|
123
|
+
allow(fixtures_project).to receive(:unsafe_profdata_llvm_cov_output).once {
|
|
124
|
+
# raise once and then insert the stub
|
|
125
|
+
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return(profdata_llvm_cov_output)
|
|
126
|
+
raise Errno::E2BIG
|
|
127
|
+
}
|
|
128
|
+
profdata_coverage_files = fixtures_project.send(:profdata_coverage_files)
|
|
129
|
+
profdata_coverage_files.each { |cf| expect(cf.kind_of?(SpecXcode7CoverageFile)).to be_truthy }
|
|
130
|
+
expect(profdata_coverage_files.map { |cf| cf.source_file_pathname.basename.to_s }).to eq(["Fixtures.swift", "Fixtures.swift"])
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe "#profdata_coverage_files" do
|
|
135
|
+
class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
llvm_cov_export_output = %q(
|
|
139
|
+
{
|
|
140
|
+
"data":[
|
|
141
|
+
{
|
|
142
|
+
"files":[
|
|
143
|
+
{
|
|
144
|
+
"filename":"spec/fixtures/fixtures/Fixtures.swift"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
profdata_llvm_cov_output = "#{FIXTURES_SWIFT_FILE_PATH}:
|
|
76
152
|
| 0|
|
|
77
153
|
| 1|import UIKit
|
|
78
154
|
| 2|
|
|
@@ -87,7 +163,14 @@ describe Slather::Project do
|
|
|
87
163
|
| 11|
|
|
88
164
|
0| 12| func applicationWillResignActive(application: UIApplication) {
|
|
89
165
|
0| 13| }
|
|
90
|
-
0| 14|}"
|
|
166
|
+
0| 14|}"
|
|
167
|
+
|
|
168
|
+
before(:each) do
|
|
169
|
+
allow(Dir).to receive(:[]).and_call_original
|
|
170
|
+
allow(Dir).to receive(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
|
|
171
|
+
allow(fixtures_project).to receive(:binary_file).and_return(["Fixtures"])
|
|
172
|
+
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(llvm_cov_export_output)
|
|
173
|
+
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return(profdata_llvm_cov_output)
|
|
91
174
|
allow(fixtures_project).to receive(:coverage_file_class).and_return(SpecXcode7CoverageFile)
|
|
92
175
|
allow(fixtures_project).to receive(:ignore_list).and_return([])
|
|
93
176
|
end
|
|
@@ -111,6 +194,18 @@ describe Slather::Project do
|
|
|
111
194
|
allow(fixtures_project).to receive(:ignore_list).and_return([])
|
|
112
195
|
allow(Dir).to receive(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
|
|
113
196
|
allow(fixtures_project).to receive(:binary_file).and_return(["Fixtures"])
|
|
197
|
+
allow(fixtures_project).to receive(:unsafe_llvm_cov_export_output).and_return("
|
|
198
|
+
{
|
|
199
|
+
\"data\":[
|
|
200
|
+
{
|
|
201
|
+
\"files\":[
|
|
202
|
+
{
|
|
203
|
+
\"filename\":\"sp\145c/fixtures/fixtures/fixtures.m\"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}")
|
|
114
209
|
allow(fixtures_project).to receive(:unsafe_profdata_llvm_cov_output).and_return("#{FIXTURES_SWIFT_FILE_PATH}:
|
|
115
210
|
1| 8| func application(application: \255, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
|
116
211
|
1| 9| return true
|
|
@@ -163,12 +258,19 @@ describe Slather::Project do
|
|
|
163
258
|
|
|
164
259
|
it "should find the product path for a scheme with no buildable products" do
|
|
165
260
|
allow(fixtures_project).to receive(:scheme).and_return("fixturesTests")
|
|
261
|
+
allow(fixtures_project).to receive(:arch).and_return("x86_64")
|
|
166
262
|
fixtures_project.send(:configure_binary_file)
|
|
167
263
|
binary_file_location = fixtures_project.send(:binary_file)
|
|
168
264
|
expect(binary_file_location.count).to eq(1)
|
|
169
265
|
expect(binary_file_location.first).to end_with("Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests")
|
|
170
266
|
end
|
|
171
267
|
|
|
268
|
+
it "should not find a product path for an invalid architecture" do
|
|
269
|
+
allow(fixtures_project).to receive(:scheme).and_return("fixturesTests")
|
|
270
|
+
allow(fixtures_project).to receive(:arch).and_return("arm64")
|
|
271
|
+
expect { fixtures_project.send(:configure_binary_file) }.to raise_error.with_message(/No product binary found in (.+)./)
|
|
272
|
+
end
|
|
273
|
+
|
|
172
274
|
it "should find multiple unique paths for a scheme with serveral buildable/testable products" do
|
|
173
275
|
allow(fixtures_project).to receive(:scheme).and_return("aggregateFixturesTests")
|
|
174
276
|
fixtures_project.send(:configure_binary_file)
|
|
@@ -509,9 +611,9 @@ describe Slather::Project do
|
|
|
509
611
|
it "should print out environment info when in verbose_mode" do
|
|
510
612
|
project_root = Pathname("./").realpath
|
|
511
613
|
|
|
512
|
-
[
|
|
614
|
+
[/\nProcessing coverage file: #{project_root}\/spec\/DerivedData\/libfixtures\/Build\/ProfileData\/[A-Z0-9-]+\/Coverage.profdata/,
|
|
513
615
|
"Against binary files:",
|
|
514
|
-
"\t#{project_root}/spec/DerivedData/libfixtures/Build/
|
|
616
|
+
"\t#{project_root}/spec/DerivedData/libfixtures/Build/Products/Debug/fixturesTests.xctest/Contents/MacOS/fixturesTests",
|
|
515
617
|
"\n"
|
|
516
618
|
].each do |line|
|
|
517
619
|
expect(fixtures_project).to receive(:puts).with(line)
|
|
@@ -525,7 +627,7 @@ describe Slather::Project do
|
|
|
525
627
|
|
|
526
628
|
project_root = Pathname("./").realpath
|
|
527
629
|
|
|
528
|
-
[
|
|
630
|
+
[/\nProcessing coverage file: #{project_root}\/spec\/DerivedData\/libfixtures\/Build\/ProfileData\/[A-Z0-9-]+\/Coverage.profdata/,
|
|
529
631
|
"No binary files found.",
|
|
530
632
|
"\n",
|
|
531
633
|
].each do |line|
|
|
@@ -556,8 +658,25 @@ describe Slather::Project do
|
|
|
556
658
|
end
|
|
557
659
|
|
|
558
660
|
it "should print out the coverage for each file, and then total coverage" do
|
|
661
|
+
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
|
|
662
|
+
{
|
|
663
|
+
"data":[
|
|
664
|
+
{
|
|
665
|
+
"files":[
|
|
666
|
+
{
|
|
667
|
+
"filename":"spec/fixtures/fixtures/fixtures.m"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"filename":"spec/fixtures/fixturesTwo/fixturesTwo.m"
|
|
671
|
+
}
|
|
672
|
+
]
|
|
673
|
+
}
|
|
674
|
+
]
|
|
675
|
+
}
|
|
676
|
+
))
|
|
559
677
|
["spec/fixtures/fixtures/fixtures.m: 3 of 6 lines (50.00%)",
|
|
560
678
|
"spec/fixtures/fixturesTwo/fixturesTwo.m: 6 of 6 lines (100.00%)",
|
|
679
|
+
"Tested 9/12 statements",
|
|
561
680
|
"Test Coverage: 75.00%"
|
|
562
681
|
].each do |line|
|
|
563
682
|
expect(fixtures_project).to receive(:puts).with(line)
|
|
@@ -587,7 +706,7 @@ describe Slather::Project do
|
|
|
587
706
|
let(:configuration) { 'Debug' }
|
|
588
707
|
let(:project_root) { Pathname("./").realpath }
|
|
589
708
|
let(:coverage_dir) { "#{project_root}/spec/DerivedData/DerivedData/Build/Intermediates/CodeCoverage" }
|
|
590
|
-
let(:search_dir) { "#{coverage_dir}
|
|
709
|
+
let(:search_dir) { "#{coverage_dir}/../../Products/#{configuration}*/fixtures*" }
|
|
591
710
|
let(:binary_file) { "#{coverage_dir}/Products/#{configuration}-iphonesimulator/fixtures.app/fixtures" }
|
|
592
711
|
|
|
593
712
|
before do
|