Skip to content

Commit 2c95cf5

Browse files
committed
Added primitive support for COVERAGE_PATH_EQUIVALENCE.
1 parent ebbff70 commit 2c95cf5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/slather/coverage_info.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def rate_branches_tested
7171
end
7272

7373
def source_file_pathname_relative_to_repo_root
74-
source_file_pathname.realpath.relative_path_from(Pathname("./").realpath)
74+
test_path=source_file_pathname
75+
if ENV["COVERAGE_PATH_EQUIVALENCE"]
76+
test_path=Pathname("." + "#{source_file_pathname}".delete_prefix(ENV["COVERAGE_PATH_EQUIVALENCE"].delete_suffix(",.")))
77+
end
78+
test_path.realpath.relative_path_from(Pathname("./").realpath)
7579
end
7680

7781
def ignored?

lib/slather/project.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def unsafe_llvm_cov_export_output(binary_path)
269269
if self.arch
270270
llvm_cov_args << "--arch" << self.arch
271271
end
272+
if ENV["COVERAGE_PATH_EQUIVALENCE"]
273+
llvm_cov_args << "-path-equivalence=#{ENV["COVERAGE_PATH_EQUIVALENCE"]}"
274+
end
272275
`xcrun llvm-cov #{llvm_cov_args.shelljoin}`
273276
end
274277
private :unsafe_llvm_cov_export_output
@@ -293,6 +296,9 @@ def unsafe_profdata_llvm_cov_output(binary_path, source_files)
293296
if self.arch
294297
llvm_cov_args << "--arch" << self.arch
295298
end
299+
if ENV["COVERAGE_PATH_EQUIVALENCE"]
300+
llvm_cov_args << "-path-equivalence=#{ENV["COVERAGE_PATH_EQUIVALENCE"]}"
301+
end
296302

297303
# POSIX systems have an ARG_MAX for the maximum total length of the command line, so the command may fail with an error message of "Argument list too long".
298304
# Using the xargs command we can break the list of source_files into sublists small enough to be acceptable.

0 commit comments

Comments
 (0)