slather 2.4.7 → 2.4.8
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 +5 -1
- data/CHANGELOG.md +14 -0
- data/README.md +14 -0
- data/lib/slather/profdata_coverage_file.rb +24 -10
- data/lib/slather/project.rb +26 -24
- data/lib/slather/version.rb +1 -1
- data/slather.gemspec +1 -1
- data/spec/slather/cocoapods_plugin_spec.rb +1 -1
- data/spec/slather/profdata_coverage_spec.rb +21 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24ee530494c9f131751a85dba16a4bc09292c187d045be17b1212d9cf4038378
|
4
|
+
data.tar.gz: 4c5dabc3de752ebb88998ca29d87d6f072e4477a909926d4237078a2a9f73bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d4a1db210237adec6b9c03634774991a209c4aa64c10dea0a73208642298082b9a76f9c0e979b68a4601c6c9ff37f92d6f05bfd3c8a35429bd78cc8ac9549c
|
7
|
+
data.tar.gz: 9bf87cccabbd4b243e8ba9c519d491818a38924125694ca8701b3b34764a8c9ae167919b764638fa0af27b137dbbf10d9188b3e6297f93f3d1673ec07566d817
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.4.8
|
4
|
+
|
5
|
+
* Optimize performance for many binaries
|
6
|
+
[cltnschlosser](https://github.com/cltnschlosser)
|
7
|
+
[#455](https://github.com/SlatherOrg/slather/pull/455)
|
8
|
+
|
9
|
+
* Don't generate line 0 in profdata_coverage_file.rb from line with error
|
10
|
+
[tthbalazs](https://github.com/tthbalazs)
|
11
|
+
[#449](https://github.com/SlatherOrg/slather/pull/449)
|
12
|
+
|
13
|
+
* coveralls dependency update
|
14
|
+
[GRiMe2D](https://github.com/GRiMe2D)
|
15
|
+
[#448](https://github.com/SlatherOrg/slather/pull/448)
|
16
|
+
|
3
17
|
## v2.4.7
|
4
18
|
|
5
19
|
* Update dependencies
|
data/README.md
CHANGED
@@ -67,6 +67,20 @@ If your configuration produces a universal binary you need to specify a specific
|
|
67
67
|
$ slather coverage -s --arch x86_64 --scheme YourXcodeSchemeName --configuration YourBuildConfigurationName path/to/project.xcodeproj
|
68
68
|
```
|
69
69
|
|
70
|
+
### For multiple modules
|
71
|
+
|
72
|
+
If you want to run some modules, but not all (like modules created by CocoaPods) you can do it like this:
|
73
|
+
|
74
|
+
```sh
|
75
|
+
$ slather coverage --binary-basename module1 --binary-basename module2 path/to/project.xcodeproj
|
76
|
+
```
|
77
|
+
You can also add it to the `.slather.yml` file as an array:
|
78
|
+
```yml
|
79
|
+
binary_basename:
|
80
|
+
- module1
|
81
|
+
- module2
|
82
|
+
```
|
83
|
+
|
70
84
|
### Setup for Xcode 5 and 6
|
71
85
|
|
72
86
|
Run this command to enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project:
|
@@ -18,7 +18,6 @@ module Slather
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def create_line_data
|
21
|
-
all_lines = source_code_lines
|
22
21
|
line_data = Hash.new
|
23
22
|
all_lines.each { |line| line_data[line_number_in_line(line, self.line_numbers_first)] = line }
|
24
23
|
self.line_data = line_data
|
@@ -26,14 +25,20 @@ module Slather
|
|
26
25
|
private :create_line_data
|
27
26
|
|
28
27
|
def path_on_first_line?
|
29
|
-
|
30
|
-
!path.lstrip.start_with?("1|")
|
28
|
+
!source.lstrip.start_with?("1|")
|
31
29
|
end
|
32
30
|
|
33
31
|
def source_file_pathname
|
34
32
|
@source_file_pathname ||= begin
|
35
33
|
if path_on_first_line?
|
36
|
-
|
34
|
+
end_index = self.source.index(/:?\n/)
|
35
|
+
if end_index != nil
|
36
|
+
end_index -= 1
|
37
|
+
path = self.source[0..end_index]
|
38
|
+
else
|
39
|
+
# Empty file, output just contains path
|
40
|
+
path = self.source.sub ":", ""
|
41
|
+
end
|
37
42
|
path &&= Pathname(path)
|
38
43
|
else
|
39
44
|
# llvm-cov was run with just one matching source file
|
@@ -64,7 +69,16 @@ module Slather
|
|
64
69
|
end
|
65
70
|
|
66
71
|
def source_code_lines
|
67
|
-
self.source.split("\n")[(path_on_first_line? ? 1 : 0)..-1]
|
72
|
+
lines = self.source.split("\n")[(path_on_first_line? ? 1 : 0)..-1]
|
73
|
+
ignore_error_lines(lines)
|
74
|
+
end
|
75
|
+
|
76
|
+
def ignore_error_lines(lines, line_numbers_first = self.line_numbers_first)
|
77
|
+
if line_numbers_first
|
78
|
+
lines.reject { |line| line.lstrip.start_with?('|', '--') }
|
79
|
+
else
|
80
|
+
lines
|
81
|
+
end
|
68
82
|
end
|
69
83
|
|
70
84
|
def source_data
|
@@ -72,10 +86,7 @@ module Slather
|
|
72
86
|
end
|
73
87
|
|
74
88
|
def all_lines
|
75
|
-
|
76
|
-
@all_lines = source_code_lines
|
77
|
-
end
|
78
|
-
@all_lines
|
89
|
+
@all_lines ||= source_code_lines
|
79
90
|
end
|
80
91
|
|
81
92
|
def raw_source
|
@@ -94,6 +105,9 @@ module Slather
|
|
94
105
|
|
95
106
|
def line_number_in_line(line, line_numbers_first = self.line_numbers_first)
|
96
107
|
if line_numbers_first
|
108
|
+
# Skip regex if the number is the first thing in the line
|
109
|
+
fastpath_number = line.to_i
|
110
|
+
return fastpath_number if fastpath_number != 0
|
97
111
|
line =~ /^(\s*)(\d*)/
|
98
112
|
group = $2
|
99
113
|
else
|
@@ -123,7 +137,7 @@ module Slather
|
|
123
137
|
end
|
124
138
|
|
125
139
|
def line_coverage_data
|
126
|
-
|
140
|
+
all_lines.map do |line|
|
127
141
|
coverage_for_line(line, self.line_numbers_first)
|
128
142
|
end
|
129
143
|
end
|
data/lib/slather/project.rb
CHANGED
@@ -191,36 +191,38 @@ module Slather
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def profdata_coverage_dir
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
194
|
+
@profdata_coverage_dir ||= begin
|
195
|
+
raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory)
|
196
|
+
dir = nil
|
197
|
+
if self.scheme
|
198
|
+
dir = Dir[File.join(build_directory,"/**/CodeCoverage/#{self.scheme}")].first
|
199
|
+
else
|
200
|
+
dir = Dir[File.join(build_directory,"/**/#{first_product_name}")].first
|
201
|
+
end
|
201
202
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
203
|
+
if dir == nil
|
204
|
+
# Xcode 7.3 moved the location of Coverage.profdata
|
205
|
+
dir = Dir[File.join(build_directory,"/**/CodeCoverage")].first
|
206
|
+
end
|
206
207
|
|
207
|
-
|
208
|
-
|
209
|
-
|
208
|
+
if dir == nil && Slather.xcode_version[0] >= 9
|
209
|
+
# Xcode 9 moved the location of Coverage.profdata
|
210
|
+
coverage_files = Dir[File.join(build_directory, "/**/ProfileData/*/Coverage.profdata")]
|
210
211
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
212
|
+
if coverage_files.count == 0
|
213
|
+
# Look up one directory
|
214
|
+
# The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates)
|
215
|
+
coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
|
216
|
+
end
|
216
217
|
|
217
|
-
|
218
|
-
|
218
|
+
if coverage_files != nil && coverage_files.count != 0
|
219
|
+
dir = Pathname.new(coverage_files.first).parent()
|
220
|
+
end
|
219
221
|
end
|
220
|
-
end
|
221
222
|
|
222
|
-
|
223
|
-
|
223
|
+
raise StandardError, "No coverage directory found." unless dir != nil
|
224
|
+
dir
|
225
|
+
end
|
224
226
|
end
|
225
227
|
|
226
228
|
def profdata_file
|
data/lib/slather/version.rb
CHANGED
data/slather.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
21
|
-
spec.add_development_dependency 'coveralls', '~> 0'
|
21
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
22
22
|
spec.add_development_dependency 'simplecov', '~> 0'
|
23
23
|
spec.add_development_dependency 'rake', '~> 12.3'
|
24
24
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
@@ -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
|
@@ -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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Larsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '0.8'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '0.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -337,8 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
337
337
|
- !ruby/object:Gem::Version
|
338
338
|
version: '0'
|
339
339
|
requirements: []
|
340
|
-
|
341
|
-
rubygems_version: 2.7.6
|
340
|
+
rubygems_version: 3.1.2
|
342
341
|
signing_key:
|
343
342
|
specification_version: 4
|
344
343
|
summary: Test coverage reports for Xcode projects
|