Skip to content

Commit

Permalink
Merge pull request #425 from calabash/release/2.1.0
Browse files Browse the repository at this point in the history
Release/2.1.0
  • Loading branch information
jmoody committed Mar 31, 2016
2 parents e538f3a + f87bbaf commit 814e61b
Show file tree
Hide file tree
Showing 179 changed files with 2,378 additions and 1,083 deletions.
26 changes: 20 additions & 6 deletions .irbrc
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,35 @@ def delete_simulator(name)
true
end

if !ENV["XCUITEST_WORKSPACE"]
if !ENV["CBXWS"]
moody = File.expand_path(File.join("~/", "git", "calabash", "xcuitest", "CBXDriver.xcworkspace"))
prometus = File.expand_path(File.join("~/", "calabash-xcuitest-server", "CBXDriver.xcworkspace"))

if File.directory?(moody)
ENV["XCUITEST_WORKSPACE"] = moody
ENV["CBXWS"] = moody
elsif File.directory?(prometus)
ENV["XCUITEST_WORKSPACE"] = prometus
ENV["CBXWS"] = prometus
end
end

puts "XCUITest workspace = #{ENV["XCUITEST_WORKSPACE"]}"
puts "XCUITest workspace = #{ENV["CBXWS"]}"

def xcuitest
RunLoop::XCUITest.new("com.apple.Preferences")
def xcuitest(bundle_id="com.apple.Preferences")
device = RunLoop::Device.detect_device({}, xcode, simcontrol, instruments)
RunLoop::XCUITest.new(bundle_id, device)
end

def holmes(bundle_id="com.apple.Preferences")
device = RunLoop::Device.detect_device({}, xcode, simcontrol, instruments)
options = {
:device => device.udid,
:xcuitest => true,
:xcode => xcode,
:simctl => simcontrol,
:instruments => instruments,
:app => bundle_id
}
RunLoop.run(options)
end

verbose
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
## Change Log

### 2.1.0

This release fixes a bug that might put the iOS Simulator into a bad state.
An iOS Simulator could potentially have a .app installed in its directory
structure, but the app would not appear in Springboard or be detected by
simctl. We have fixed the bug for Xcode 7. There is no possible fix for
Xcode 6. In order to ensure that your iOS Simulators are in a good shape we
recommend that all users run:

```
# Will take ~10 minutes depending on the number of installed simulators.
#
# Don't forget to run this on your CI machines.
#
# You only have to run this command once!
$ DEBUG=1 run-loop simctl doctor
```

I apologize for the inconvenience, this mistake is on me. -jjm

* Experimental interface for launching CBX-Runner and sending commands
#423
* App and Ipa can return version info #422
* CLI: simctl doctor erases sims first #421
* Improve installed app check for Xcode 7 simulators #420
* Instruments#kill\_instruments no longer branches on Xcode version #420
* CoreSim#launch - retry on errors #418
* Interface for launching CBX-Runner #417
* Core.run\_with\_options improve the way AUT and DUT are inferred #414
* Core.detecti\_uia\_strategy given options and RunLoop::Device #413
* DetectAUT.detect\_app\_under\_test #412
* Device is responsible for inferring which device to target #411
* Drop Xcode 5 checks #410
* Environment: handle empty strings for DEVICE\_TARGET, DEVICE\_ENDPOINT, and
TRACE\_TEMPLATE #408
* Rescue pipe\_io if Errno::EPIPE error is encountered #407 @TeresaP

### 2.0.9

* Improve automatic .app detection #405
Expand Down
92 changes: 48 additions & 44 deletions lib/run_loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
require 'run_loop/host_cache'
require 'run_loop/patches/awesome_print'
require 'run_loop/core_simulator'
require 'run_loop/simctl/plists'
require "run_loop/simctl"
require 'run_loop/template'
require "run_loop/locale"
require "run_loop/language"
Expand Down Expand Up @@ -66,64 +66,69 @@ class WriteFailedError < RuntimeError

def self.run(options={})

