Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/slather/coverage_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def rate_branches_tested
end

def source_file_pathname_relative_to_repo_root
source_file_pathname.realpath.relative_path_from(Pathname("./").realpath)
test_path=source_file_pathname
if ENV["COVERAGE_PATH_EQUIVALENCE"]
test_path=Pathname("." + "#{source_file_pathname}".delete_prefix(ENV["COVERAGE_PATH_EQUIVALENCE"].delete_suffix(",.")))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only supports COVERAGE_PATH_EQUIVALENCE=XXX,., i.e. relocation from a given source root (XXX) to the current directory.

end
test_path.realpath.relative_path_from(Pathname("./").realpath)
end

def ignored?
Expand Down
6 changes: 6 additions & 0 deletions lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def unsafe_llvm_cov_export_output(binary_path)
if self.arch
llvm_cov_args << "--arch" << self.arch
end
if ENV["COVERAGE_PATH_EQUIVALENCE"]
llvm_cov_args << "-path-equivalence=#{ENV["COVERAGE_PATH_EQUIVALENCE"]}"
end
`xcrun llvm-cov #{llvm_cov_args.shelljoin}`
end
private :unsafe_llvm_cov_export_output
Expand All @@ -293,6 +296,9 @@ def unsafe_profdata_llvm_cov_output(binary_path, source_files)
if self.arch
llvm_cov_args << "--arch" << self.arch
end
if ENV["COVERAGE_PATH_EQUIVALENCE"]
llvm_cov_args << "-path-equivalence=#{ENV["COVERAGE_PATH_EQUIVALENCE"]}"
end

# 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".
# Using the xargs command we can break the list of source_files into sublists small enough to be acceptable.
Expand Down