diff --git a/lib/run_loop/cli/instruments.rb b/lib/run_loop/cli/instruments.rb index 5eda7aee..a53d7ea5 100644 --- a/lib/run_loop/cli/instruments.rb +++ b/lib/run_loop/cli/instruments.rb @@ -26,6 +26,11 @@ class Instruments < Thor def quit + if RunLoop::Xcode.new.version_gte_8? + puts "instruments quit with Xcode 8 is not supported" + exit 1 + end + signal = options[:signal] ENV['DEBUG'] = '1' if options[:debug] instruments = RunLoop::Instruments.new @@ -94,6 +99,10 @@ def quit :type => :boolean def launch + if RunLoop::Xcode.new.version_gte_8? + puts "Launching applications with Xcode 8 is not supported" + exit 1 + end debug = options[:debug] original_value = ENV['DEBUG'] diff --git a/spec/integration/bin/instruments_spec.rb b/spec/integration/bin/instruments_spec.rb index fe0f323c..cd54f487 100644 --- a/spec/integration/bin/instruments_spec.rb +++ b/spec/integration/bin/instruments_spec.rb @@ -6,89 +6,100 @@ allow(RunLoop::Environment).to receive(:debug?).and_return true end - context 'quit' do - it 'has help' do - expect(Luffa.unix_command('run-loop instruments help quit', - {:exit_on_nonzero_status => false})).to be == 0 + if Resources.shared.xcode.version_gte_8? + context "Xcode >= 8.0" do + it "instruments cli is not supported for Xcode 8" do + + end end + else + context "Xcode < 8.0" do + + context 'quit' do + it 'has help' do + expect(Luffa.unix_command('run-loop instruments help quit', + {:exit_on_nonzero_status => false})).to be == 0 + end - it 'can quit instruments' do - simctl = Resources.shared.simctl - options = + it "can quit instruments" do + simctl = Resources.shared.simctl + options = { - :app => Resources.shared.cal_app_bundle_path, - :device_target => 'simulator', - :simctl => simctl + :app => Resources.shared.cal_app_bundle_path, + :device_target => 'simulator', + :simctl => simctl } - hash = Resources.shared.launch_with_options(options) + hash = Resources.shared.launch_with_options(options) - expect(hash).not_to be nil + expect(hash).not_to be nil - instruments = RunLoop::Instruments.new - expect(instruments.instruments_pids.count).to be == 1 - expect(Luffa.unix_command('run-loop instruments quit', - {:exit_on_nonzero_status => false})).to be == 0 - end - end + instruments = RunLoop::Instruments.new + expect(instruments.instruments_pids.count).to be == 1 + expect(Luffa.unix_command('run-loop instruments quit', + {:exit_on_nonzero_status => false})).to be == 0 + end + end - context 'launch' do - it 'launching an app on default simulator' do - cmd = + context "launch" do + it "can launch an application on a simulator" do + cmd = [ - 'run-loop instruments launch', - "--app #{Resources.shared.cal_app_bundle_path}" + 'run-loop instruments launch', + "--app #{Resources.shared.cal_app_bundle_path}" ].join(' ') - expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 - end + expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 + end - describe 'launching different simulators' do - let(:instruments) { RunLoop::Instruments.new } - let(:xcode) { instruments.xcode } + describe 'launching different simulators' do + let(:instruments) { RunLoop::Instruments.new } + let(:xcode) { instruments.xcode } - it 'iOS >= 9' do + it 'iOS >= 9' do - sampled = instruments.simulators.select do |device| - device.version >= RunLoop::Version.new('9.0') - end.sample + sampled = instruments.simulators.select do |device| + device.version >= RunLoop::Version.new('9.0') + end.sample - if sampled.nil? - Luffa.log_warn("Skipping test: no iOS Simulators >= 8.0 found") - else - simulator = sampled.instruments_identifier(xcode) - cmd = + if sampled.nil? + Luffa.log_warn("Skipping test: no iOS Simulators >= 8.0 found") + else + simulator = sampled.instruments_identifier(xcode) + cmd = [ - 'run-loop instruments launch', - "--app #{Resources.shared.cal_app_bundle_path}", - "--device \"#{simulator}\"" + 'run-loop instruments launch', + "--app #{Resources.shared.cal_app_bundle_path}", + "--device \"#{simulator}\"" ].join(' ') - expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 - end - end + expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 + end + end - it '8.0 <= iOS < 9.0' do + it '8.0 <= iOS < 9.0' do - sampled = instruments.simulators.select do |device| - device.version >= RunLoop::Version.new('8.0') && + sampled = instruments.simulators.select do |device| + device.version >= RunLoop::Version.new('8.0') && device.version < RunLoop::Version.new('9.0') && device.name[/Resizable/, 0].nil? - end.sample + end.sample - if sampled.nil? - Luffa.log_warn("Skipping test: no 8.0 <= iOS Simulators < 9.0 found") - else - simulator = sampled.instruments_identifier(xcode) - cmd = + if sampled.nil? + Luffa.log_warn("Skipping test: no 8.0 <= iOS Simulators < 9.0 found") + else + simulator = sampled.instruments_identifier(xcode) + cmd = [ - 'run-loop instruments launch', - "--app #{Resources.shared.cal_app_bundle_path}", - "--device \"#{simulator}\"" + 'run-loop instruments launch', + "--app #{Resources.shared.cal_app_bundle_path}", + "--device \"#{simulator}\"" ].join(' ') - expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 + expect(Luffa.unix_command(cmd, {:exit_on_nonzero_status => false})).to be == 0 + end + end end end end diff --git a/spec/integration/detect_simulators_spec.rb b/spec/integration/detect_simulators_spec.rb index 034b8284..0d1cf7b4 100644 --- a/spec/integration/detect_simulators_spec.rb +++ b/spec/integration/detect_simulators_spec.rb @@ -1,7 +1,7 @@ describe "Detect iOS Simulators" do - it "Instruments and SimControl agree on the simulator count" do - simcontrol = RunLoop::SimControl.new.simulators.count - instruments = RunLoop::Instruments.new.simulators.count + it "Instruments and Simctl agree on the simulator count" do + simcontrol = Resources.shared.simctl.simulators.count + instruments = Resources.shared.instruments.simulators.count expect(instruments).to be == simcontrol end end diff --git a/spec/integration/instruments_spec.rb b/spec/integration/instruments_spec.rb deleted file mode 100644 index 9a20b700..00000000 --- a/spec/integration/instruments_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -describe RunLoop::Instruments do - - let(:simctl) { Resources.shared.simctl } - let(:instruments) { Resources.shared.instruments } - let(:xcode) { Resources.shared.xcode } - - before(:each) do - Resources.shared.kill_fake_instruments_process - allow(RunLoop::Environment).to receive(:debug?).and_return(true) - end - - describe '#kill_instruments' do - - let(:options) do - { - :app => Resources.shared.cal_app_bundle_path, - :device_target => 'simulator', - :simctl => simctl, - :instruments => instruments, - :xcode => xcode - } - end - - describe 'running against simulators' do - it 'the current Xcode version' do - Resources.shared.launch_with_options(options) do |hash| - expect(hash).not_to be nil - expect(instruments.instruments_running?).to be == true - instruments.kill_instruments - expect(instruments.instruments_running?).to be == false - end - end - - describe 'regression' do - xcode_installs = Resources.shared.alt_xcode_install_paths - if xcode_installs.empty? - it 'no alternative versions of Xcode found' do - expect(true).to be == true - end - else - xcode_installs.each do |developer_dir| - it "#{developer_dir}" do - Resources.shared.with_developer_dir(developer_dir) do - - options[:simctl] = RunLoop::Simctl.new - options[:instruments] = RunLoop::Instruments.new - options[:xcode] = RunLoop::Xcode.new - - if xcode.version_gte_8? - RunLoop.log_debug("Skipping Xcode 8 instruments tests") - else - Resources.shared.launch_with_options(options) do |hash| - expect(hash).not_to be nil - expect(instruments.instruments_running?).to be == true - instruments.kill_instruments - expect(instruments.instruments_running?).to be == false - end - end - end - end - end - end - end - end - end - - describe '#instruments_app_running?' do - - before(:each) { Resources.shared.kill_instruments_app } - after(:each) { Resources.shared.kill_instruments_app } - - it 'returns true when Instruments.app is running' do - Resources.shared.launch_instruments_app - expect(instruments.instruments_app_running?).to be == true - end - - it 'returns false when Instruments.app is not running' do - Resources.shared.kill_instruments_app(instruments) - expect(instruments.instruments_app_running?).to be == false - end - end - - describe '#pids_from_ps_output' do - it 'when instruments process is running return 1 process' do - simctl = Resources.shared.simctl - options = - { - :app => Resources.shared.cal_app_bundle_path, - :device_target => 'simulator', - :simctl => simctl - } - - Resources.shared.launch_with_options(options) do |hash| - expect(hash).not_to be nil - expect(instruments.send(:pids_from_ps_output).count).to be == 1 - end - end - end -end diff --git a/spec/integration/run_loop_spec.rb b/spec/integration/run_loop_spec.rb deleted file mode 100644 index bdc5fc6a..00000000 --- a/spec/integration/run_loop_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -describe 'RunLoop' do - - describe '.run' do - before(:each) { Resources.shared.kill_instruments_app } - after(:each) { Resources.shared.kill_instruments_app } - - it 'raises error if Instruments.app is running' do - Resources.shared.launch_instruments_app - expect { RunLoop.run }.to raise_error RuntimeError - end - - it "can be retried with raising an error" do - options = { - :app => Resources.shared.cal_app_bundle_path, - :uia_strategy => :preferences - } - - run_options = { - :app => Resources.shared.cal_app_bundle_path, - :uia_strategy => :preferences - } - expect(RunLoop::Core).to receive(:run_with_options).and_raise(ArgumentError) - expect(RunLoop::Core).to receive(:run_with_options).and_call_original - - begin - RunLoop.run(options) - rescue ArgumentError => _ - actual = RunLoop.run(options) - expect(actual[:uia_strategy]).to be == options[:uia_strategy] - end - end - end -end diff --git a/spec/integration/simctl_spec.rb b/spec/integration/simctl_spec.rb index d0b0dfb4..c0909345 100644 --- a/spec/integration/simctl_spec.rb +++ b/spec/integration/simctl_spec.rb @@ -15,6 +15,10 @@ end it "#wait_for_shutdown" do + RunLoop::CoreSimulator.quit_simulator + core_sim = RunLoop::CoreSimulator.new(device, app) + core_sim.launch_simulator + RunLoop::CoreSimulator.quit_simulator expect(simctl.wait_for_shutdown(device, 10.0, 0)).to be_truthy end @@ -23,8 +27,6 @@ delay = RunLoop::CoreSimulator::WAIT_FOR_SIMULATOR_STATE_INTERVAL expect(simctl.erase(device, timeout, delay)).to be_truthy - device.simulator_wait_for_stable_state - core_sim.launch_simulator timeout = RunLoop::CoreSimulator::DEFAULT_OPTIONS[:install_app_timeout]