xcov 1.3.5 → 1.4.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/README.md +2 -1
- data/lib/xcov-core.rb +6 -3
- data/lib/xcov-core/bin/xcov-core +0 -0
- data/lib/xcov-core/bin/xcov-core-legacy +0 -0
- data/lib/xcov-core/version.rb +1 -1
- data/lib/xcov/manager.rb +4 -2
- data/lib/xcov/model/report.rb +2 -11
- data/lib/xcov/model/source.rb +0 -10
- data/lib/xcov/model/target.rb +3 -27
- data/lib/xcov/options.rb +16 -0
- data/lib/xcov/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da2758b99e44d950c2911d36f08b1aac504c88ef
|
4
|
+
data.tar.gz: 271d955103fb0d6d932a99352e44d91442809b9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40a3c1f8964eeea59e200af826a8b6672fe17462c9e96ca0c68356f184dc55b3990bcfe46d1ded3f9c00727162c9dde6ddda8e425ff9a9f6385b7f59bc1e2da
|
7
|
+
data.tar.gz: 50f0692e00f140a4d37ddaec13220094077116131caa38b3975611fda65bc3d87439b70f3ad20f931406bebc8b8db16886624f9a31ad254977a3d86d9f038e60
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ In order to make *xcov* run you must:
|
|
45
45
|
</h3>
|
46
46
|
|
47
47
|
## Usage
|
48
|
-
*xcov* analyzes the `.xccoverage` files created after running your tests therefore, before executing xcov, you need to run your tests with either `Xcode`, `xcodebuild` or [scan](https://github.com/fastlane/fastlane/tree/master/scan). Once completed, obtain your coverage report by providing a few parameters:
|
48
|
+
*xcov* analyzes the `.xccoverage` and `.xccovreport` files created after running your tests therefore, before executing xcov, you need to run your tests with either `Xcode`, `xcodebuild` or [scan](https://github.com/fastlane/fastlane/tree/master/scan). Once completed, obtain your coverage report by providing a few parameters:
|
49
49
|
```
|
50
50
|
xcov -w LystSDK.xcworkspace -s LystSDK -o xcov_output
|
51
51
|
```
|
@@ -75,6 +75,7 @@ xcov -w LystSDK.xcworkspace -s LystSDK -o xcov_output
|
|
75
75
|
* `--coveralls_repo_token`: Repository token to be used by integrations not compatible with Coveralls (optional).
|
76
76
|
* `--slack_username`: The username which is used to publish to slack (optional).
|
77
77
|
* `--slack_message`: The message which is published together with a successful report (optional).
|
78
|
+
* `--legacy_support`: Enables parsing coverage reports generated by Xcode 9.2 or previous versions.
|
78
79
|
|
79
80
|
_**Note:** All paths you provide should be absolute and unescaped_
|
80
81
|
|
data/lib/xcov-core.rb
CHANGED
@@ -8,15 +8,18 @@ require 'fastlane_core'
|
|
8
8
|
module Xcov
|
9
9
|
module Core
|
10
10
|
|
11
|
-
ENV['
|
11
|
+
ENV['XCOV_CORE_BINARY_PATH'] = File.expand_path("../xcov-core/bin", __FILE__) + "/xcov-core"
|
12
|
+
ENV['XCOV_CORE_LEGACY_BINARY_PATH'] = File.expand_path("../xcov-core/bin", __FILE__) + "/xcov-core-legacy"
|
12
13
|
|
13
14
|
class Parser
|
14
15
|
|
15
|
-
def self.parse(file, output_directory)
|
16
|
+
def self.parse(file, output_directory, ide_foundation_path)
|
16
17
|
tmp_dir = File.join(output_directory, 'tmp')
|
17
18
|
FileUtils.mkdir_p(tmp_dir) unless File.directory?(tmp_dir)
|
18
19
|
report_output = Tempfile.new("report.json", tmp_dir)
|
19
|
-
|
20
|
+
binary_path = ide_foundation_path.nil? ? ENV['XCOV_CORE_LEGACY_BINARY_PATH'] : ENV['XCOV_CORE_BINARY_PATH']
|
21
|
+
command = "#{binary_path.shellescape} -s #{file.shellescape} -o #{report_output.path.shellescape}"
|
22
|
+
command << " --ide-foundation-path #{ide_foundation_path}" unless ide_foundation_path.nil?
|
20
23
|
description = [{ prefix: "Parsing .xccoverage file: " }]
|
21
24
|
execute_command(command, description)
|
22
25
|
output_file = File.read(report_output.path)
|
data/lib/xcov-core/bin/xcov-core
CHANGED
Binary file
|
Binary file
|
data/lib/xcov-core/version.rb
CHANGED
data/lib/xcov/manager.rb
CHANGED
@@ -37,15 +37,17 @@ module Xcov
|
|
37
37
|
|
38
38
|
def parse_xccoverage
|
39
39
|
# Find .xccoverage file
|
40
|
+
extension = Xcov.config[:legacy_support] ? "xccoverage" : "xccovreport"
|
40
41
|
test_logs_path = derived_data_path + "Logs/Test/"
|
41
|
-
xccoverage_files = Dir["#{test_logs_path}
|
42
|
+
xccoverage_files = Dir["#{test_logs_path}*.#{extension}"].sort_by { |filename| File.mtime(filename) }.reverse
|
42
43
|
|
43
44
|
unless test_logs_path.directory? && !xccoverage_files.empty?
|
44
45
|
ErrorHandler.handle_error("XccoverageFileNotFound")
|
45
46
|
end
|
46
47
|
|
47
48
|
# Convert .xccoverage file to json
|
48
|
-
|
49
|
+
ide_foundation_path = Xcov.config[:legacy_support] ? nil : Xcov.config[:ideFoundationPath]
|
50
|
+
json_report = Xcov::Core::Parser.parse(xccoverage_files.first, Xcov.config[:output_directory], ide_foundation_path)
|
49
51
|
ErrorHandler.handle_error("UnableToParseXccoverageFile") if json_report.nil?
|
50
52
|
|
51
53
|
json_report
|
data/lib/xcov/model/report.rb
CHANGED
@@ -19,17 +19,8 @@ module Xcov
|
|
19
19
|
return 0 if targets.count == 0
|
20
20
|
return targets.first.coverage if targets.count == 1
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
covered = targets.reduce(0) do |partial_result, target|
|
27
|
-
partial_result + target.covered_lines
|
28
|
-
end
|
29
|
-
|
30
|
-
return 0 if executable == 0 # avoid ZeroDivisionError
|
31
|
-
|
32
|
-
covered.to_f / executable.to_f
|
22
|
+
acc_coverage = targets.reduce(0) { |acc, target| acc + target.coverage }
|
23
|
+
acc_coverage.to_f / targets.count
|
33
24
|
end
|
34
25
|
|
35
26
|
def print_description
|
data/lib/xcov/model/source.rb
CHANGED
@@ -62,16 +62,6 @@ module Xcov
|
|
62
62
|
return value
|
63
63
|
end
|
64
64
|
|
65
|
-
def number_of_executable_lines
|
66
|
-
return 0 if lines.nil? || lines.empty?
|
67
|
-
lines.select { |line| line.executable }.count
|
68
|
-
end
|
69
|
-
|
70
|
-
def number_of_covered_lines
|
71
|
-
return 0 if lines.nil? || lines.empty?
|
72
|
-
lines.select { |line| line.covered? }.count
|
73
|
-
end
|
74
|
-
|
75
65
|
# Class methods
|
76
66
|
|
77
67
|
def self.map(dictionary)
|
data/lib/xcov/model/target.rb
CHANGED
@@ -4,18 +4,13 @@ module Xcov
|
|
4
4
|
class Target < Xcov::Base
|
5
5
|
|
6
6
|
attr_accessor :name
|
7
|
-
attr_accessor :executable_lines # number of executable lines in target
|
8
|
-
attr_accessor :covered_lines # number of covered lines in target
|
9
7
|
attr_accessor :files
|
10
8
|
attr_accessor :file_templates
|
11
9
|
|
12
|
-
def initialize(name,
|
10
|
+
def initialize(name, files)
|
13
11
|
@name = CGI::escapeHTML(name)
|
14
|
-
@executable_lines = executable
|
15
|
-
@covered_lines = covered
|
16
12
|
@files = files
|
17
|
-
|
18
|
-
@coverage = executable == 0 ? 0.0 : covered.to_f / executable # avoid ZeroDivisionError
|
13
|
+
@coverage = files.count == 0 ? 0.0 : files.reduce(0) { |acc, file| acc + file.coverage.to_f } / files.count
|
19
14
|
@displayable_coverage = self.create_displayable_coverage
|
20
15
|
@coverage_color = self.create_coverage_color
|
21
16
|
@id = Target.create_id(name)
|
@@ -60,12 +55,9 @@ module Xcov
|
|
60
55
|
name = dictionary["name"]
|
61
56
|
files = dictionary["files"].map { |file| Source.map(file)}
|
62
57
|
files = files.sort &by_coverage_with_ignored_at_the_end
|
63
|
-
|
64
58
|
non_ignored_files = Target.select_non_ignored_files(files)
|
65
|
-
executable = Target.calculate_number_of_executable_lines(non_ignored_files)
|
66
|
-
covered = Target.calculate_number_of_covered_lines(non_ignored_files)
|
67
59
|
|
68
|
-
Target.new(name,
|
60
|
+
Target.new(name, non_ignored_files)
|
69
61
|
end
|
70
62
|
|
71
63
|
def self.by_coverage_with_ignored_at_the_end
|
@@ -85,21 +77,5 @@ module Xcov
|
|
85
77
|
files.select { |file| !file.ignored }
|
86
78
|
end
|
87
79
|
|
88
|
-
def self.calculate_number_of_covered_lines(files)
|
89
|
-
return 0 if files.nil? || files.empty?
|
90
|
-
|
91
|
-
files.reduce(0) do |partial_result, file|
|
92
|
-
partial_result + file.number_of_covered_lines
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.calculate_number_of_executable_lines(files)
|
97
|
-
return 0 if files.nil? || files.empty?
|
98
|
-
|
99
|
-
files.reduce(0) do |partial_result, file|
|
100
|
-
partial_result + file.number_of_executable_lines
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
80
|
end
|
105
81
|
end
|
data/lib/xcov/options.rb
CHANGED
@@ -220,6 +220,22 @@ module Xcov
|
|
220
220
|
verify_block: proc do |value|
|
221
221
|
UI.user_error!("File not found at path '#{File.expand_path(value)}'") unless File.exist?(value)
|
222
222
|
end
|
223
|
+
),
|
224
|
+
|
225
|
+
# xccovreport compatibility options
|
226
|
+
FastlaneCore::ConfigItem.new(
|
227
|
+
key: :ideFoundationPath,
|
228
|
+
env_name: "XCOV_IDE_FOUNDATION_PATH",
|
229
|
+
description: "Absolute path to the IDEFoundation.framework binary",
|
230
|
+
optional: true,
|
231
|
+
default_value: File.join(`/usr/bin/xcode-select -p`.delete!("\n"), "../Frameworks/IDEFoundation.framework/Versions/A/IDEFoundation")
|
232
|
+
),
|
233
|
+
FastlaneCore::ConfigItem.new(
|
234
|
+
key: :legacy_support,
|
235
|
+
env_name: "XCOV_LEGACY_SUPPORT",
|
236
|
+
description: "Whether xcov should parse a xccoverage file instead on xccovreport",
|
237
|
+
optional: true,
|
238
|
+
default_value: false
|
223
239
|
)
|
224
240
|
]
|
225
241
|
end
|
data/lib/xcov/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Vidal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- bin/xcov
|
154
154
|
- lib/xcov-core.rb
|
155
155
|
- lib/xcov-core/bin/xcov-core
|
156
|
+
- lib/xcov-core/bin/xcov-core-legacy
|
156
157
|
- lib/xcov-core/version.rb
|
157
158
|
- lib/xcov.rb
|
158
159
|
- lib/xcov/commands_generator.rb
|