Skip to content

Commit e41e560

Browse files
author
Julian Krumow
committed
Squashed commit of the following:
commit 6a19585 Merge: 36db604 edc92c4 Author: Simone Civetta <[email protected]> Date: Mon Jan 18 18:11:39 2016 +0100 Merge pull request SlatherOrg#17 from viteinfinite/feature-profdata-flavoured-specs Update specs to test against profdata output instead of gcov commit edc92c4 Author: Simone Civetta <[email protected]> Date: Mon Jan 18 17:55:45 2016 +0100 [specs] Update specs to test against profdata output instead of gcov commit c460c4f Author: Simone Civetta <[email protected]> Date: Mon Jan 18 17:52:16 2016 +0100 [profdata] Add specs for ignoring platform files commit ab7004c Author: Simone Civetta <[email protected]> Date: Mon Jan 18 17:16:25 2016 +0100 [command] Add spec for verbose mode commit 2930bef Author: Simone Civetta <[email protected]> Date: Mon Jan 18 17:08:31 2016 +0100 [profdata] Ignore platform files commit 3442a20 Author: Simone Civetta <[email protected]> Date: Mon Jan 18 15:48:05 2016 +0100 [command] Add verbose mode commit 36db604 Merge: 1408a73 5d555fe Author: Simone Civetta <[email protected]> Date: Sun Dec 27 03:05:53 2015 +0100 Merge pull request SlatherOrg#16 from viteinfinite/feature-binaryfile-param Fix spec when running in a CI environment commit 5d555fe Author: Simone Civetta <[email protected]> Date: Sun Dec 27 03:03:58 2015 +0100 [coveralls] Fix spec when running in a CI environment commit 1408a73 Merge: 19cd964 1e40d93 Author: Simone Civetta <[email protected]> Date: Sun Dec 27 02:43:46 2015 +0100 Merge pull request SlatherOrg#15 from viteinfinite/feature-binaryfile-param Add binary_file param commit 1e40d93 Author: Simone Civetta <[email protected]> Date: Sun Dec 27 01:42:17 2015 +0100 [project] Refactor configuration method names commit 2c43d91 Author: Simone Civetta <[email protected]> Date: Sun Dec 27 01:36:06 2015 +0100 [project] Refactor configuration steps commit 6a16699 Author: Simone Civetta <[email protected]> Date: Thu Dec 24 02:16:58 2015 +0100 [profdata] Add binary file param commit 19cd964 Merge: e8b7e21 5343de6 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 22:31:49 2015 +0100 Merge pull request SlatherOrg#14 from viteinfinite/fix-macos-binary [specs] Fix MacOS binary file spec commit 5343de6 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 22:30:36 2015 +0100 [specs] Fix MacOS binary file spec commit e8b7e21 Merge: ad9b9eb aab3a15 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 22:09:23 2015 +0100 Merge pull request SlatherOrg#13 from viteinfinite/fix-macos-binary Fix MacOS binary file detection commit aab3a15 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 22:08:08 2015 +0100 [profdata] Fix binary file detection for MacOS apps commit ad9b9eb Merge: 57c8850 c05b0c0 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 15:44:00 2015 +0100 Merge pull request SlatherOrg#12 from viteinfinite/feature-re-encode-develop Re-encode llvm-cov output to prevent potential "invalid byte sequence" issue commit c05b0c0 Author: Simone Civetta <[email protected]> Date: Thu Dec 17 15:40:37 2015 +0100 [profdata] Re-encode llvm-cov output to prevent potential "invalid byte sequence" issue commit 57c8850 Author: Simone Civetta <[email protected]> Date: Tue Dec 15 16:27:02 2015 +0100 [command] Print environment info for easier debugging commit c01bca0 Author: Simone Civetta <[email protected]> Date: Tue Dec 15 15:32:05 2015 +0100 [profdata] Exclude UITest runner analysis commit a55a142 Author: Simone Civetta <[email protected]> Date: Tue Dec 15 03:35:08 2015 +0100 [spec] Fix path being absolute in HTML fixture commit 1c5baad Author: Simone Civetta <[email protected]> Date: Tue Dec 15 03:22:15 2015 +0100 [spec] De-ignore fixture commit 8158b5c Author: Simone Civetta <[email protected]> Date: Tue Dec 15 02:50:56 2015 +0100 [project] Minor refactoring for easier troubleshooting and readability commit 173e822 Author: Simone Civetta <[email protected]> Date: Mon Dec 14 23:16:49 2015 +0100 [html] Add working profdata support commit 644db09 Author: Simone Civetta <[email protected]> Date: Mon Dec 14 18:06:37 2015 +0100 [project] Are more explicit error when the build_directory does not exist commit e909c76 Author: Simone Civetta <[email protected]> Date: Mon Dec 14 16:47:27 2015 +0100 [command] Improve command clarity commit 9b9bc7c Merge: 0b86c80 37ae46c Author: Simone Civetta <[email protected]> Date: Sun Dec 13 23:36:48 2015 +0100 Merge pull request SlatherOrg#10 from viteinfinite/feature-temp-profdata Merge with master commit 37ae46c Author: Simone Civetta <[email protected]> Date: Sun Dec 13 23:23:54 2015 +0100 [profdata] Improve coveralls spec commit f8fd63d Merge: 84c54a9 87899db Author: Simone Civetta <[email protected]> Date: Fri Dec 11 02:42:09 2015 +0100 Merge branch 'venmo-master' into feature-temp-profdata Conflicts: slather.gemspec commit 0b86c80 Merge: 61f0098 84c54a9 Author: Simone Civetta <[email protected]> Date: Fri Dec 11 02:37:29 2015 +0100 Merge branch 'feature-temp-profdata' into feature-profdata commit 84c54a9 Merge: 0660a07 61f0098 Author: Simone Civetta <[email protected]> Date: Fri Dec 11 02:37:16 2015 +0100 Merge remote-tracking branch 'origin/feature-profdata' into feature-temp-profdata # Conflicts: # lib/slather/project.rb # spec/fixtures/cobertura.xml # spec/fixtures/gutter.json # spec/slather/coverage_service/coveralls_spec.rb # spec/slather/project_spec.rb # spec/spec_helper.rb commit 0660a07 Author: Simone Civetta <[email protected]> Date: Fri Dec 11 02:09:12 2015 +0100 [profdata] Improve project setup specs commit 341c9b9 Author: Simone Civetta <[email protected]> Date: Fri Dec 11 01:24:09 2015 +0100 [profdata] Fix xctest bundle spec commit f361648 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 20:56:41 2015 +0100 [profdata] Fix binary file detection when testing static libraries commit ef9f6d0 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 19:44:49 2015 +0100 [specs] Fix build_directory test commit adae9f5 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 18:32:45 2015 +0100 [profdata] Rename derived_data_dir to derived_data_path commit b92f9b1 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 18:26:54 2015 +0100 [project] Fix typo commit 3dd3558 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 18:25:12 2015 +0100 [profdata] Add profdata fixtures commit 5c96f14 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 17:36:05 2015 +0100 [helper] Set a fixed DerivedData dir for better testing commit 3ec9e2e Author: Simone Civetta <[email protected]> Date: Thu Dec 10 17:34:24 2015 +0100 [xcode7] Make fixtures comply to Xcode7 gcov output commit 2479d59 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 15:54:02 2015 +0100 [xcode7] Make specs less precise in order to conform to Xcode 7 gcov bug commit 0dec11e Author: Simone Civetta <[email protected]> Date: Thu Dec 10 14:51:46 2015 +0100 [helper] Set a fixed DerivedData dir for better testing commit ccc88e5 Author: Simone Civetta <[email protected]> Date: Thu Dec 10 14:51:04 2015 +0100 [profdata] Rename derived_data_dir to derived_data_path commit 342ff7b Author: Simone Civetta <[email protected]> Date: Thu Dec 10 13:56:15 2015 +0100 [profdata] Update cocoa pods and xcodeproj dependencies commit d09ce4f Author: Matt Delves <[email protected]> Date: Wed Sep 23 11:58:48 2015 +1000 [profdata] update cocoapods and xcodeproj dependencies commit f231c8b Author: Matt Delves <[email protected]> Date: Wed Sep 23 11:11:02 2015 +1000 [profdata] Use xcode7 on travisCI commit 5a101fb Author: Matt Delves <[email protected]> Date: Wed Sep 23 11:02:09 2015 +1000 [profdata] update spec usage to expect instead of should commit 0bb51de Author: Matt Delves <[email protected]> Date: Wed Sep 23 10:56:49 2015 +1000 [profdata] Ignore gcda and gcno files commit 5c971d3 Author: Matt Delves <[email protected]> Date: Wed Sep 23 10:55:49 2015 +1000 [profdata] Update rspec to 3.3 commit 510b60c Merge: 8aa1c12 b8997fe Author: Matt Delves <[email protected]> Date: Wed Sep 23 08:21:26 2015 +1000 Merge pull request SlatherOrg#1 from AliSoftware/feature-profdata Fixes for your profdata support commit b8997fe Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 21:25:59 2015 +0200 Using xcrun to find llvm-cov (instead of building the path ourselves) commit ef91356 Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 21:23:56 2015 +0200 Adding "rake spec" task to Rakefile commit 9289c96 Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 21:19:11 2015 +0200 Introducing coverage format auto-detection based on Xcode version * Change "--input-format" option of "slather setup" to "--format", more appropriate name in the context of setup * Supporting auto for `slather setup --format` and `slather coverage --input-format` which will use profdata if Xcode 7, gcov if earlier * Checking the validity of the parameters given to `--format` / `--input-format` commit 8b7a535 Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 01:41:52 2015 +0200 Prepare the code to auto-update xcschemes with "slather setup". This will need us to update the dependency against the xcodeproj gem to "~> 0.27" (which requires to bump the dependency on cocoapods as well) commit d079453 Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 00:47:04 2015 +0200 Add "--input-format" parameter in "slather setup" too, so it can enable CLANG_ENABLE_CODE_COVERAGE instead of GCC_GENERATE_TEST_COVERAGE_FILES + Print explicit error when missing parameter for "slather setup" TODO: improve Xcodeproj gem so my new Xcodeproj::XCScheme implementation also allows to set codeCoverageEnabled = YES in every xcscheme commit 4d0199a Author: Olivier Halligon <[email protected]> Date: Tue Sep 22 00:44:28 2015 +0200 Fix shell escape of llvm-cov path and arguments commit 8aa1c12 Author: Simone Civetta <[email protected]> Date: Mon Aug 10 18:49:59 2015 +0200 Add spec for framework coverage commit e64a7b7 Author: Pierre-Marc Airoldi <[email protected]> Date: Sat Aug 8 14:39:41 2015 -0400 fix llvm-cov path and add framework coverage commit 95a067b Author: Simone Civetta <[email protected]> Date: Fri Jul 10 20:54:53 2015 +0200 Fix whitespace issues commit 7f602d0 Author: Simone Civetta <[email protected]> Date: Sun Jun 21 12:10:29 2015 +0200 Merge branch 'feature-temp-profdata' of https://github.com/viteinfinite/slather into feature-temp-profdata * 'feature-temp-profdata' of https://github.com/viteinfinite/slather: Remove useless file Fix tests Remove useless files Fix unit tests Add more precise path handling Add scheme and ignore Export coverage base info into modules Fix coveralls_spec Minor fixes in spec_helper Re-add coveralls support Re-add coveralls support Add tests [WIP] Refactor interface of coverage_file [WIP] Add unit tests [WIP] Add experimental support to swift commit 9aa2af2 Author: Anthony Mittaz <[email protected]> Date: Thu Jun 18 11:43:45 2015 +1000 fix broken path commit 5cd2399 Author: Simone Civetta <[email protected]> Date: Sat Jun 13 08:44:16 2015 -0700 Add experimental support to profdata file format commit 61f0098 Merge: 7236739 c5d2b70 Author: Simone Civetta <[email protected]> Date: Mon Aug 10 18:53:06 2015 +0200 Merge branch 'petester42-master' into feature-profdata * petester42-master: Add spec for framework coverage Fix llvm-cov path and add framework coverage commit c5d2b70 Author: Simone Civetta <[email protected]> Date: Mon Aug 10 18:49:59 2015 +0200 Add spec for framework coverage commit 9e5724b Author: Pierre-Marc Airoldi <[email protected]> Date: Sat Aug 8 14:39:41 2015 -0400 fix llvm-cov path and add framework coverage commit 7236739 Merge: 32dab65 c70948f Author: Simone Civetta <[email protected]> Date: Sun Jul 12 00:08:42 2015 +0200 Merge pull request SlatherOrg#3 from viteinfinite/fix-whitespaces Fix whitespace issues commit c70948f Author: Simone Civetta <[email protected]> Date: Fri Jul 10 20:54:53 2015 +0200 Fix whitespace issues commit 32dab65 Merge: d3bece9 8558508 Author: Simone Civetta <[email protected]> Date: Sun Jun 21 15:45:30 2015 +0200 Add JSON support to profdata file format commit 8558508 Merge: 1f58caa 0c7877a Author: Simone Civetta <[email protected]> Date: Sun Jun 21 12:13:22 2015 +0200 Merge pull request SlatherOrg#2 from viteinfinite/feature-temp-profdata Add JSON support to profdata format commit 0c7877a Author: Simone Civetta <[email protected]> Date: Sun Jun 21 12:10:29 2015 +0200 Merge branch 'feature-temp-profdata' of https://github.com/viteinfinite/slather into feature-temp-profdata * 'feature-temp-profdata' of https://github.com/viteinfinite/slather: Remove useless file Fix tests Remove useless files Fix unit tests Add more precise path handling Add scheme and ignore Export coverage base info into modules Fix coveralls_spec Minor fixes in spec_helper Re-add coveralls support Re-add coveralls support Add tests [WIP] Refactor interface of coverage_file [WIP] Add unit tests [WIP] Add experimental support to swift commit d3bece9 Merge: b1de838 b305ed8 Author: Simone Civetta <[email protected]> Date: Thu Jun 18 20:03:08 2015 +0200 Merge pull request SlatherOrg#1 from sync/feature-profdata Fix broken path commit b305ed8 Author: Anthony Mittaz <[email protected]> Date: Thu Jun 18 11:43:45 2015 +1000 fix broken path commit b1de838 Author: Simone Civetta <[email protected]> Date: Sat Jun 13 08:44:16 2015 -0700 Add experimental support to profdata file format
1 parent d953cbc commit e41e560

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2234
-1826
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ mkmf.log
2323

