calabash-cucumber 0.9.19 → 0.9.20

Sign up to get free protection for your applications and to get access to all the features.
data/bin/calabash-ios CHANGED
@@ -27,6 +27,9 @@ elsif cmd == 'gen'
27
27
  elsif cmd == 'setup'
28
28
  calabash_setup(ARGV)
29
29
  exit 0
30
+ elsif cmd == 'check'
31
+ validate_setup(ARGV)
32
+ exit 0
30
33
  elsif cmd == 'sim'
31
34
  if ARGV.length == 0
32
35
  print_usage
@@ -15,6 +15,8 @@ def print_usage
15
15
  generate a features folder structure.
16
16
  setup (EXPERIMENTAL)
17
17
  setup your XCode project for calabash-ios)
18
+ check (EXPERIMENTAL)
19
+ check whether an app or ipa is linked with calabash.framework
18
20
  sim locale [lang] [regional]?
19
21
  change locale and regional settings in all iOS Simulators
20
22
  sim reset
@@ -1,3 +1,5 @@
1
+ require "calabash-cucumber/version"
2
+
1
3
  def dup_scheme(project_name, pbx_dir)
2
4
 
3
5
  userdata_dirs = Dir.foreach("#{pbx_dir}/xcuserdata").find_all { |x|
@@ -32,9 +34,19 @@ def dup_scheme(project_name, pbx_dir)
32
34
  puts "Duplicating scheme #{project_name}.xcscheme as #{project_name}-cal.xcscheme"
33
35
 
34
36
  doc = REXML::Document.new(File.new("#{pbx_dir}/xcuserdata/#{userdata_dir}/xcschemes/#{scheme}"))
37
+
35
38
  doc.elements.each("Scheme/LaunchAction") do |la|
36
39
  la.attributes["buildConfiguration"] = "Calabash"
37
40
  end
41
+ doc.elements.each("Scheme/ArchiveAction") do |la|
42
+ la.attributes["buildConfiguration"] = "Calabash"
43
+ end
44
+ doc.elements.each("Scheme/AnalyzeAction") do |la|
45
+ la.attributes["buildConfiguration"] = "Calabash"
46
+ end
47
+ doc.elements.each("Scheme/ProfileAction") do |la|
48
+ la.attributes["buildConfiguration"] = "Calabash"
49
+ end
38
50
  doc.write(File.open("#{pbx_dir}/xcuserdata/#{userdata_dir}/xcschemes/#{project_name}-cal.xcscheme", "w"))
39
51
  end
40
52
  end
@@ -57,7 +69,7 @@ def calabash_setup(args)
57
69
  puts "Please validate by running the #{project_name}-cal scheme"
58
70
  puts "from Xcode."
59
71
  puts "When starting the iOS Simulator using the"
60
- puts "new scheme: #{project_name}-cal, you should see:\n"
72
+ puts "new scheme: #{project_name}-cal, you should see:\n\n"
61
73
  puts ' "Started LPHTTP server on port 37265"'
62
74
  puts "\nin the application log in Xcode."
63
75
  puts "\n\n"
@@ -142,16 +154,14 @@ def setup_project(project_name, project_path, path)
142
154
  ##Download calabash.framework
143
155
  if not Dir.exists?(File.join(project_path, file))
144
156
  msg("Info") do
145
- zip_file = 'calabash.framework-0.9.15.zip'
146
- puts "Did not find calabash.framework. I'll download the latest version...'"
147
- puts "https://raw.github.com/calabash/calabash-ios/master/frameworks/#{zip_file}"
157
+ zip_file = "calabash.framework-#{Calabash::Cucumber::VERSION}.zip"
158
+ puts "Did not find calabash.framework. I'll download it...'"
159
+ puts "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
148
160
  require 'uri'
149
- require 'net/https'
150
161
 
151
- uri = URI.parse "https://raw.github.com/calabash/calabash-ios/master/frameworks/#{zip_file}"
162
+ uri = URI.parse "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
152
163
 
153
- Net::HTTP.start(uri.host, uri.port,
154
- :use_ssl => uri.scheme == 'https') do |http|
164
+ Net::HTTP.start(uri.host, uri.port) do |http|
155
165
  request = Net::HTTP::Get.new uri.request_uri
156
166
 
157
167
  http.request request do |response|
@@ -211,7 +221,7 @@ def setup_project(project_name, project_path, path)
211
221
  pbx.sections['PBXFrameworksBuildPhase'][0].files << build_phase_entry
212
222
 
213
223
 
214
- #TODO first check if already linking with CFNetwork
224
+
215
225
  cfnet = pbx.find_item :name => "CFNetwork.framework", :type => PBXProject::PBXTypes::PBXFileReference
216
226
 
217
227
  unless cfnet
@@ -285,6 +295,26 @@ def setup_project(project_name, project_path, path)
285
295
 
286
296
 
287
297
  ld_flags = cal_build_settings['OTHER_LDFLAGS'] || []
298
+
299
+ if not ld_flags.is_a?Array
300
+ ld_flags = [ld_flags]
301
+ end
302
+ danger = ld_flags.find_all {|f| /-ObjC/i.match(f.value) || /-all_load/i.match(f.value)}
303
+
304
+ if not danger.empty?
305
+ msg("Error") do
306
+ puts "Detected Other Linker Flag: #{(danger.map {|d| d.value}).join(", ")}"
307
+ puts "calabash-ios setup does not yet support this scenario"
308
+ puts "(why? karl@lesspainful.com)"
309
+ puts "You must manually setup ios see:"
310
+ puts "https://github.com/calabash/calabash-ios"
311
+ end
312
+ exit 1
313
+ end
314
+
315
+
316
+
317
+
288
318
  ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"-force_load"')
289
319
  ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"$(SRCROOT)/calabash.framework/calabash"')
290
320
  ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"-lstdc++"')
@@ -314,8 +344,7 @@ def setup_project(project_name, project_path, path)
314
344
  sp = [sp]
315
345
  end
316
346
  inherit = sp.find { |x| x.value == '"$(inherited)"' }
317
- srcroot = sp.find { |x| p x.value;x.value == "\"$(SRCROOT)\""}
318
- p srcroot
347
+ srcroot = sp.find { |x| x.value == "\"$(SRCROOT)\""}
319
348
  sp << PBXProject::PBXTypes::BasicValue.new(:value => '"$(inherited)"') unless inherit
320
349
  sp << PBXProject::PBXTypes::BasicValue.new(:value => "\"$(SRCROOT)\"") unless srcroot
321
350
  bc.buildSettings["FRAMEWORK_SEARCH_PATHS"] = sp
@@ -326,3 +355,120 @@ def setup_project(project_name, project_path, path)
326
355
  end
327
356
 
328
357
 
358
+
359
+ require 'calabash-cucumber/launch/simulator_helper'
360
+ def validate_setup(args)
361
+ if args.length > 0
362
+ if args[0].end_with?(".ipa")
363
+ validate_ipa(args[0])
364
+ elsif args[0].end_with?(".app")
365
+ validate_app(args[0])
366
+ end
367
+ else
368
+ dd_dir = Calabash::Cucumber::SimulatorHelper.derived_data_dir_for_project
369
+ if not dd_dir
370
+ puts "Unable to find iOS project."
371
+ puts "You should run this command from an iOS project directory."
372
+ exit 1
373
+ end
374
+ app_bundles = Dir.glob(File.join(dd_dir, "Build", "Products", "*", "*.app"))
375
+ sim_dirs = Dir.glob(File.join(dd_dir, "Build", "Products", "Debug-iphonesimulator", "*.app"))
376
+ sim_dirs = sim_dirs.concat(Dir.glob(File.join(dd_dir, "Build", "Products", "Calabash-iphonesimulator", "*.app")))
377
+ if sim_dirs.empty?
378
+ msg = ["Have you built your app for simulator?"]
379
+ msg << "You should build the -cal scheme and your normal scheme"
380
+ msg << "(with configuration Debug)."
381
+ msg << "Searched dir: #{dd_dir}/Build/Products"
382
+ msg("Error") do
383
+ puts msg.join("\n")
384
+ end
385
+ exit 1
386
+ elsif sim_dirs.count != 2
387
+ msg = ["Have you built your app for simulator?"]
388
+ msg << "You should build the -cal scheme and your normal scheme"
389
+ msg << "(with configuration Debug)."
390
+ msg << "Searched dir: #{dd_dir}/Build/Products"
391
+ msg("Error") do
392
+ puts msg.join("\n")
393
+ end
394
+ exit 1
395
+ end
396
+ out_debug = `otool #{sim_dirs[0]}/* -o 2> /dev/null | grep CalabashServer`
397
+ out_cal = `otool #{sim_dirs[1]}/* -o 2> /dev/null | grep CalabashServer 2> /dev/null`
398
+ ok = (not /CalabashServer/.match(out_debug)) and /CalabashServer/.match(out_cal)
399
+ if ok
400
+ msg("OK") do
401
+ puts "Your configuration seems ok."
402
+ puts "app in directory:"
403
+ puts sim_dirs[0]
404
+ puts "does not have calabash.framework linked in."
405
+ puts "directory:"
406
+ puts sim_dirs[1]
407
+ puts "does."
408
+ end
409
+ else
410
+ msg("Fail") do
411
+ puts "Your configuration looks bad."
412
+ if (not /CalabashServer/.match(out_debug))
413
+ puts "WARNING: You Debug build seems to be linking with Calabash."
414
+ puts "You should restore your xcodeproject file from backup."
415
+ else
416
+ puts "app in directory"
417
+ puts sim_dirs[1]
418
+ puts "does not have calabash.framework linked in."
419
+ end
420
+ end
421
+ end
422
+ end
423
+
424
+
425
+ end
426
+
427
+ def validate_ipa(ipa)
428
+ require 'tmpdir'
429
+ fail = false
430
+ Dir.mktmpdir do |dir|
431
+ if not system("unzip -C -K -o -q -d #{dir} #{ipa}")
432
+ msg("Error") do
433
+ puts "Unable to unzip ipa: #{ipa}"
434
+ end
435
+ Dir
436
+ fail = true
437
+ end
438
+
439
+ app_dir = Dir.foreach("#{dir}/Payload").find {|d| /\.app$/.match(d)}
440
+ app = app_dir.split(".")[0]
441
+ res = `otool #{dir}/Payload/#{app_dir}/#{app} -o 2> /dev/null | grep CalabashServer`
442
+ msg("Info") do
443
+ if /CalabashServer/.match(res)
444
+ puts "Ipa: #{ipa} *contains* calabash.framework"
445
+ else
446
+ puts "Ipa: #{ipa} *does not contain* calabash.framework"
447
+ end
448
+ end
449
+
450
+ end
451
+ if fail
452
+ exit(1)
453
+ end
454
+
455
+ end
456
+
457
+ def validate_app(app)
458
+ if not Dir.exists?app
459
+ msg("Error") do
460
+ puts "Path: #{app} is not a directory."
461
+ end
462
+ exit 1
463
+ end
464
+ out = `otool #{app}/* -o 2> /dev/null | grep CalabashServer`
465
+
466
+ msg("Info") do
467
+ if /CalabashServer/.match(out)
468
+ puts "App: #{app} *contains* calabash.framework"
469
+ else
470
+ puts "App: #{app} *does not contain* calabash.framework"
471
+ end
472
+ end
473
+
474
+ end
@@ -33,6 +33,14 @@ Usage: calabash-ios <command-name> [parameters]
33
33
  If something goes wrong. Close Xcode and copy project.pbxproj.bak
34
34
  to project.pbxproj inside your .xcodeproj folder.
35
35
 
36
+ check (EXPERIMENTAL) [.app or .ipa]?
37
+ check whether an app or ipa is linked with calabash.framework
38
+ if called without parameter [.app or .ipa] then pwd should be
39
+ a directory containing an xcodeproj. In this case we'll check
40
+ the default Xcode simulator build path for a Debug and Calabash
41
+ build configurations. We check that Debug doesn't link with
42
+ calabash.framework but Calabash does.
43
+
36
44
  sim locale [lang] [regional]? Changes the regional settings
37
45
  for the iOS Simulators. You must ensure the correct format
38
46
  for the optional regional parameter, for example,
@@ -10,7 +10,7 @@
10
10
  # #
11
11
  # Don't rely on this file being #
12
12
  # present when running at #
13
- # lesspainful.com. #
13
+ # www.lesspainful.com. #
14
14
  # #
15
15
  # Only put stuff here to automate #
16
16
  # iOS Simulator. #
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = "0.9.19"
3
+ VERSION = "0.9.20"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.19
4
+ version: 0.9.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
16
- requirement: &70257557882100 !ruby/object:Gem::Requirement
16
+ requirement: &70182882346360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70257557882100
24
+ version_requirements: *70182882346360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &70257557881400 !ruby/object:Gem::Requirement
27
+ requirement: &70182882345940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70257557881400
35
+ version_requirements: *70182882345940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: CFPropertyList
38
- requirement: &70257557880780 !ruby/object:Gem::Requirement
38
+ requirement: &70182882345520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70257557880780
46
+ version_requirements: *70182882345520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sim_launcher
49
- requirement: &70257557880220 !ruby/object:Gem::Requirement
49
+ requirement: &70182882345080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70257557880220
57
+ version_requirements: *70182882345080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: slowhandcuke
60
- requirement: &70257557878640 !ruby/object:Gem::Requirement
60
+ requirement: &70182882344640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70257557878640
68
+ version_requirements: *70182882344640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-http-persistent
71
- requirement: &70257557878060 !ruby/object:Gem::Requirement
71
+ requirement: &70182882344220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70257557878060
79
+ version_requirements: *70182882344220
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: pbxproject
82
- requirement: &70257557877640 !ruby/object:Gem::Requirement
82
+ requirement: &70182882343800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70257557877640
90
+ version_requirements: *70182882343800
91
91
  description: calabash-cucumber drives tests for native iOS apps. You must link your
92
92
  app with calabash-ios-server framework to execute tests.
93
93
  email: