@@ -51,7 +51,7 @@ module Slather
51
51
class Project < Xcodeproj ::Project
52
52
53
53
attr_accessor :build_directory , :ignore_list , :ci_service , :coverage_service , :coverage_access_token , :source_directory ,
54
- :output_directory , :xcodeproj , :show_html , :input_format , :scheme , :binary_file
54
+ :output_directory , :xcodeproj , :show_html , :verbose_mode , : input_format, :scheme , :binary_file
55
55
56
56
alias_method :setup_for_coverage , :slather_setup_for_coverage
57
57
@@ -113,6 +113,20 @@ def profdata_coverage_dir
113
113
dir
114
114
end
115
115
116
+ def profdata_file
117
+ profdata_coverage_dir = self . profdata_coverage_dir
118
+ if profdata_coverage_dir == nil
119
+ raise StandardError , "No coverage directory found. Please make sure the \" Code Coverage\" checkbox is enabled in your scheme's Test action or the build_directory property is set."
120
+ end
121
+
122
+ file = Dir [ "#{ profdata_coverage_dir } /**/Coverage.profdata" ] . first
123
+ unless file != nil
124
+ return nil
125
+ end
126
+ return File . expand_path ( file )
127
+ end
128
+ private :profdata_file
129
+
116
130
def find_binary_file_for_app ( app_bundle_file )
117
131
app_bundle_file_name_noext = Pathname . new ( app_bundle_file ) . basename . to_s . gsub ( ".app" , "" )
118
132
Dir [ "#{ app_bundle_file } /**/#{ app_bundle_file_name_noext } " ] . first
@@ -129,20 +143,15 @@ def find_binary_file_for_static_lib(xctest_bundle_file)
129
143
end
130
144
131
145
def unsafe_profdata_llvm_cov_output
132
- profdata_coverage_dir = self . profdata_coverage_dir
133
-
134
- if profdata_coverage_dir == nil || ( profdata_file_arg = Dir [ "#{ profdata_coverage_dir } /**/Coverage.profdata" ] . first ) == nil
146
+ profdata_file_arg = profdata_file
147
+ if profdata_file_arg == nil
135
148
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."
136
149
end
137
150
138
151
if self . binary_file == nil
139
152
raise StandardError , "No binary file found."
140
153
end
141
154
142
- puts "\n Processing coverage file: #{ profdata_file_arg } "
143
- puts "Against binary file: #{ self . binary_file } \n \n "
144
-
145
-
146
155
llvm_cov_args = %W( show -instr-profile #{ profdata_file_arg } #{ self . binary_file } )
147
156
`xcrun llvm-cov #{ llvm_cov_args . shelljoin } `
148
157
end
@@ -177,6 +186,11 @@ def configure
177
186
configure_input_format
178
187
configure_scheme
179
188
configure_binary_file
189
+
190
+ if self . verbose_mode
191
+ puts "\n Processing coverage file: #{ profdata_file } "
192
+ puts "Against binary file: #{ self . binary_file } \n \n "
193
+ end
180
194
end
181
195
182
196
def configure_build_directory
@@ -253,7 +267,7 @@ def coverage_service=(service)
253
267
254
268
def configure_binary_file
255
269
if self . input_format == "profdata"
256
- self . binary_file ||= self . class . yml [ "binary_file" ] || find_binary_file
270
+ self . binary_file ||= self . class . yml [ "binary_file" ] || File . expand_path ( find_binary_file )
257
271
end
258
272
end
259
273
0 commit comments