2424
# Xcode
2525
#
26-
build/
2726
*.pbxuser
2827
!default.pbxuser
2928
*.mode1v3
@@ -43,3 +42,5 @@ DerivedData
4342
cobertura.xml
4443
.gutter.json
4544
html
45+
*.gcda
46+
*.gcno

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: objective-c
22
script: bundle exec rspec
3+
osx_image: xcode7
34

45
# Sets Travis to run the Ruby specs on OS X machines which are required to
56
# build the native extensions of Xcodeproj.

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
require "bundler/gem_tasks"
2+
3+
desc 'Execute tests'
4+
task :spec do
5+
sh 'bundle exec rspec spec'
6+
end
7+

bin/slather

+39-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Clamp do
99

1010
subcommand "coverage", "Computes coverage for the supplied project" do
1111

12-
parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
12+
parameter "[PROJECT]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
1313

1414
option ["--travis", "-t"], :flag, "Indicate that the builds are running on Travis CI"
1515
option ["--circleci"], :flag, "Indicate that the builds are running on CircleCI"
@@ -27,6 +27,11 @@ Clamp do
2727
option ["--source-directory"], "SOURCE_DIRECTORY", "The directory where your source files are located."
2828
option ["--output-directory"], "OUTPUT_DIRECTORY", "The directory where your Cobertura XML report will be written to."
2929
option ["--ignore", "-i"], "IGNORE", "ignore files conforming to a path", :multivalued => true
30+
option ["--verbose", "-v"], :flag, "Enable verbose mode"
31+
32+
option ["--input-format"], "INPUT_FORMAT", "Input format (gcov, profdata)"
33+
option ["--scheme"], "SCHEME", "The scheme for which the coverage was generated"
34+
option ["--binary-file"], "BINARY_FILE", "The binary file against the which the coverage will be run"
3035

