xcjobs 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63dcf92b35885eb60c2b55a65af78496bd9cdbcb
4
- data.tar.gz: f90022d38f0019958a485fe58b7bdbfcd916ecdf
3
+ metadata.gz: cfed7f6abb2a79dd85f2b689a1a6c9bbaa82f605
4
+ data.tar.gz: 44e38c2a7d513135212861088c14b77d4b37bfbc
5
5
  SHA512:
6
- metadata.gz: 37295d7f0acc2425d22482becf983d6206c806f22d4638ad4e2ca9623eed3ceecc2b4e2c9b45842f542e82f9091ca32a626f2a0166d4abfa6b667a365ff3a2b3
7
- data.tar.gz: 42acf9fe3cc9a4a9b7bb9754e0ab79237d86d1b4400ce9cb91e1a5554923a54c0195393afcc4b2d918aa09e14864735fe34357e33a5df845c256805e4ee9dacc
6
+ metadata.gz: c4c9a23d70fab95c73ccce1e6bcb03251b64330fb7c7b9de039960b7c9c7b9cb101285c47fa31bbf8857fd938d81c14671bfe33e918b6847869e1ec6814fa22f
7
+ data.tar.gz: 00861da56737697a84b98d09b3e602afd3a715dce913fdfa4befe9c8176f1b3a84201ebeb105fea34bc147813b07a0b9036600dea7aa33ab9437588c2bf1ec8e
@@ -1,3 +1,3 @@
1
1
  module XCJobs
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -146,6 +146,100 @@ module XCJobs
146
146
  end
147
147
 
148
148
  private
