lib/slather/project.rb in slather-2.8.3 vs lib/slather/project.rb in slather-2.8.4
- old
+ new
@@ -130,25 +130,30 @@
end
private :profdata_coverage_files
def pathnames_per_binary(binary_path)
coverage_json_string = llvm_cov_export_output(binary_path)
- coverage_json = JSON.parse(coverage_json_string)
- coverage_json["data"].reduce([]) do |result, chunk|
- result.concat(chunk["files"].map do |file|
- filename = file["filename"]
- path = Pathname(filename)
- # Don't crash if the file doesn't exist on disk.
- # This may happen for autogenerated files that have been deleted.
- filename = path.exist? ? path.realpath : filename
- {"filename" => filename, "segments" => file["segments"]}
- end)
+ if coverage_json_string.strip != ""
+ # JSON.parse will crash on an empty string, so just skip everything if the string is empty.
+ coverage_json = JSON.parse(coverage_json_string)
+ coverage_json["data"].reduce([]) do |result, chunk|
+ result.concat(chunk["files"].map do |file|
+ filename = file["filename"]
+ path = Pathname(filename)
+ # Don't crash if the file doesn't exist on disk.
+ # This may happen for autogenerated files that have been deleted.
+ filename = path.exist? ? path.realpath : filename
+ {"filename" => filename, "segments" => file["segments"]}
+ end)
+ end
end
end
private :pathnames_per_binary
def create_coverage_files_for_binary(binary_path, pathnames_per_binary)
+ return [] unless pathnames_per_binary != nil
+
coverage_files = []
begin
coverage_files.concat(create_coverage_files(binary_path, pathnames_per_binary))
rescue Errno::E2BIG => e
@@ -480,10 +485,19 @@
end
def find_binary_file_in_bundle(bundle_file)
if File.directory? bundle_file
bundle_file_noext = File.basename(bundle_file, File.extname(bundle_file))
- Dir["#{bundle_file}/**/#{bundle_file_noext}"].first
+
+ # Search for .debug.dylib binaries
+ # See https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Debug-Dylib-Support for details
+ debug_dylib_matches = Dir["#{bundle_file}/**/#{bundle_file_noext}.debug.dylib"]
+
+ if debug_dylib_matches.length() > 0
+ debug_dylib_matches.first
+ else
+ Dir["#{bundle_file}/**/#{bundle_file_noext}"].first
+ end
else
bundle_file
end
end