3136
def execute
3237
puts "Slathering..."
@@ -37,6 +42,12 @@ Clamp do
3742
setup_source_directory
3843
setup_output_directory
3944
setup_coverage_service
45+
setup_verbose_mode
46+
setup_input_format
47+
setup_scheme
48+
setup_binary_file
49+
50+
project.configure
4051

4152
post
4253

@@ -81,7 +92,7 @@ Clamp do
8192
if xcodeproj_path_to_open
8293
project = Slather::Project.open(xcodeproj_path_to_open)
8394
else
84-
raise StandardError, "Must provide an xcodeproj through .slather.yml"
95+
raise StandardError, "Must provide an xcodeproj either via the 'slather [SUBCOMMAND] [PROJECT].xcodeproj' command or through .slather.yml"
8596
end
8697
end
8798
end
@@ -101,15 +112,37 @@ Clamp do
101112
end
102113
end
103114

115+
def setup_verbose_mode
116+
project.verbose_mode = verbose?
117+
end
118+
119+
def setup_input_format
120+
project.input_format = input_format
121+
end
122+
123+
def setup_scheme
124+
project.scheme = scheme
125+
end
126+
127+
def setup_binary_file
128+
project.binary_file = binary_file
129+
end
130+
104131
end
105132

106-
subcommand "setup", "Configures an xcodeproj for test coverage generation" do
133+
subcommand "setup", "Configures a .xcodeproj for test coverage generation" do
134+
135+
parameter "[PROJECT]", "Path to the .xcodeproj", :attribute_name => :xcodeproj_path
107136

