Skip to content

Commit

Permalink
Merge pull request #389 from calabash/release/2.0.7
Browse files Browse the repository at this point in the history
Release/2.0.7
  • Loading branch information
jmoody committed Feb 26, 2016
2 parents f1c3e45 + 3f11ada commit 853e0f7
Show file tree
Hide file tree
Showing 472 changed files with 1,200 additions and 12 deletions.
19 changes: 19 additions & 0 deletions .irbrc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ def delete_simulator(name)
true
end

if !ENV["XCUITEST_WORKSPACE"]
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
elsif File.directory?(prometus)
ENV["XCUITEST_WORKSPACE"] = prometus
end
end

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

def xcuitest
RunLoop::XCUITest.new("com.apple.Preferences")
end

verbose

motd=["Let's get this done!", 'Ready to rumble.', 'Enjoy.', 'Remember to breathe.',
'Take a deep breath.', "Isn't it time for a break?", 'Can I get you a coffee?',
'What is a calabash anyway?', 'Smile! You are on camera!', 'Let op! Wild Rooster!',
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Change Log

### 2.0.7

* Obtaining codesigning information about App and Ipa #388
* Raise error if Xcode#developer\_dir path does not exist #387

### 2.0.6

* Xcrun: handle command output that contains non-UTF8 characters #382 @ark-konopacki
Expand Down
6 changes: 6 additions & 0 deletions lib/run_loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require 'run_loop/core'
require 'run_loop/version'
require 'run_loop/plist_buddy'
require "run_loop/codesign"
require 'run_loop/app'
require 'run_loop/ipa'
require 'run_loop/sim_control'
Expand All @@ -30,6 +31,11 @@
require 'run_loop/template'
require "run_loop/locale"
require "run_loop/language"
require "run_loop/xcuitest"
require "run_loop/http/error"
require "run_loop/http/server"
require "run_loop/http/request"
require "run_loop/http/retriable_client"

module RunLoop

Expand Down
15 changes: 15 additions & 0 deletions lib/run_loop/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ def calabash_server_version
version
end

# @!visibility private
def codesign_info
RunLoop::Codesign.info(path)
end

# @!visibility private
def developer_signed?
RunLoop::Codesign.developer?(path)
end

# @!visibility private
def distribution_signed?
RunLoop::Codesign.distribution?(path)
end

# @!visibility private
# Collects the paths to executables in the bundle.
def executables
Expand Down
4 changes: 4 additions & 0 deletions lib/run_loop/cli/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'run_loop/cli/instruments'
require 'run_loop/cli/simctl'
require "run_loop/cli/locale"
require "run_loop/cli/codesign"

trap 'SIGINT' do
puts 'Trapped SIGINT - exiting'
Expand Down Expand Up @@ -35,6 +36,9 @@ def version
desc "locale", "Tools for interacting with locales"
subcommand "locale", RunLoop::CLI::Locale

desc "codesign", "Tools for interacting with codesign"
subcommand "codesign", RunLoop::CLI::Codesign

end
end
end
24 changes: 24 additions & 0 deletions lib/run_loop/cli/codesign.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "thor"
require "run_loop"
require "run_loop/cli/errors"

module RunLoop
module CLI
class Codesign < Thor

desc "info ARTIFACT", "Print codesign information about ARTIFACT (ipa, app, or library)"

def info(app_or_ipa)
extension = File.extname(app_or_ipa)

if extension == ".app"
puts RunLoop::App.new(app_or_ipa).codesign_info
elsif extension == ".ipa"
puts RunLoop::Ipa.new(app_or_ipa).codesign_info
else
puts RunLoop::Codesign.info(app_or_ipa)
end
end
end
end
end
76 changes: 76 additions & 0 deletions lib/run_loop/codesign.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module RunLoop
# @!visibility private
# A wrapper around codesign command line tool
class Codesign

# @!visibility private
DEV_REGEX = /Authority=iPhone Developer:/

# @!visibility private
APP_STORE_REGEX = /Authority=Apple iPhone OS Application Signing/

# @!visibility private
DISTR_REGEX = /Authority=iPhone Distribution:/

# @!visibility private
NOT_SIGNED_REGEX = /code object is not signed at all/

# @!visibility private
def self.info(path)
self.expect_path_exists(path)
self.exec(["--display", "--verbose=4", path])
end

# @!visibility private
#
# True if the asset is signed.
def self.signed?(path)
info = self.info(path)
info[NOT_SIGNED_REGEX, 0] == nil
end

# @!visibility private
#
# True if the asset is signed with anything other than a dev cert.
def self.distribution?(path)
info = self.info(path)

info[NOT_SIGNED_REGEX, 0] == nil &&
info[DEV_REGEX, 0] == nil
end

# @!visibility private
#
# True if the asset is signed with a dev cert
def self.developer?(path)
info = self.info(path)
info[DEV_REGEX, 0] != nil
end

private

def self.expect_path_exists(path)
if !File.exist?(path)
raise ArgumentError,
%Q{There is no file or directory at path:
#{path}
}
end
end

def self.exec(args)
if !args.is_a?(Array)
raise ArgumentError, "Expected args: '#{args}' to be an Array"
end

xcrun = RunLoop::Xcrun.new
cmd = ["codesign"] + args
options = {:log_cmd => true}
hash = xcrun.exec(cmd, options)

hash[:out]
end
end
end

3 changes: 1 addition & 2 deletions lib/run_loop/core_simulator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ def self.term_or_kill(process_name, send_term_first)
end
end
end

# Returns the current simulator name.
#
# @return [String] A String suitable for searching for a pid, quitting, or
Expand Down Expand Up @@ -540,8 +541,6 @@ def sim_app_path
# @note Will only search for the current Xcode simulator.
#
# @return [Integer, nil] The pid as a String or nil if no process is found.
#
# @todo Convert this to force UTF8
def running_simulator_pid
process_name = "MacOS/#{sim_name}"

Expand Down
10 changes: 10 additions & 0 deletions lib/run_loop/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ def self.xtc?
ENV['XAMARIN_TEST_CLOUD'] == '1'
end

# Returns the value of DEVICE_TARGET
def self.device_target
ENV["DEVICE_TARGET"]
end

# Returns the value of DEVICE_ENDPOINT
def self.device_endpoint
ENV["DEVICE_ENDPOINT"]
end

# Returns the value of TRACE_TEMPLATE; the Instruments template to use
# during testing.
def self.trace_template
Expand Down
15 changes: 15 additions & 0 deletions lib/run_loop/http/error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module RunLoop
module HTTP

# Raised when there is a problem communicating with the Calabash test
# server.
class Error < StandardError

end

# Raised when there is a problem creating an HTTP request.
class RequestError < StandardError

end
end
end
44 changes: 44 additions & 0 deletions lib/run_loop/http/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module RunLoop
module HTTP

# A representation of an HTTP request that can be passed passed to the HTTP
# client as an argument for `get` or `post`.
# @!visibility private
class Request
attr_reader :route, :params

def initialize(route, params={})
@route = route
@params = params
end

# Create a new Request from `route` and `parameters`.
#
# @param [String] route The http route for the new request.
# @param [Array, Hash] parameters An Array or Hash of parameters.
# @return [Request] A new Request for `route` with `parameters`.
# @raise [RequestError] Raises an error if the parameters cannot be
# converted to JSON
def self.request(route, parameters)
Request.new(route, Request.data(parameters))
end

private

# Converts `parameters` to JSON.
#
# @param [Array, Hash] parameters An Array or Hash of parameters.
# @return [String] A JSON formatted string that represents the parameters.
# @raise [RequestError] Raises an error if the parameters cannot be
# converted to JSON
def self.data(parameters)
begin
JSON.generate(parameters)
rescue *[TypeError, JSON::GeneratorError] => e
raise RequestError, "#{e}: could not generate JSON from '#{parameters}'"
end
end
end
end
end

Loading

0 comments on commit 853e0f7

Please sign in to comment.