Skip to content

Commit f361648

Browse files
committed
[profdata] Fix binary file detection when testing static libraries
1 parent ef9f6d0 commit f361648

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/slather/project.rb

+12-5
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,28 @@ def binary_file
127127
app_bundle_file_name_noext = Pathname.new(app_bundle_file).basename.to_s.gsub(".app", "")
128128
"#{app_bundle_file}/#{app_bundle_file_name_noext}"
129129
elsif framework_bundle_file != nil
130-
framework_bundle_file_name_noext = Pathname.new(framework_bundle_file).basename.to_s.gsub(".framework", "")
131-
"#{framework_bundle_file}/#{framework_bundle_file_name_noext}"
130+
framework_bundle_file_name_noext = Pathname.new(framework_bundle_file).basename.to_s.gsub(".framework", "")
131+
"#{framework_bundle_file}/#{framework_bundle_file_name_noext}"
132132
else
133133
xctest_bundle_file_name_noext = Pathname.new(xctest_bundle_file).basename.to_s.gsub(".xctest", "")
134-
"#{xctest_bundle_file}/#{xctest_bundle_file_name_noext}"
134+
Dir["#{xctest_bundle_file}/**/#{xctest_bundle_file_name_noext}"].first
135135
end
136136
end
137137
private :binary_file
138138

139139
def profdata_llvm_cov_output
140140
profdata_coverage_dir = self.profdata_coverage_dir
141-
if profdata_coverage_dir == nil || (coverage_profdata = Dir["#{profdata_coverage_dir}/**/Coverage.profdata"].first) == nil
141+
binary_file_arg = binary_file
142+
143+
if profdata_coverage_dir == nil || (profdata_file_arg = Dir["#{profdata_coverage_dir}/**/Coverage.profdata"].first) == nil
142144
raise StandardError, "No Coverage.profdata files found. Please make sure the \"Code Coverage\" checkbox is enabled in your scheme's Test action or the build_directory property is set."
143145
end
144-
llvm_cov_args = %W(show -instr-profile #{coverage_profdata} #{binary_file})
146+
147+
if binary_file_arg == nil
148+
raise StandardError, "No binary file found. Please help slather by adding the \"scheme\" argument"
149+
end
150+
151+
llvm_cov_args = %W(show -instr-profile #{profdata_file_arg} #{binary_file_arg})
145152
`xcrun llvm-cov #{llvm_cov_args.shelljoin}`
146153
end
147154
private :profdata_llvm_cov_output

0 commit comments

Comments
 (0)