108-
parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
137+
option ["--format"], "FORMAT", "Type of coverage to use (gcov, clang, auto)"
109138

110139
def execute
111-
project = Slather::Project.open(xcodeproj_path)
112-
project.setup_for_coverage
140+
xcodeproj_path_to_open = xcodeproj_path || Slather::Project.yml["xcodeproj"]
141+
unless xcodeproj_path_to_open
142+
raise StandardError, "Must provide a .xcodeproj either via the 'slather [SUBCOMMAND] [PROJECT].xcodeproj' command or through .slather.yml"
143+
end
144+
project = Slather::Project.open(xcodeproj_path_to_open)
145+
project.setup_for_coverage(format ? format.to_sym : :auto)
113146
project.save
114147
end
115148

lib/slather.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
require 'slather/version'
22
require 'slather/project'
3+
require 'slather/coverage_info'
34
require 'slather/coverage_file'
4-
require 'slather/coveralls_coverage_file'
5+
require 'slather/coveralls_coverage'
6+
require 'slather/profdata_coverage_file'
57
require 'slather/coverage_service/cobertura_xml_output'
68
require 'slather/coverage_service/coveralls'
79
require 'slather/coverage_service/hardcover'
@@ -17,4 +19,10 @@ def self.prepare_pods(pods)
1719
Pod::UI.warn("[Slather] prepare_pods is now deprecated. The call to prepare_pods in your Podfile can simply be ommitted.")
1820
end
1921

