From f0a92e154521061f9f91b265b30a0ddac564d25d Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Mon, 6 Feb 2017 13:48:30 +0100 Subject: [PATCH 01/11] Device: remove a line of commented out code --- lib/run_loop/device.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/run_loop/device.rb b/lib/run_loop/device.rb index 2e2d08c0..c88c9d43 100644 --- a/lib/run_loop/device.rb +++ b/lib/run_loop/device.rb @@ -658,7 +658,6 @@ def simulator_process_running?(process_name) waiter = RunLoop::ProcessWaiter.new(process_name) waiter.pids.any? do |pid| process_parent_is_launchd_sim?(pid) - #process_parent_is_current_xcode?(pid) end end From 8c9a059c4a913af17797da5059aee85490331a99 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 7 Feb 2017 10:55:03 +0100 Subject: [PATCH 02/11] Directory: rescue errors when checking File size --- lib/run_loop/directory.rb | 66 ++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/lib/run_loop/directory.rb b/lib/run_loop/directory.rb index b1d307e9..c55e288a 100644 --- a/lib/run_loop/directory.rb +++ b/lib/run_loop/directory.rb @@ -73,11 +73,11 @@ def self.directory_digest(path, options={}) #{e} - while trying to find the SHA of this file: +while trying to find the SHA of this file: #{file} - This is not a fatal error; it can be ignored. +This is not a fatal error; it can be ignored. } RunLoop.log_debug(message) when :raising @@ -135,32 +135,37 @@ def self.size(path, format) def self.skip_file?(file, task, debug) skip = false - if File.directory?(file) - # Skip directories - skip = true - elsif !Pathname.new(file).exist? - # Skip broken symlinks - skip = true - elsif !File.exist?(file) - # Skip files that don't exist - skip = true - else - case File.ftype(file) - when 'fifo' - RunLoop.log_warn("#{task} IS SKIPPING FIFO #{file}") if debug - skip = true - when 'socket' - RunLoop.log_warn("#{task} IS SKIPPING SOCKET #{file}") if debug - skip = true - when 'characterSpecial' - RunLoop.log_warn("#{task} IS SKIPPING CHAR SPECIAL #{file}") if debug - skip = true - when 'blockSpecial' - skip = true - RunLoop.log_warn("#{task} SKIPPING BLOCK SPECIAL #{file}") if debug - else - + begin + if File.directory?(file) + # Skip directories + skip = true + elsif !Pathname.new(file).exist? + # Skip broken symlinks + skip = true + elsif !File.exist?(file) + # Skip files that don't exist + skip = true + else + case File.ftype(file) + when 'fifo' + RunLoop.log_warn("#{task} IS SKIPPING FIFO #{file}") if debug + skip = true + when 'socket' + RunLoop.log_warn("#{task} IS SKIPPING SOCKET #{file}") if debug + skip = true + when 'characterSpecial' + RunLoop.log_warn("#{task} IS SKIPPING CHAR SPECIAL #{file}") if debug + skip = true + when 'blockSpecial' + skip = true + RunLoop.log_warn("#{task} SKIPPING BLOCK SPECIAL #{file}") if debug + else + end end + rescue => e + skip = true + RunLoop.log_debug("Directory.skip_file? rescued an ignorable error.") + RunLoop.log_debug("#{e.class}: #{e.message}") end skip end @@ -170,7 +175,12 @@ def self.iterate_for_size(entries) size = 0 entries.each do |file| unless self.skip_file?(file, "SIZE", debug) - size = size + File.size(file) + begin + size = size + File.size(file) + rescue => e + RunLoop.log_debug("Directory.iterate_for_size? rescued an ignorable error.") + RunLoop.log_debug("#{e.class}: #{e.message}") + end end end size From e7e1fd08cdf9d33931ddfff8fff1e7d98ef1b0b3 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 7 Feb 2017 10:58:14 +0100 Subject: [PATCH 03/11] JS: replaces tabs with spaces in on_alert.js --- scripts/lib/on_alert.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/lib/on_alert.js b/scripts/lib/on_alert.js index 78ee4114..92039773 100644 --- a/scripts/lib/on_alert.js +++ b/scripts/lib/on_alert.js @@ -132,15 +132,15 @@ function dutchLocalizations() { } function dutch_BE_Localizations() { - return [ - ["Sta toe", /toegang tot je locatie toestaan terwijl je de app gebruikt/], - ["Sta toe", /toegang tot je locatie toestaan, zelfs als je de app niet gebruikt/], - ["OK", /wil toegang tot je contacten/], - ["OK", /wil toegang tot je agenda/], - ["OK", /wil toegang tot je herinneringen/], - ["OK", /wil toegang tot je foto's/], - ["OK", /wil toegang tot je bewegings- en fitnessactiviteit/] - ]; + return [ + ["Sta toe", /toegang tot je locatie toestaan terwijl je de app gebruikt/], + ["Sta toe", /toegang tot je locatie toestaan, zelfs als je de app niet gebruikt/], + ["OK", /wil toegang tot je contacten/], + ["OK", /wil toegang tot je agenda/], + ["OK", /wil toegang tot je herinneringen/], + ["OK", /wil toegang tot je foto's/], + ["OK", /wil toegang tot je bewegings- en fitnessactiviteit/] + ]; } function swedishLocalizations() { From b1a4c7e0e6eea81b95e3b469c91df18bde3ea1f3 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 28 Feb 2017 12:39:01 +0100 Subject: [PATCH 04/11] Rake: create Calabash.keychain if it exists --- Rakefile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Rakefile b/Rakefile index 945aa669..df85a714 100644 --- a/Rakefile +++ b/Rakefile @@ -225,6 +225,30 @@ target = #{target} end end + def create_calabash_keychain + require "run_loop/environment" + path = File.join(RunLoop::Environment.user_home_directory, + ".calabash", "calabash-codesign") + if File.exist?(path) + Dir.chdir(path) do + args = ["apple/create-keychain.sh"] + hash = RunLoop::Shell.run_shell_command(args) + if hash[:exit_status] != 0 + raise %Q[ +Failed to create the codesigning keychain: + +#{hash[:out]} + +] + else + log_info("Created the Calabash.keychain") + end + end + else + log_info("Cannot create the Calabash.keychain") + end + end + task :build do banner("Building") @@ -233,6 +257,8 @@ target = #{target} ensure_valid_core_simulator_service + create_calabash_keychain + env = {"DEVICEAGENT_PATH" => device_agent} Dir.chdir(ios_device_manager) do From 2c548aa133cbc8ea84c8ef3d6fd2d8754765a67f Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 28 Feb 2017 12:49:19 +0100 Subject: [PATCH 05/11] Xcode: update to for Xcode 8.3 --- lib/run_loop/xcode.rb | 15 +++++++++++++++ spec/lib/xcode_spec.rb | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/run_loop/xcode.rb b/lib/run_loop/xcode.rb index 31b785de..73e15718 100644 --- a/lib/run_loop/xcode.rb +++ b/lib/run_loop/xcode.rb @@ -24,6 +24,14 @@ def inspect to_s end + # Returns a version instance for Xcode 8.3 ; used to check for the + # availability of features and paths to various items on the filesystem + # + # @return [RunLoop::Version] 8.3 + def v83 + fetch_version(:v83) + end + # Returns a version instance for Xcode 8.2 ; used to check for the # availability of features and paths to various items on the filesystem # @@ -136,6 +144,13 @@ def v50 fetch_version(:v50) end + # Is the active Xcode version 8.3 or above? + # + # @return [Boolean] `true` if the current Xcode version is >= 8.3 + def version_gte_83? + version >= v83 + end + # Is the active Xcode version 8.2 or above? # # @return [Boolean] `true` if the current Xcode version is >= 8.2 diff --git a/spec/lib/xcode_spec.rb b/spec/lib/xcode_spec.rb index 5eb201da..559db048 100644 --- a/spec/lib/xcode_spec.rb +++ b/spec/lib/xcode_spec.rb @@ -56,6 +56,7 @@ expect(xcode.send(:fetch_version, key)).to be == version end + it '#v83' do expect(xcode.v83).to be == RunLoop::Version.new('8.3') end it '#v82' do expect(xcode.v82).to be == RunLoop::Version.new('8.2') end it '#v81' do expect(xcode.v81).to be == RunLoop::Version.new('8.1') end it '#v80' do expect(xcode.v80).to be == RunLoop::Version.new('8.0') end @@ -71,6 +72,20 @@ it '#v51' do expect(xcode.v51).to be == RunLoop::Version.new('5.1') end it '#v50' do expect(xcode.v50).to be == RunLoop::Version.new('5.0') end + describe "#version_gte_83?" do + it "true" do + expect(xcode).to receive(:version).and_return(RunLoop::Version.new("8.3")) + + expect(xcode.version_gte_83?).to be_truthy + end + + it "false" do + expect(xcode).to receive(:version).and_return xcode.v82 + + expect(xcode.version_gte_83?).to be_falsey + end + end + describe "#version_gte_82?" do it "true" do expect(xcode).to receive(:version).and_return(RunLoop::Version.new("8.2")) From 55d8a14a0b2a1604d157804a9f4236c648efc51d Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 28 Feb 2017 12:52:22 +0100 Subject: [PATCH 06/11] Core: iPhone 7 10.3 is default sim for Xcode 8.3 --- lib/run_loop/core.rb | 4 +++- spec/lib/core_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/run_loop/core.rb b/lib/run_loop/core.rb index d7dcd664..c7c29d45 100644 --- a/lib/run_loop/core.rb +++ b/lib/run_loop/core.rb @@ -320,7 +320,9 @@ def self.include_calabash_script?(options) # version. def self.default_simulator(xcode=RunLoop::Xcode.new) - if xcode.version_gte_82? + if xcode.version_gte_83? + "iPhone 7 (10.3)" + elsif xcode.version_gte_82? "iPhone 7 (10.2)" elsif xcode.version_gte_81? "iPhone 7 (10.1)" diff --git a/spec/lib/core_spec.rb b/spec/lib/core_spec.rb index e0581bfa..d48e6575 100644 --- a/spec/lib/core_spec.rb +++ b/spec/lib/core_spec.rb @@ -268,6 +268,12 @@ expect(xcode).to receive(:version).at_least(:once).and_return xcode.v82 expect(RunLoop::Core.default_simulator(xcode)).to be == expected end + + it 'Xcode >= 8.3' do + expected = 'iPhone 7 (10.3)' + expect(xcode).to receive(:version).at_least(:once).and_return xcode.v83 + expect(RunLoop::Core.default_simulator(xcode)).to be == expected + end end describe '.above_or_eql_version?' do From 7f12e7bbc3515e362f19efedfcae2c4e08d979d7 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 28 Feb 2017 14:24:37 +0100 Subject: [PATCH 07/11] DA:Client: skip ensure software keyboard check This check quits the simulator and defeats the purpose of CoreSim: quit simulator only when necessary #580 @JoeSSS --- lib/run_loop/device_agent/client.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/run_loop/device_agent/client.rb b/lib/run_loop/device_agent/client.rb index 1727671d..b8ed8d12 100644 --- a/lib/run_loop/device_agent/client.rb +++ b/lib/run_loop/device_agent/client.rb @@ -112,7 +112,6 @@ def self.run(options={}) core_sim.reset_app_sandbox end - simctl.ensure_software_keyboard(device) core_sim.install end From 410ed0d7d49733d1065fea2105017023e2376ba1 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Tue, 28 Feb 2017 14:33:42 +0100 Subject: [PATCH 08/11] CoreSim: quit simulator if before resetting app sandbox --- lib/run_loop/core_simulator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/run_loop/core_simulator.rb b/lib/run_loop/core_simulator.rb index f9467e1f..aada361d 100644 --- a/lib/run_loop/core_simulator.rb +++ b/lib/run_loop/core_simulator.rb @@ -460,6 +460,7 @@ def app_is_installed? def reset_app_sandbox return true if !app_is_installed? + RunLoop::CoreSimulator.quit_simulator RunLoop::CoreSimulator.wait_for_simulator_state(device, "Shutdown") reset_app_sandbox_internal From 0ddd7a8f1a538c02caec1f9b4e84bde34cdf24d8 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Mon, 6 Mar 2017 13:46:58 +0100 Subject: [PATCH 09/11] Xcode#version returns 0.0.0 on XTC and on errors --- lib/run_loop/xcode.rb | 41 +++++++++++++++++++++++----------- spec/integration/xcode_spec.rb | 16 ------------- spec/lib/run_loop_spec.rb | 4 ++-- spec/lib/xcode_spec.rb | 40 ++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/lib/run_loop/xcode.rb b/lib/run_loop/xcode.rb index 73e15718..d6859def 100644 --- a/lib/run_loop/xcode.rb +++ b/lib/run_loop/xcode.rb @@ -1,5 +1,3 @@ -require 'open3' - module RunLoop # A model of the active Xcode version. @@ -12,7 +10,11 @@ module RunLoop # `xcode-select` or overridden using the `DEVELOPER_DIR`. class Xcode + require "run_loop/regex" + require "run_loop/shell" + include RunLoop::Regex + include RunLoop::Shell # Returns a String representation. def to_s @@ -249,12 +251,31 @@ def version_gte_51? # @return [RunLoop::Version] The current version of Xcode as reported by # `xcrun xcodebuild -version`. def version - @xcode_version ||= lambda do - execute_command(['-version']) do |stdout, _, _| - version_string = stdout.read.chomp[VERSION_REGEX, 0] - RunLoop::Version.new(version_string) + @xcode_version ||= begin + if RunLoop::Environment.xtc? + RunLoop::Version.new("0.0.0") + else + version = RunLoop::Version.new("0.0.0") + begin + args = ["xcrun", "xcodebuild", "-version"] + hash = run_shell_command(args) + if hash[:exit_status] != 0 + RunLoop.log_error("xcrun xcodebuild -version exited non-zero") + else + out = hash[:out] + version_string = out.chomp[VERSION_REGEX, 0] + version = RunLoop::Version.new(version_string) + end + rescue RuntimeError => e + RunLoop.log_error(%Q[ +Could not find Xcode version: + + #{e.class}: #{e.message} +]) + end + version end - end.call + end end # Is this a beta version of Xcode? @@ -348,12 +369,6 @@ def ensure_valid_version_key(key) end end - def execute_command(args) - Open3.popen3('xcrun', 'xcodebuild', *args) do |_, stdout, stderr, wait_thr| - yield stdout, stderr, wait_thr - end - end - def xcode_select_path Open3.popen3('xcode-select', '--print-path') do |_, stdout, _, _| stdout.read.chomp diff --git a/spec/integration/xcode_spec.rb b/spec/integration/xcode_spec.rb index 949b8c3f..12733d00 100644 --- a/spec/integration/xcode_spec.rb +++ b/spec/integration/xcode_spec.rb @@ -2,22 +2,6 @@ let(:xcode) { RunLoop::Xcode.new } - it '#version' do - stdout = %q( -Xcode 7.0.1 -Build version 7A192o -) - yielded = [StringIO.new(stdout), StringIO.new(''), nil] - expect(xcode).to receive(:execute_command).with(['-version']).and_yield(*yielded) - - expected = RunLoop::Version.new('7.0.1') - expect(xcode.version).to be == expected - expect(xcode.instance_variable_get(:@xcode_version)).to be == expected - - #Testing memoization - expect(xcode.version).to be == expected - end - it '#xcode_select_path' do path = xcode.send(:xcode_select_path) expect(Dir.exist?(path)).to be_truthy diff --git a/spec/lib/run_loop_spec.rb b/spec/lib/run_loop_spec.rb index f9812755..6419bbf1 100644 --- a/spec/lib/run_loop_spec.rb +++ b/spec/lib/run_loop_spec.rb @@ -49,7 +49,7 @@ context "not XTC" do before do - expect(RunLoop::Environment).to receive(:xtc?).and_return(false) + expect(RunLoop::Environment).to receive(:xtc?).at_least(:once).and_return(false) end context "Xcode >= 8" do @@ -101,7 +101,7 @@ context "not XTC" do before do - expect(RunLoop::Environment).to receive(:xtc?).and_return(false) + expect(RunLoop::Environment).to receive(:xtc?).at_least(:once).and_return(false) end context ":automator defined" do diff --git a/spec/lib/xcode_spec.rb b/spec/lib/xcode_spec.rb index 559db048..1d793637 100644 --- a/spec/lib/xcode_spec.rb +++ b/spec/lib/xcode_spec.rb @@ -29,13 +29,51 @@ end end - it 'does not raise an error for valid keys' do + it 'does not raise an error for vaklid keys' do expect do xcode.send(:ensure_valid_version_key, :v70) end.not_to raise_error end end + context "#version" do + let(:xcodebuild_out) do + { + :out => %Q[ +Xcode 8.2.1 +Build version 8W132p +], + :exit_status => 0, + :pid => 1 + } + end + + it "returns 0.0.0 when running on Test Cloud" do + expect(RunLoop::Environment).to receive(:xtc?).and_return(true) + + expect(xcode.version).to be == RunLoop::Version.new("0.0.0") + end + + it "returns 0.0.0 when xcrun xcodebuild has exit status non-zero" do + xcodebuild_out[:exit_status] = 1 + expect(xcode).to receive(:run_shell_command).and_return(xcodebuild_out) + + expect(xcode.version).to be == RunLoop::Version.new("0.0.0") + end + + it "returns 0.0.0 when xcrun xcodebuild raises an error" do + expect(xcode).to receive(:run_shell_command).and_raise(RuntimeError) + + expect(xcode.version).to be == RunLoop::Version.new("0.0.0") + end + + it "returns Xcode version" do + expect(xcode).to receive(:run_shell_command).and_return(xcodebuild_out) + + expect(xcode.version).to be == RunLoop::Version.new("8.2.1") + end + end + it '#xcode_versions' do expect(xcode.instance_variable_get(:@xcode_versions)).to be == nil expect(xcode.send(:xcode_versions)).to be == {} From 289a4abb901e5c3b17a6e240bb1f0e96962c28fc Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Mon, 6 Mar 2017 15:50:04 +0100 Subject: [PATCH 10/11] Doc: changelog for 2.3.1 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dd506aa..118758a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ ## Change Log +### 2.3.1 + +This release does not contain a new DeviceAgent stack. + +* Xcode#version returns 0.0.0 on XTC and on RuntimeErrors #606 +* CoreSim: quit simulator before resetting app sandbox #605 +* DeviceAgent::Client: skip ensure software keyboard check #604 +* Prepare for Xcode 8.3 support #603 +* Directory: rescue errors during skip check and File.size #598 +* Directory: rescue ENOENT errors during skip check #597 + ### 2.3.0 This release contains a significant change - Simulators will not be From 682817a249b4cc1ccc660e901cbe131346b99e71 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Mon, 6 Mar 2017 15:50:18 +0100 Subject: [PATCH 11/11] Gem: bump version to 2.3.1 --- lib/run_loop/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/run_loop/version.rb b/lib/run_loop/version.rb index 5876e922..663426c2 100644 --- a/lib/run_loop/version.rb +++ b/lib/run_loop/version.rb @@ -1,5 +1,5 @@ module RunLoop - VERSION = "2.3.0" + VERSION = "2.3.1" # A model of a software release version that can be used to compare two versions. #