xcjobs 0.8.1 → 0.9.0

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: 7464a0a5d68f99a77502c4d293772012113c5743
4
- data.tar.gz: 747b110147e42003891b9e14e95e50422eebf107
3
+ metadata.gz: 694d4c8a53b9a099ff689a38bb163e0d225f7327
4
+ data.tar.gz: d05a32b42325bc2887be5c5b7319608bfc37220e
5
5
  SHA512:
6
- metadata.gz: db0f03448c564174b86acbb948a8605872aaca845ccd5ad1891db0e19e50ebf353de9a83825e479e8941cedaec142c18be574150ae5e75e93b2f8c837fc4536d
7
- data.tar.gz: 9eaaa2ea808afdbd8d81f00fdd945788dab0f4d7e1af86dc61a01308bb7e518c0e207276ab656354639cb04b71e70c5d06642879d0520627309e83d1b15b5293
6
+ metadata.gz: ea48a6001664419ebcecb65db4916711f43b781db685fccbfddda5dc1b60b51deeb6759f2b4ccef3d6d1b0d5dfd06c720c3e66315ff67af1cd7a364fa9e69750
7
+ data.tar.gz: 8f2966ae904065af2080c47771305ca6757e5f71a48c6278016561b12c8bb6be600cc9ed440fa5a6173fd87363ec7f901da9a00f0fd29244d100c4fab069489c
@@ -1,3 +1,3 @@
1
1
  module XCJobs
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -31,7 +31,7 @@ module XCJobs
31
31
 
32
32
  def initialize(name)
33
33
  $stdout.sync = $stderr.sync = true
34
-
34
+
35
35
  @name = name
36
36
  @destinations = []
37
37
  @only_testings = []
@@ -39,6 +39,7 @@ module XCJobs
39
39
  @build_options = {}
40
40
  @build_settings = {}
41
41
  @unsetenv_others = false
42
+ @description = Rake.application.last_description # nil or given from "desc"
42
43
  end
43
44
 
44
45
  def project
@@ -174,7 +175,7 @@ module XCJobs
174
175
 
175
176
  def initialize(name = :test)
176
177
  super
177
- @description = 'test application'
178
+ @description ||= 'test application'
178
179
  @without_building = false
179
180
  yield self if block_given?
180
181
  define
@@ -185,66 +186,30 @@ module XCJobs
185
186
  end
186
187
 
187
188
  private
188
-
189
- def show_coverage(profdata_path, target_path)
189
+
190
+ def show_coverage_report(profdata_path, target_path)
190
191
  cmd = ['xcrun', 'llvm-cov', 'report']
191
192
  opts = ['-instr-profile', profdata_path, target_path, '-use-color=0']
192
- puts (cmd + opts).join(" ")
193
- out, status = Open3.capture2(*(cmd + opts))
194
- out.lines.each do |line|
195
- puts line
196
- end
193
+ sh *(cmd + opts)
197
194
  end
198
-
199
- def generate_gcov_file(profdata_path, target_path)
200
- puts 'Generage gcov file...'
195
+
196
+ def build_coverage_report(profdata_path, target_path)
201
197
  gcov_file = {}
202
198
  source_path = ''
203
-
199
+
204
200
  cmd = ['xcrun', 'llvm-cov', 'show']
205
201
  opts = ['-instr-profile', profdata_path, target_path, '-use-color=0']