22+
def self.xcode_version
23+
xcode_path = `xcode-select -p`.strip
24+
xcode_version = `mdls -name kMDItemVersion -raw #{xcode_path.shellescape}/../..`.strip
25+
xcode_version.split('.').map(&:to_i)
26+
end
27+
2028
end

lib/slather/coverage_file.rb

+37-90
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
require 'slather/coverage_info'
2+
require 'slather/coveralls_coverage'
3+
14
module Slather
25
class CoverageFile
36

7+
include CoverageInfo
8+
include CoverallsCoverage
9+
410
attr_accessor :project, :gcno_file_pathname
511

612
def initialize(project, gcno_file_pathname)
@@ -11,7 +17,6 @@ def initialize(project, gcno_file_pathname)
1117
def source_file_pathname
1218
@source_file_pathname ||= begin
1319
base_filename = gcno_file_pathname.basename.sub_ext("")
14-
# TODO: Handle Swift
1520
path = nil
1621
if project.source_directory
1722
path = Dir["#{project.source_directory}/**/#{base_filename}.{#{supported_file_extensions.join(",")}}"].first
@@ -36,10 +41,6 @@ def source_data
3641
source_file.read
3742
end
3843

39-
def source_file_pathname_relative_to_repo_root
40-
source_file_pathname.realpath.relative_path_from(Pathname("./").realpath)
41-
end
42-
4344
def gcov_data
4445
@gcov_data ||= begin
4546
gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
@@ -58,6 +59,24 @@ def gcov_data
5859
end
5960
end
6061

62+
def all_lines
63+
unless cleaned_gcov_data.empty?
64+
first_line_start = cleaned_gcov_data =~ /^\s+(-|#+|[0-9+]):\s+1:/
65+
cleaned_gcov_data[first_line_start..-1].split("\n").map
66+
else
67+
[]
68+
end
69+
end
70+
71+
def cleaned_gcov_data
72+
data = gcov_data.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/^function(.*) called [0-9]+ returned [0-9]+% blocks executed(.*)$\r?\n/, '')
73+
data.gsub(/^branch(.*)$\r?\n/, '')
74+
end
75+
76+
def raw_data
77+
self.gcov_data
78+
end
79+
6180
def line_coverage_data
6281
unless cleaned_gcov_data.empty?
6382
first_line_start = cleaned_gcov_data =~ /^\s+(-|#+|[0-9+]):\s+1:/
@@ -70,9 +89,8 @@ def line_coverage_data
7089
end
7190
end
7291

73-
def cleaned_gcov_data
74-
data = gcov_data.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/^function(.*) called [0-9]+ returned [0-9]+% blocks executed(.*)$\r?\n/, '')
75-
data.gsub(/^branch(.*)$\r?\n/, '')
92+
def line_number_in_line(line)
93+
line.split(':')[1].strip.to_i
7694
end
7795

