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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7984985bdbdff4ddf35556121d63a21e039228a
4
- data.tar.gz: 43adff6756fc7d8c2c6d544e86cd8daec446a60b
3
+ metadata.gz: da2758b99e44d950c2911d36f08b1aac504c88ef
4
+ data.tar.gz: 271d955103fb0d6d932a99352e44d91442809b9d
5
5
  SHA512:
6
- metadata.gz: 8af9af31f32cb3352170c3b18004b3c10cdda446b023ba48034ef9970a1bf2af0867e675523ac5cc64e9601e878820bc8153699fc6fe0ac55fc958d659121692
7
- data.tar.gz: 8c85209f1fa8cc3d737377c4e4d508520027187261b53dd58ee92a5c784dada13a98ed426ddcfc067bfb8359aaa3afc68ff66827ee7c18626e61779cbbfab686
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['XCOV_CORE_LIBRARY_PATH'] = File.expand_path("../xcov-core/bin", __FILE__) + "/xcov-core"
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
- command = "#{ENV['XCOV_CORE_LIBRARY_PATH'].shellescape} -s #{file.shellescape} -o #{report_output.path.shellescape} --include-lines-info"
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)
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module Xcov
2
2
  module Core
3
- VERSION = "0.4"
3
+ VERSION = "0.5"
4
4
  end
5
5
  end
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}*.xccoverage"].sort_by { |filename| File.mtime(filename) }.reverse
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
- json_report = Xcov::Core::Parser.parse(xccoverage_files.first, Xcov.config[:output_directory])
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
@@ -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
- executable = targets.reduce(0) do |partial_result, target|
23
- partial_result + target.executable_lines
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
@@ -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)
@@ -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, executable, covered, files)
10
+ def initialize(name, files)
13
11
  @name = CGI::escapeHTML(name)
14
- @executable_lines = executable
15
- @covered_lines = covered
16
12
  @files = files
17
- # we cast to floats because integers always return 0
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, executable, covered, files)
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
@@ -1,6 +1,6 @@
1
1
  module Xcov
2
2
 
3
- VERSION = "1.3.5"
3
+ VERSION = "1.4.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.3.5
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-20 00:00:00.000000000 Z
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