if RunLoop::Instruments.new.instruments_app_running?
raise %q(The Instruments.app is open.
if options[:xcuitest]
RunLoop::XCUITest.run(options)
else

if RunLoop::Instruments.new.instruments_app_running?
raise %q(The Instruments.app is open.
If the Instruments.app is open, the instruments command line tool cannot take
control of your application.
Please quit the Instruments.app and try again.)

end
end

uia_strategy = options[:uia_strategy]
if options[:script]
script = validate_script(options[:script])
else
if uia_strategy
script = default_script_for_uia_strategy(uia_strategy)
uia_strategy = options[:uia_strategy]
if options[:script]
script = validate_script(options[:script])
else
if options[:calabash_lite]
uia_strategy = :host
script = Core.script_for_key(:run_loop_host)
else
uia_strategy = :preferences
if uia_strategy
script = default_script_for_uia_strategy(uia_strategy)
else
if options[:calabash_lite]
uia_strategy = :host
script = Core.script_for_key(:run_loop_host)
else
uia_strategy = :preferences
script = default_script_for_uia_strategy(uia_strategy)
end
end
end
end
# At this point, 'script' has been chosen, but uia_strategy might not
unless uia_strategy
desired_script = options[:script]
if desired_script.is_a?(String) #custom path to script
uia_strategy = :host
elsif desired_script == :run_loop_host
uia_strategy = :host
elsif desired_script == :run_loop_fast_uia
uia_strategy = :preferences
elsif desired_script == :run_loop_shared_element
uia_strategy = :shared_element
else
raise "Inconsistent state: desired script #{desired_script} has not uia_strategy"
# At this point, 'script' has been chosen, but uia_strategy might not
unless uia_strategy
desired_script = options[:script]
if desired_script.is_a?(String) #custom path to script
uia_strategy = :host
elsif desired_script == :run_loop_host
uia_strategy = :host
elsif desired_script == :run_loop_fast_uia
uia_strategy = :preferences
elsif desired_script == :run_loop_shared_element
uia_strategy = :shared_element
else
raise "Inconsistent state: desired script #{desired_script} has not uia_strategy"
end
end
end

# At this point script and uia_strategy selected
cloned_options = options.clone
cloned_options[:script] = script
cloned_options[:uia_strategy] = uia_strategy
# At this point script and uia_strategy selected
cloned_options = options.clone
cloned_options[:script] = script
cloned_options[:uia_strategy] = uia_strategy

# Xcode and SimControl will not be properly cloned and we don't want
# them to be; we want to use the exact objects that were passed.
if options[:xcode]
cloned_options[:xcode] = options[:xcode]
end
# Xcode and SimControl will not be properly cloned and we don't want
# them to be; we want to use the exact objects that were passed.
if options[:xcode]
cloned_options[:xcode] = options[:xcode]
end

if options[:sim_control]
cloned_options[:sim_control] = options[:sim_control]
end
if options[:sim_control]
cloned_options[:sim_control] = options[:sim_control]
end

Core.run_with_options(cloned_options)
Core.run_with_options(cloned_options)
end
end

def self.send_command(run_loop, cmd, options={timeout: 60}, num_retries=0, last_error=nil)
Expand Down Expand Up @@ -235,5 +240,4 @@ def self.validate_script(script)
def self.log_info(*args)
RunLoop::Logging.log_info(*args)
end

end
84 changes: 83 additions & 1 deletion lib/run_loop/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ def initialize(app_bundle_path)

# @!visibility private
def to_s
"#<APP: #{path}>"
cf_bundle_version = bundle_version
cf_bundle_short_version = short_bundle_version

if cf_bundle_version && cf_bundle_short_version
version = "#{cf_bundle_version.to_s} / #{cf_bundle_short_version}"
elsif cf_bundle_version
version = cf_bundle_version.to_s
elsif cf_bundle_short_version
version = cf_bundle_short_version
else
version = ""
end

"#<APP #{bundle_identifier} #{version} #{path}>"
end

# @!visibility private
Expand Down Expand Up @@ -130,6 +143,75 @@ def distribution_signed?
RunLoop::Codesign.distribution?(path)
end

# Returns the CFBundleShortVersionString of the app as Version instance.
#
# Apple docs:
#
# CFBundleShortVersionString specifies the release version number of the
# bundle, which identifies a released iteration of the app. The release
# version number is a string comprised of three period-separated integers.
#
# The first integer represents major revisions to the app, such as revisions
# that implement new features or major changes. The second integer denotes
# revisions that implement less prominent features. The third integer
# represents maintenance releases.
#
# The value for this key differs from the value for CFBundleVersion, which
# identifies an iteration (released or unreleased) of the app. This key can
# be localized by including it in your InfoPlist.strings files.
#
# @return [RunLoop::Version, nil] Returns a Version instance if the
# CFBundleShortVersion string is well formed and nil if not.
def marketing_version
string = plist_buddy.plist_read("CFBundleShortVersionString", info_plist_path)
begin
version = RunLoop::Version.new(string)
rescue
if string && string != ""
RunLoop.log_debug("CFBundleShortVersionString: '#{string}' is not a well formed version string")
else
RunLoop.log_debug("CFBundleShortVersionString is not defined in Info.plist")
end
version = nil
end
version
end

# See #marketing_version
alias_method :short_bundle_version, :marketing_version

# Returns the CFBundleVersionString of the app as Version instance.
#
# Apple docs:
#
# CFBundleVersion specifies the build version number of the bundle, which
# identifies an iteration (released or unreleased) of the bundle. The build
# version number should be a string comprised of three non-negative,
# period-separated integers with the first integer being greater than zero.
# The string should only contain numeric (0-9) and period (.) characters.
# Leading zeros are truncated from each integer and will be ignored (that
# is, 1.02.3 is equivalent to 1.2.3).
#
# @return [RunLoop::Version, nil] Returns a Version instance if the
# CFBundleVersion string is well formed and nil if not.
def build_version
string = plist_buddy.plist_read("CFBundleVersionString", info_plist_path)
begin
version = RunLoop::Version.new(string)
rescue
if string && string != ""
RunLoop.log_debug("CFBundleVersionString: '#{string}' is not a well formed version string")
else
RunLoop.log_debug("CFBundleVersionString is not defined in Info.plist")
end
version = nil
end
version
end

# See #build_version
alias_method :bundle_version, :build_version

# @!visibility private
# Collects the paths to executables in the bundle.
def executables
Expand Down
11 changes: 8 additions & 3 deletions lib/run_loop/cli/simctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,25 @@ def doctor
debug = options[:debug]
device = options[:device]

manage_processes

if device
RunLoop::Environment.with_debugging(debug) do
RunLoop::CoreSimulator.erase(device)
launch_simulator(device, xcode)
end
else
launch_each_simulator
RunLoop::Environment.with_debugging(debug) do
erase_and_launch_each_simulator
end
end

manage_processes
end

no_commands do
def launch_each_simulator
def erase_and_launch_each_simulator
sim_control.simulators.each do |simulator|
RunLoop::CoreSimulator.erase(simulator)
launch_simulator(simulator, xcode)
end
end
Expand Down
Loading

0 comments on commit 814e61b

Please sign in to comment.