7896
def coverage_for_line(line)
@@ -89,102 +107,31 @@ def coverage_for_line(line)
89107
end
90108
end
91109

92-
def num_lines_tested
93-
line_coverage_data.compact.select { |cd| cd > 0 }.count
94-
end
95-
96-
def num_lines_testable
97-
line_coverage_data.compact.count
98-
end
99-
100-
def rate_lines_tested
101-
if num_lines_testable > 0
102-
(num_lines_tested / num_lines_testable.to_f)
103-
else
104-
0
105-
end
106-
end
107-
108-
def percentage_lines_tested
109-
if num_lines_testable == 0
110-
100
111-
else
112-
rate_lines_tested * 100
113-
end
114-
end
115-
116110
def branch_coverage_data
117111
@branch_coverage_data ||= begin
118112
branch_coverage_data = Hash.new
119113

120-
gcov_data.scan(/(^(\s+(-|#+|[0-9]+):\s+[1-9]+:(.*)$\r?\n)(^branch\s+[0-9]+\s+[a-zA-Z0-9]+\s+[a-zA-Z0-9]+$\r?\n)+)+/) do |data|
121-
lines = data[0].split("\n")
122-
line_number = lines[0].split(':')[1].strip.to_i
123-
branch_coverage_data[line_number] = lines[1..-1].map do |line|
124-
if line.split(' ')[2].strip == "never"
125-
0
126-
else
127-
line.split(' ')[3].strip.to_i
128-
end
114+
gcov_data.scan(/(^(\s+(-|#+|[0-9]+):\s+[1-9]+:(.*)$\r?\n)(^branch\s+[0-9]+\s+[a-zA-Z0-9]+\s+[a-zA-Z0-9]+$\r?\n)+)+/) do |data|
115+
lines = data[0].split("\n")
116+
line_number = lines[0].split(':')[1].strip.to_i
117+
branch_coverage_data[line_number] = lines[1..-1].map do |line|
118+
if line.split(' ')[2].strip == "never"
119+
0
120+
else
121+
line.split(' ')[3].strip.to_i
129122
end
130123
end
124+
end
131125
branch_coverage_data
132126
end
133127
end
134128

135-
def branch_coverage_data_for_statement_on_line(line_number)
136-
branch_coverage_data[line_number] || []
137-
end
138-
139-
def num_branches_for_statement_on_line(line_number)
140-
branch_coverage_data_for_statement_on_line(line_number).length
141-
end
142-
143-
def num_branch_hits_for_statement_on_line(line_number)
144-
branch_coverage_data_for_statement_on_line(line_number).count { |hit_count| hit_count > 0 }
145-
end
146-
147-
def rate_branch_coverage_for_statement_on_line(line_number)
148-
branch_data = branch_coverage_data_for_statement_on_line(line_number)
149-
if branch_data.empty?
150-
0.0
151-
else
152-
(num_branch_hits_for_statement_on_line(line_number) / branch_data.length.to_f)
153-
end
154-
end
155-
156-
def percentage_branch_coverage_for_statement_on_line(line_number)
157-
rate_branch_coverage_for_statement_on_line(line_number) * 100
158-
end
159-
160-
def num_branches_testable
161-
branch_coverage_data.keys.reduce(0) do |sum, line_number|
162-
sum += num_branches_for_statement_on_line(line_number)
163-
end
164-
end
165-
166-
def num_branches_tested
167-
branch_coverage_data.keys.reduce(0) do |sum, line_number|
168-
sum += num_branch_hits_for_statement_on_line(line_number)
169-
end
170-
end
171-
172-
def rate_branches_tested
173-
if (num_branches_testable > 0)
174-
(num_branches_tested / num_branches_testable.to_f)
175-
else
176-
0.0
177-
end
178-
end
179-
180129
def source_file_basename
181130
File.basename(source_file_pathname, '.m')
182131
end
183132

184-
def ignored?
185-
project.ignore_list.any? do |ignore|
186-
File.fnmatch(ignore, source_file_pathname_relative_to_repo_root)
187-
end
133+
def line_number_separator
134+
":"
188135
end
189136

190137
def supported_file_extensions

0 commit comments

Comments
 (0)