xcov 1.6.0 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36baa2a5175fb9d5664e322d39a9bb3110cde70e672ed6c3a5c858f725478da7
4
- data.tar.gz: 34287b2a2cbf7fe408d1eaf39e8cc414c87a2ef3c873c4d6f6cd3535afcfe592
3
+ metadata.gz: c32dea765a1ab454e9c7cfe52e0b2c811ed95cdd298824a9d13d88d678591ac0
4
+ data.tar.gz: 2f36b292854842a4eaa5b5d1229c5c7fcc4df8c92bd8e51d2cbea0bea306c619
5
5
  SHA512:
6
- metadata.gz: d5963ae1495ec0de0c0b10d3fda2ed1c6431319c009cb5098d54a2aacc9fae8506e30301fc6c713459934462b28deeace8d5b2c584da8d9fa9aba4c8f1c0a80b
7
- data.tar.gz: 2f4277eb3eabf9433f38914ad607b9365a90c83120b738dc8bb8fb43993cda09fd67e3ef53ddc1f51adf4ce7dd6473b1a0062e2e66bde31a0c60a60ad8db6ec1
6
+ metadata.gz: 6ec5ec18d4ca35b5ed61f9f17ab1cd6f402f2e31e7f0d5c8a37710892884fefed6173fcd7af5ecae48c51563a28fee57d2ac93c970af5aac20313b6a8b0f1b4e
7
+ data.tar.gz: fefa702e5ea8344912cc37d191e6a4567d41ce50537c2456aab472fdfc6fa59efc5ffcd9ec6d754118ea4b660a3f8591df26a2a5a54fe3f3b50a971d30970cda
Binary file
@@ -1,5 +1,5 @@
1
1
  module Xcov
2
2
  module Core
3
- VERSION = "0.7"
3
+ VERSION = "0.8"
4
4
  end
5
5
  end
@@ -35,9 +35,16 @@ module Xcov
35
35
  submit_to_coveralls(report)
36
36
  tmp_dir = File.join(Xcov.config[:output_directory], 'tmp')
37
37
  FileUtils.rm_rf(tmp_dir) if File.directory?(tmp_dir)
38
+
39
+ json_report
38
40
  end
39
41
 
40
42
  def parse_xccoverage
43
+ xccoverage_files = []
44
+
45
+ # xcresults to parse and export after collecting
46
+ xcresults_to_parse_and_export = []
47
+
41
48
  # Find .xccoverage file
42
49
  # If no xccov direct path, use the old derived data path method
43
50
  if xccov_file_direct_paths.nil?
@@ -48,17 +55,36 @@ module Xcov
48
55
  if xccoverage_files.empty?
49
56
  xcresult_paths = Dir["#{test_logs_path}*.xcresult"].sort_by { |filename| File.mtime(filename) }.reverse
50
57
  xcresult_paths.each do |xcresult_path|
51
- xccoverage_files += export_paths_from_xcresult!(xcresult_path)
58
+ xcresults_to_parse_and_export << xcresult_path
52
59
  end
53
60
  end
54
61
 
55
- unless test_logs_path.directory? && !xccoverage_files.empty?
62
+ unless test_logs_path.directory?
56
63
  ErrorHandler.handle_error("XccoverageFileNotFound")
57
64
  end
58
65
  else
59
- xccoverage_files = xccov_file_direct_paths
66
+ # Iterate over direct paths and find .xcresult files
67
+ # that need to be processed before getting coverage
68
+ xccov_file_direct_paths.each do |path|
69
+ if File.extname(path) == '.xcresult'
70
+ xcresults_to_parse_and_export << path
71
+ else
72
+ xccoverage_files << path
73
+ end
74
+ end
60
75
  end
61
76
 
