xcov 1.5.1 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 39093eb1a121b8746609124b8d4e7e8433127777
4
- data.tar.gz: 521073d98ad4229dbbe7c2ded44235a4a236d9cc
2
+ SHA256:
3
+ metadata.gz: 36baa2a5175fb9d5664e322d39a9bb3110cde70e672ed6c3a5c858f725478da7
4
+ data.tar.gz: 34287b2a2cbf7fe408d1eaf39e8cc414c87a2ef3c873c4d6f6cd3535afcfe592
5
5
  SHA512:
6
- metadata.gz: d82f23e8a4ad93740091e26c1b5ee6defc71ecf2bd1c3ca25f2c9b2aeef87c467322a613de3c090aea80627c450a5e1f9f985e2d8a81183aba9a8d0c64b6a616
7
- data.tar.gz: 4ab27e291ef1f3a6bea483911324d033624d143cc55f8c9925da8301cb7ccdeada8e6644e8b642f01eef74ba18818cde5df4b4d7c049876c5c7a18ff2e189e8d
6
+ metadata.gz: d5963ae1495ec0de0c0b10d3fda2ed1c6431319c009cb5098d54a2aacc9fae8506e30301fc6c713459934462b28deeace8d5b2c584da8d9fa9aba4c8f1c0a80b
7
+ data.tar.gz: 2f4277eb3eabf9433f38914ad607b9365a90c83120b738dc8bb8fb43993cda09fd67e3ef53ddc1f51adf4ce7dd6473b1a0062e2e66bde31a0c60a60ad8db6ec1
data/lib/xcov/manager.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require 'fastlane_core'
2
2
  require 'pty'
3
3
  require 'open3'
4
+ require 'tmpdir'
4
5
  require 'fileutils'
5
6
  require 'terminal-table'
6
7
  require 'xcov-core'
7
8
  require 'pathname'
8
9
  require 'json'
10
+ require 'xcresult'
9
11
 
10
12
  module Xcov
11
13
  class Manager
@@ -38,18 +40,26 @@ module Xcov
38
40
  def parse_xccoverage
39
41
  # Find .xccoverage file
40
42
  # If no xccov direct path, use the old derived data path method
41
- if xccov_file_direct_path.nil?
43
+ if xccov_file_direct_paths.nil?
42
44
  extension = Xcov.config[:legacy_support] ? "xccoverage" : "xccovreport"
43
45
  test_logs_path = derived_data_path + "Logs/Test/"
44
46
  xccoverage_files = Dir["#{test_logs_path}*.#{extension}", "#{test_logs_path}*.xcresult/*/action.#{extension}"].sort_by { |filename| File.mtime(filename) }.reverse
45
47
 
48
+ if xccoverage_files.empty?
49
+ xcresult_paths = Dir["#{test_logs_path}*.xcresult"].sort_by { |filename| File.mtime(filename) }.reverse
50
+ xcresult_paths.each do |xcresult_path|
51
+ xccoverage_files += export_paths_from_xcresult!(xcresult_path)
52
+ end
53
+ end
54
+
46
55
  unless test_logs_path.directory? && !xccoverage_files.empty?
47
56
  ErrorHandler.handle_error("XccoverageFileNotFound")
48
57
  end
49
58
  else
50
- xccoverage_files = ["#{xccov_file_direct_path}"]
59
+ xccoverage_files = xccov_file_direct_paths
51
60
  end
52
61
 
62
+
53
63
  # Convert .xccoverage file to json
54
64
  ide_foundation_path = Xcov.config[:legacy_support] ? nil : Xcov.config[:ideFoundationPath]
55
65
  json_report = Xcov::Core::Parser.parse(xccoverage_files.first, Xcov.config[:output_directory], ide_foundation_path)
@@ -155,12 +165,27 @@ module Xcov
155
165
  return product_builds_path.parent.parent
156
166
  end
157
167
 
158
- def xccov_file_direct_path
168
+ def xccov_file_direct_paths
159
169
  # If xccov_file_direct_path was supplied, return
160
170
  if Xcov.config[:xccov_file_direct_path].nil?
161
171
  return nil
162
172
  end
163
- return Pathname.new(Xcov.config[:xccov_file_direct_path])
173
+
174
+ path = Xcov.config[:xccov_file_direct_path]
175
+ if File.extname(path) == '.xcresult'
176
+ return export_paths_from_xcresult!(path)
177
+ end
178
+
179
+ return [Pathname.new(path).to_s]
180
+ end
181
+
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'")
164
189
  end
165
190
 
166
191
  end
data/lib/xcov/options.rb CHANGED
@@ -77,12 +77,12 @@ module Xcov
77
77
  key: :xccov_file_direct_path,
78
78
  short_option: "-f",
79
79
  env_name: "XCOV_FILE_DIRECT_PATH",
80
- description: "The path to the xccoverage/xccovreport file to parse to generate code coverage",
80
+ description: "The path to the xccoverage/xccovreport/xcresult file to parse to generate code coverage",
81
81
  optional: true,
82
82
  verify_block: proc do |value|
83
83
  v = File.expand_path(value.to_s)
84
- raise "xccoverage/xccovreport file does not exist".red unless File.exist?(v)
85
- raise "Invalid xccov file type (must be xccoverage or xccovreport)".red unless value.end_with? "xccoverage" or value.end_with? "xccovreport"
84
+ raise "xccoverage/xccovreport/xcresult file does not exist".red unless File.exist?(v)
85
+ raise "Invalid xccov file type (must be xccoverage, xccovreport, xcresult)".red unless value.end_with? "xccoverage" or value.end_with? "xccovreport" or value.end_with? "xcresult"
86
86
  end
87
87
  ),
88
88
  FastlaneCore::ConfigItem.new(
data/lib/xcov/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Xcov
2
2
 
3
- VERSION = "1.5.1"
3
+ VERSION = "1.6.0"
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.5.1
4
+ version: 1.6.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: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: xcresult
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.1.1
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.1.1
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: bundler
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -195,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
209
  - !ruby/object:Gem::Version
196
210
  version: '0'
197
211
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.5.1
212
+ rubygems_version: 3.0.3
200
213
  signing_key:
201
214
  specification_version: 4
202
215
  summary: xcov is a friendly visualizer for Xcode's code coverage files