206
-
207
- out, status = Open3.capture2(*(cmd + opts))
208
- out.lines.each do |line|
209
- match = /^(['"]?(?:\/[^\/]+)*['"]?):$/.match(line)
210
- if match.to_a.count > 0
211
- source_path = match.to_a[1]
212
- gcov_file[source_path] = []
213
- next
214
- end
215
-
216
- match = /^[ ]*([0-9]+|[ ]+)\|[ ]*([0-9]+)\|(.*)$/.match(line)
217
- next unless match.to_a.count == 4
218
- count, number, text = match.to_a[1..3]
219
-
220
- execution_count = case count.strip
221
- when ''
222
- '-'.rjust(5)
223
- when '0'
224
- '#####'
225
- else count
226
- end
227
- gcov_file[source_path] << "#{execution_count.rjust(5)}:#{number.rjust(5)}:#{text}"
228
- end
229
-
230
- gcov_file.each do |key, value|
231
- gcon_path = File.join(File.dirname(profdata_path), "#{SecureRandom.urlsafe_base64(6)}-#{File.basename(target_path)}.gcov")
232
- file = File::open(gcon_path, "w")
233
- file.puts("#{'-'.rjust(5)}:#{'0'.rjust(5)}:Source:#{key}")
234
- file.puts(value)
235
- file.flush
236
- end
202
+
203
+ sh *(cmd + opts)
237
204
  end
238
-
205
+
239
206
  def coverage_report(options)
240
207
  settings = build_settings(options)
241
-
242
- xcode_version = `xcodebuild -version`.split("\n").first.scan(/\d+/).join('.')
243
-
208
+
244
209
  targetSettings = settings.select { |key, _| settings[key]['PRODUCT_TYPE'] != 'com.apple.product-type.bundle.unit-test' }
245
210
  targetSettings.each do |target, settings|
246
211
  objroot = settings['OBJROOT']
247
-
212
+
248
213
  product_type = settings['PRODUCT_TYPE']
249
214
  if product_type == 'com.apple.product-type.framework' || product_type == 'com.apple.product-type.application'
250
215
  if sdk.start_with?('iphone') && settings['ONLY_ACTIVE_ARCH'] == 'NO'
@@ -256,17 +221,17 @@ module XCJobs
256
221
  elsif
257
222
  raise %[Product type (PRODUCT_TYPE) '#{product_type}' is unsupported.]
258
223
  end
259
-
224
+
260
225
  profdata_path = Dir.glob(File.join(objroot, '/**/Coverage.profdata')).first
261
-
262
- show_coverage(profdata_path, target_path)
263
- generate_gcov_file(profdata_path, target_path)
226
+
227
+ show_coverage_report(profdata_path, target_path)
228
+ build_coverage_report(profdata_path, target_path)
264
229
  end
265
230
  end
266
-
231
+
267
232
  def build_settings(options)
268
233
  out, status = Open3.capture2(*(['xcodebuild', 'test'] + options + ['-showBuildSettings']))
269
-
234
+
270
235
  settings, target = {}, nil
271
236
  out.lines.each do |line|
272
237
  case line
@@ -286,25 +251,26 @@ module XCJobs
286
251
  raise 'cannot specify both a scheme and targets' if scheme && target
287
252
 
288
253
  desc @description
289
- task @name do
254
+ task @name do
290
255
  add_build_setting('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO')
291
256
 
292
- run(['xcodebuild', without_building ? 'test-without-building' : 'test'] + options)
257
+ run(['xcodebuild', command] + options)
293
258
 
294
259
  if coverage_enabled
295
260
  coverage_report(options)
296
261
  end
297
262
  end
298
263
  end
264
+
265
+ def command
266
+ 'test'
267
+ end
299
268
  end
300
269
 
301
270
  class Build < Xcodebuild
302
- attr_accessor :for_testing
303
-
304
271
  def initialize(name = :build)
305
272
  super
306
- @description = 'build application'
307
- @for_testing = false
273
+ @description ||= 'build application'
308
274
  yield self if block_given?
309
275
  define
310
276
  end
@@ -324,9 +290,29 @@ module XCJobs
324
290
  add_build_setting('CODE_SIGN_IDENTITY', signing_identity) if signing_identity
325
291
  add_build_setting('PROVISIONING_PROFILE', provisioning_profile_uuid) if provisioning_profile_uuid
326
292
 
327
- run(['xcodebuild', for_testing ? 'build-for-testing' : 'build'] + options)
293
+ run(['xcodebuild', command] + options)
328
294
  end
329
295
  end
296
+
297
+ def command
298
+ 'build'
299
+ end
300
+ end
301
+
302
+ class TestWithoutBuilding < Build
303
+ private
304
+
305
+ def command
306
+ 'test-without-building'
307
+ end
308
+ end
309
+
310
+ class BuildForTesting < Build
311
+ private
312
+
313
+ def command
314
+ 'build-for-testing'
315
+ end
330
316
  end
331
317
 
332
318
  class Archive < Xcodebuild
@@ -334,7 +320,7 @@ module XCJobs
334
320
 
335
321
  def initialize(name = :archive)
336
322
  super
337
- @description = 'make xcarchive'
323
+ @description ||= 'make xcarchive'
338
324
  yield self if block_given?
339
325
  define
340
326
  end
@@ -393,7 +379,7 @@ module XCJobs
393
379
  def initialize(name = :export)
394
380
  super
395
381
  self.unsetenv_others = true
396
- @description = 'export from an archive'
382
+ @description ||= 'export from an archive'
397
383
  @export_format = 'IPA'
398
384
  yield self if block_given?
399
385
  define
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.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kishikawa katsumi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-28 00:00:00.000000000 Z
11
+ date: 2017-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.6.11
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Support the automation of release process of iOS/OSX apps with CI