77
+ # Iterates over xcresults
78
+ # Exports .xccovarchives
79
+ # Exports .xccovreports and collects the paths
80
+ unless xcresults_to_parse_and_export.empty?
81
+ xccoverage_files = process_xcresults!(xcresults_to_parse_and_export)
82
+ end
83
+
84
+ # Errors if no coverage files were found
85
+ if xccoverage_files.empty?
86
+ ErrorHandler.handle_error("XccoverageFileNotFound")
87
+ end
62
88
 
63
89
  # Convert .xccoverage file to json
64
90
  ide_foundation_path = Xcov.config[:legacy_support] ? nil : Xcov.config[:ideFoundationPath]
@@ -172,21 +198,36 @@ module Xcov
172
198
  end
173
199
 
174
200
  path = Xcov.config[:xccov_file_direct_path]
175
- if File.extname(path) == '.xcresult'
176
- return export_paths_from_xcresult!(path)
177
- end
178
-
179
201
  return [Pathname.new(path).to_s]
180
202
  end
181
203
 
182
- def export_paths_from_xcresult!(path)
183
- parser = XCResult::Parser.new(path: path)
184
- return parser.export_xccovreports(destination: Dir.mktmpdir)
185
- rescue
186
- UI.error("Error occured while exporting xccovreport from xcresult '#{path}'")
187
- UI.error("Make sure you have both Xcode 11 selected and pointing to the correct xcresult file")
188
- UI.crash!("Failed to export xccovreport from xcresult'")
189
- end
204
+ def process_xcresults!(xcresult_paths)
205
+ output_path = Xcov.config[:output_directory]
206
+ FileUtils.mkdir_p(output_path)
190
207
 
208
+ return xcresult_paths.flat_map do |xcresult_path|
209
+ begin
210
+ parser = XCResult::Parser.new(path: xcresult_path)
211
+
212
+ # Exporting to same directory as xcresult
213
+ archive_paths = parser.export_xccovarchives(destination: output_path)
214
+ report_paths = parser.export_xccovreports(destination: output_path)
215
+
216
+ # Informating user of export paths
217
+ archive_paths.each do |path|
218
+ UI.important("Copying .xccovarchive to #{path}")
219
+ end
220
+ report_paths.each do |path|
221
+ UI.important("Copying .xccovreport to #{path}")
222
+ end
223
+
224
+ report_paths
225
+ rescue
226
+ UI.error("Error occured while exporting xccovreport from xcresult '#{xcresult_path}'")
227
+ UI.error("Make sure you have both Xcode 11 selected and pointing to the correct xcresult file")
228
+ UI.crash!("Failed to export xccovreport from xcresult'")
229
+ end
230
+ end
231
+ end
191
232
  end
192
233
  end
@@ -8,14 +8,18 @@ module Xcov
8
8
  attr_accessor :type
9
9
  attr_accessor :ignored
10
10
  attr_accessor :coverage
11
+ attr_accessor :coveredLines
12
+ attr_accessor :executableLines
11
13
  attr_accessor :functions
12
14
  attr_accessor :function_templates
13
15
  attr_accessor :lines
14
16
 
15
- def initialize(name, location, coverage, functions, lines = nil)
17
+ def initialize(name, location, coverage, coveredLines, executableLines, functions, lines = nil)
16
18
  @name = CGI::escapeHTML(name)
17
19
  @location = CGI::escapeHTML(location)
18
20
  @coverage = coverage
21
+ @coveredLines = coveredLines
22
+ @executableLines = executableLines
19
23
  @functions = functions
20
24
  @ignored = Xcov.ignore_handler.should_ignore_file_at_path(location)
21
25
  @displayable_coverage = self.create_displayable_coverage
@@ -52,6 +56,7 @@ module Xcov
52
56
  def json_value