149
+
150
+ def show_coverage(profdata_path, target_path)
151
+ cmd = ['xcrun', 'llvm-cov', 'report']
152
+ opts = ['-instr-profile', profdata_path, target_path, '-use-color=0']
153
+ puts (cmd + opts).join(" ")
154
+ out, status = Open3.capture2(*(cmd + opts))
155
+ out.lines.each do |line|
156
+ puts line
157
+ end
158
+ end
159
+
160
+ def generate_gcov_file(profdata_path, target_path)
161
+ puts 'Generage gcov file...'
162
+ gcov_file = {}
163
+ source_path = ''
164
+
165
+ cmd = ['xcrun', 'llvm-cov', 'show']
166
+ opts = ['-instr-profile', profdata_path, target_path, '-use-color=0']
167
+
168
+ out, status = Open3.capture2(*(cmd + opts))
169
+ out.lines.each do |line|
170
+ match = /^(['"]?(?:\/[^\/]+)*['"]?):$/.match(line)
171
+ if match.to_a.count > 0
172
+ source_path = match.to_a[1]
173
+ gcov_file[source_path] = []
174
+ next
175
+ end
176
+
177
+ match = /^[ ]*([0-9]+|[ ]+)\|[ ]*([0-9]+)\|(.*)$/.match(line)
178
+ next unless match.to_a.count == 4
179
+ count, number, text = match.to_a[1..3]
180
+
181
+ execution_count = case count.strip
182
+ when ''
183
+ '-'.rjust(5)
184
+ when '0'
185
+ '#####'
186
+ else count
187
+ end
188
+ gcov_file[source_path] << "#{execution_count.rjust(5)}:#{number.rjust(5)}:#{text}"
189
+ end
190
+
191
+ gcov_file.each do |key, value|
192
+ gcon_path = File.join(File.dirname(profdata_path), "#{File.basename(target_path)}.gcov")
193
+ file = File::open(gcon_path, "w")
194
+ file.puts("#{'-'.rjust(5)}:#{'0'.rjust(5)}:Source:#{key}")
195
+ file.puts(value)
196
+ file.flush
197
+ end
198
+ end
199
+
200
+ def coverage_report(options)
201
+ settings = build_settings(options)
202
+
203
+ targetSettings = settings.select { |key, _| settings[key]['PRODUCT_TYPE'] != 'com.apple.product-type.bundle.unit-test' }
204
+ targetSettings.each do |target, settings|
205
+ if settings['PRODUCT_TYPE'] == 'com.apple.product-type.framework'
206
+ if sdk.start_with? 'iphone'
207
+ target_dir = settings['OBJECT_FILE_DIR_normal'].gsub('Build/Intermediates', "Build/Intermediates/CodeCoverage/#{target}/Intermediates")
208
+ executable_name = settings['EXECUTABLE_NAME']
209
+ target_path = File.join(File.join(target_dir, settings['CURRENT_ARCH']), executable_name)
210
+ else
211
+ target_dir = settings['CODESIGNING_FOLDER_PATH'].gsub('Build/Products', "Build/Intermediates/CodeCoverage/#{target}/Products")
212
+ executable_name = settings['EXECUTABLE_NAME']
213
+ target_path = File.join(target_dir, executable_name)
214
+ end
215
+ else
216
+
217
+ end
218
+
219
+ code_coverage_dir = settings['BUILD_DIR'].gsub('Build/Products', "Build/Intermediates/CodeCoverage/#{target}/")
220
+ profdata_path = File.join(code_coverage_dir, 'Coverage.profdata')
221
+
222
+ show_coverage(profdata_path, target_path)
223
+ generate_gcov_file(profdata_path, target_path)
224
+ end
225
+ end
226
+
227
+ def build_settings(options)
228
+ out, status = Open3.capture2(*(['xcodebuild', 'test'] + options + ['-showBuildSettings']))
229
+
230
+ settings, target = {}, nil
231
+ out.lines.each do |line|
232
+ case line
233
+ when /Build settings for action test and target (.+):/
234
+ target = $1
235
+ settings[target] = {}
236
+ else
237
+ key, value = line.split(/\=/).collect(&:strip)
238
+ settings[target][key] = value if target
239
+ end
240
+ end
241
+ return settings
242
+ end
149
243
 
150
244
  def define
151
245
  raise 'test action requires specifying a scheme' unless scheme
@@ -157,77 +251,13 @@ module XCJobs
157
251
  add_build_setting('CODE_SIGN_IDENTITY', '""')
158
252
  add_build_setting('CODE_SIGNING_REQUIRED', 'NO')
159
253
  end
160
- if sdk == 'macosx'
161
- add_build_setting('CONFIGURATION_BUILD_DIR', File.expand_path(build_dir)) if build_dir
162
- end
163
- add_build_setting('CONFIGURATION_TEMP_DIR', File.join(build_dir, 'temp')) if build_dir
254
+
164
255
  add_build_setting('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO')
165
256
 
166
257
  run(['xcodebuild', 'test'] + options)
167
258
 
168
259
  if coverage_enabled
169
- out, status = Open3.capture2(*(['xcodebuild', 'test'] + options + ['-showBuildSettings']))
170
-
171
- configuration_build_dir = out.lines.grep(/\bCONFIGURATION_BUILD_DIR\b/).first.split('=').last.strip
172
- project_temp_root = out.lines.grep(/\bPROJECT_TEMP_ROOT\b/).first.split('=').last.strip
173
- object_file_dir_normal = out.lines.grep(/\bOBJECT_FILE_DIR_normal\b/).first.split('=').last.strip
174
- current_arch = out.lines.grep(/\bCURRENT_ARCH\b/).first.split('=').last.strip
175
- executable_name = out.lines.grep(/\bEXECUTABLE_NAME\b/).first.split('=').last.strip
176
- executable_path = out.lines.grep(/\bEXECUTABLE_PATH\b/).first.split('=').last.strip
177
-
178
- if sdk.start_with? 'iphone'
179
- target_path = File.join(File.join(object_file_dir_normal, current_arch), executable_name)
180
- elsif sdk == 'macosx'
181
- target_path = File.join(configuration_build_dir, executable_path)
182
- end
183
-
184
- code_coverage_dir = File.join(project_temp_root, 'CodeCoverage')
185
- profdata_dir = File.join(code_coverage_dir, scheme)
186
- profdata_path = File.join(profdata_dir, 'Coverage.profdata')
187
-
188
- gcov_file = {}
189
- source_path = ''
190
-
191
- cmd = ['xcrun', 'llvm-cov', 'report']
192
- opts = ['-instr-profile', profdata_path, target_path, '-use-color=0']
193
- puts (cmd + opts).join(" ")
194
- out, status = Open3.capture2(*(cmd + opts))
195
- out.lines.each do |line|
196
- puts line
197
- end
198
-
199
- cmd = ['xcrun', 'llvm-cov', 'show']
200
- puts (cmd + opts).join(" ")
201
- out, status = Open3.capture2(*(cmd + opts))
202
- out.lines.each do |line|
203
- match = /^(['"]?(?:\/[^\/]+)*['"]?):$/.match(line)
204
- if match.to_a.count > 0
205
- source_path = match.to_a[1]
206
- gcov_file[source_path] = []
207
- next
208
- end
209
-
210
- match = /^[ ]*([0-9]+|[ ]+)\|[ ]*([0-9]+)\|(.*)$/.match(line)
211
- next unless match.to_a.count == 4
212
- count, number, text = match.to_a[1..3]
213
-
214
- execution_count = case count.strip
215
- when ''
216
- '-'.rjust(5)
217
- when '0'
218
- '#####'
219
- else count
220
- end
221
- gcov_file[source_path] << "#{execution_count.rjust(5)}:#{number.rjust(5)}:#{text}"
222
- end
223
-
224
- gcov_file.each do |key, value|
225
- gcon_path = File.join(File.dirname(target_path), "#{File.basename(target_path)}.gcov")
226
- file = File::open(gcon_path, "w")
227
- file.puts("#{'-'.rjust(5)}:#{'0'.rjust(5)}:Source:#{key}")
228
- file.puts(value)
229
- file.flush
230
- end
260
+ coverage_report(options)
231
261
  end
232
262
  end
233
263
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcjobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kishikawa katsumi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-11 00:00:00.000000000 Z
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler