Skip to content

Commit

Permalink
Spec: fixup CLI instruments examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoody committed Dec 31, 2016
1 parent 4718c6b commit 728f633
Showing 1 changed file with 67 additions and 56 deletions.
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

0 comments on commit 728f633

Please sign in to comment.