53
57
  value = {
54
58
  "name" => @name,
59
+ "path" => @location,
55
60
  "coverage" => @coverage,
56
61
  "type" => @type,
57
62
  "functions" => @functions ? @functions.map{ |function| function.json_value } : []
@@ -68,9 +73,11 @@ module Xcov
68
73
  name = dictionary["name"]
69
74
  location = dictionary["location"]
70
75
  coverage = dictionary["coverage"]
76
+ coveredLines = dictionary["coveredLines"]
77
+ executableLines = dictionary["executableLines"]
71
78
  functions = dictionary["functions"].map { |function| Function.map(function)}
72
79
  lines = map_lines(dictionary["lines"])
73
- Source.new(name, location, coverage, functions, lines)
80
+ Source.new(name, location, coverage, coveredLines, executableLines, functions, lines)
74
81
  end
75
82
 
76
83
  def self.map_lines(dictionaries)
@@ -7,10 +7,12 @@ module Xcov
7
7
  attr_accessor :files
8
8
  attr_accessor :file_templates
9
9
 
10
- def initialize(name, coverage, files)
10
+ def initialize(name, files)
11
11
  @name = CGI::escapeHTML(name)
12
12
  @files = files
13
- @coverage = coverage
13
+ totalCoveredLines = files.reduce(0) { |acc, file| acc + file.coveredLines }
14
+ totalExecutableLines = files.reduce(0) { |acc, file| acc + file.executableLines }
15
+ @coverage = files.count == 0 || totalExecutableLines == 0 ? 0.0 : totalCoveredLines.to_f / totalExecutableLines.to_f
14
16
  @displayable_coverage = self.create_displayable_coverage
15
17
  @coverage_color = self.create_coverage_color
16
18
  @id = Target.create_id(name)
@@ -53,12 +55,11 @@ module Xcov
53
55
 
54
56
  def self.map(dictionary)
55
57
  name = dictionary["name"]
56
- coverage = dictionary["coverage"]
57
58
  files = dictionary["files"].map { |file| Source.map(file)}
58
59
  files = files.sort &by_coverage_with_ignored_at_the_end
59
60
  non_ignored_files = Target.select_non_ignored_files(files)
60
61
 
61
- Target.new(name, coverage, non_ignored_files)
62
+ Target.new(name, non_ignored_files)
62
63
  end
63
64
 
64
65
  def self.by_coverage_with_ignored_at_the_end
@@ -93,6 +93,14 @@ module Xcov
93
93
  default_value: File.join(containing, "xcov_report"),
94
94
  default_value_dynamic: true
95
95
  ),
96
+ FastlaneCore::ConfigItem.new(
97
+ key: :cloned_source_packages_path,
98
+ short_option: "-C",
99
+ env_name: "XCOV_CLONED_SOURCE_PACKAGES_PATH",
100
+ description: "Sets a custom path for Swift Package Manager dependencies",
101
+ type: String,
102
+ optional: true
103
+ ),
96
104
 
97
105
  # Report options
98
106
  FastlaneCore::ConfigItem.new(
@@ -1,6 +1,6 @@
1
1
  module Xcov
2
2
 
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.4"
4
4
  DESCRIPTION = "xcov is a friendly visualizer for Xcode's code coverage files"
5
5
 
6
6
  end
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.6.0
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Vidal
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.82.0
19
+ version: 2.141.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 2.82.0
29
+ version: 2.141.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.1.1
95
+ version: 0.2.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.1.1
102
+ version: 0.2.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: bundler
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -190,11 +190,11 @@ files:
190
190
  - views/function.erb
191
191
  - views/report.erb
192
192
  - views/target.erb
193
- homepage: https://github.com/nakiostudio/xcov
193
+ homepage: https://github.com/fastlane-community/xcov
194
194
  licenses:
195
195
  - MIT
196
196
  metadata: {}
197
- post_install_message:
197
+ post_install_message:
198
198
  rdoc_options: []
199
199
  require_paths:
200
200
  - lib
@@ -209,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubygems_version: 3.0.3
213
- signing_key:
212
+ rubygems_version: 3.0.6
213
+ signing_key:
214
214
  specification_version: 4
215
215
  summary: xcov is a friendly visualizer for Xcode's code coverage files
216
216
  test_files: []