Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize integration tests for Xcode 8 #578

Merged
merged 6 commits into from
Dec 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/run_loop/cli/instruments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down
123 changes: 67 additions & 56 deletions spec/integration/bin/instruments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/detect_simulators_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
99 changes: 0 additions & 99 deletions spec/integration/instruments_spec.rb

This file was deleted.

33 changes: 0 additions & 33 deletions spec/integration/run_loop_spec.rb

This file was deleted.

6 changes: 4 additions & 2 deletions spec/integration/simctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down