Permalink
Browse files

Reliable starting/quitting without Xcode. Hurrah.

  • Loading branch information...
1 parent 030e509 commit c8f0c523a6b8110b1226f86013f58d27281098ff Rob Holland committed Jun 24, 2010
Showing with 15 additions and 19 deletions.
  1. +1 −0 ext/.gitignore
  2. +1 −1 ext/WaxSim
  3. +1 −1 features/iphone.feature
  4. +1 −1 lib/icuke/cucumber.rb
  5. +4 −4 lib/icuke/sdk.rb
  6. +1 −5 lib/icuke/simulator.rb
  7. +6 −7 lib/icuke/{iphonesim.rb → waxsim.rb}
View
@@ -0,0 +1 @@
+bin
Submodule WaxSim updated 3 files
+2 −1 Simulator.h
+3 −2 Simulator.m
+16 −11 WaxSim.m
View
@@ -4,7 +4,7 @@ Feature: iPhone integration tests
I want cucumber to be able to drive the simulator
Background:
- Given "app/Universal.xcodeproj" is loaded in the iPhone simulator
+ Given "app/Universal.xcodeproj" is loaded in the iphone simulator
Scenario: Scrolling
When I tap "Show Test Modal"
View
@@ -185,7 +185,7 @@ def direction_modifier(direction)
quit unless scenario.failed?
end
-Given /^(?:"([^\"]*)" from )?"([^\"]*)" is loaded in the (?:(iPhone|iPad) )?simulator(?: with SDK ([0-9.]+))?$/ do |target, project, platform, sdk_version|
+Given /^(?:"([^\"]*)" from )?"([^\"]*)" is loaded in the (?:(iphone|ipad) )?simulator(?: with SDK ([0-9.]+))?$/ do |target, project, platform, sdk_version|
if sdk_version
ICuke::SDK.use(sdk_version)
elsif platform
View
@@ -1,7 +1,7 @@
module ICuke
module SDK
ICUKE_EXT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'ext', 'iCuke'))
- ICUKE_BIN_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin'))
+ ICUKE_BIN_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'ext', 'bin'))
CFLAGS = '-arch i386 -pipe -ggdb -std=c99 -DTARGET_OS_IPHONE'
def self.all
@@ -120,9 +120,9 @@ def self.ld
"xcrun -sdk #{fullname} gcc -I. -I#{sdk_ext_dir} -I#{sdk_ext_dir}/json #{cflags} #{abi_flags}"
end
- def self.launch(application, family = :ipad, environment = {})
- environment_args = environment.map { |k, v| %Q{#{k}="#{v}"} }.join(' ')
- %Q{#{environment_args} #{ICUKE_EXT_DIR}/bin/waxsim -s #{version} "#{application}"}
+ def self.launch(application, family = :iphone, environment = {})
+ environment_args = environment.map { |k, v| %Q{-e "#{k}=#{v}"} }.join(' ')
+ %Q{#{ICUKE_BIN_DIR}/waxsim -s #{version} -f #{family} #{environment_args} "#{application}"}
end
private
View
@@ -1,5 +1,5 @@
require 'icuke/core_ext'
-require 'icuke/iphonesim'
+require 'icuke/waxsim'
require 'httparty'
@@ -47,10 +47,6 @@ def set_defaults(defaults)
get '/defaults', :query => defaults.to_json
end
- def quit
- get '/quit'
- end
-
def get(path, options = {})
options[:query] = URI.escape(options[:query]) if options.has_key?(:query)
response = self.class.get(path, options)
@@ -1,3 +1,4 @@
+require 'background_process'
require 'tmpdir'
module ICuke
@@ -16,13 +17,7 @@ def launch(project_file, options = {})
options[:env]['CFFIXED_USER_HOME'] = Dir.mktmpdir
command = ICuke::SDK.launch("#{directory}/#{app_name}.app", options[:platform], options[:env])
- fork {
- STDERR.close
- STDIN.close
- STDOUT.close
-
- exec command
- }
+ @simulator = BackgroundProcess.run(command)
timeout(30) do
begin
@@ -33,5 +28,9 @@ def launch(project_file, options = {})
end
end
end
+
+ def quit
+ @simulator.kill('QUIT')
+ end
end
end

0 comments on commit c8f0c52

Please sign in to comment.