Skip to content

Commit

Permalink
Merge pull request #104 from calabash/release/1.2.1
Browse files Browse the repository at this point in the history
Release/1.2.1
  • Loading branch information
jmoody committed Jan 9, 2015
2 parents 656f6b1 + 40e5cd9 commit 263530d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Change Log

### 1.2.1

* #101 Escape binary path in argument to lipo. @gredman

### 1.2.0

* Improved :host strategy.
Expand Down
7 changes: 5 additions & 2 deletions lib/run_loop/lipo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def expect_compatible_arch(device)
# @return [Array<String>] A list of architecture.
# @raise [RuntimeError] If the output of lipo cannot be parsed.
def info
execute_lipo("-info #{binary_path}") do |stdout, stderr, wait_thr|
execute_lipo("-info \"#{binary_path}\"") do |stdout, stderr, wait_thr|
output = stdout.read.strip
begin
output.split(':')[-1].strip.split
rescue Exception => e
msg = ['Expected to be able to parse the output of lipo.',
"cmd: 'lipo -info #{binary_path}'",
"cmd: 'lipo -info #{escaped_binary_path}'",
"stdout: '#{output}'",
"stderr: '#{stderr.read.strip}'",
"exit code: '#{wait_thr.value}'",
Expand All @@ -99,6 +99,9 @@ def info

private

# Caller is responsible for correctly escaping arguments.
# For example, the caller must proper quote `"` paths to avoid errors
# when dealing with paths that contain spaces.
def execute_lipo(argument)
command = "xcrun lipo #{argument}"
Open3.popen3(command) do |_, stdout, stderr, wait_thr|
Expand Down
2 changes: 1 addition & 1 deletion lib/run_loop/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RunLoop
VERSION = '1.2.0'
VERSION = '1.2.1'

# A model of a software release version that can be used to compare two versions.
#
Expand Down
20 changes: 18 additions & 2 deletions spec/lib/lipo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'tmpdir'
require 'fileutils'

describe RunLoop::Lipo do

let(:app_bundle_path) { Resources.shared.app_bundle_path }
Expand Down Expand Up @@ -33,14 +36,27 @@

it 'raises an error if lipo output cannot be parsed' do
stream = lambda { |string| StringIO.new(string, 'r') }
class RunLoop::Lipo::RSpec::ProcessStatus
class RunLoop::Lipo::ProcessStatus
def value() 1 end
end
expect(lipo).to receive(:execute_lipo).and_yield(stream.call(''),
stream.call('stderr output'),
RunLoop::Lipo::RSpec::ProcessStatus.new)
RunLoop::Lipo::ProcessStatus.new)
expect { lipo.info }.to raise_error
end

context 'bundle path has spaces' do
let(:app_bundle_path) {
tmpdir = Dir.mktmpdir
working_dir = File.join(tmpdir, 'a path with spaces')
FileUtils.mkdir_p(working_dir)
original = Resources.shared.app_bundle_path_i386
FileUtils.cp_r(original, working_dir)
File.join(working_dir, File.basename(original))
}
it { is_expected.to be_a Array }
it { is_expected.to match_array ['i386'] }
end
end

describe '#expect_compatible_arch' do
Expand Down
Binary file modified spec/resources/chou-cal.app/chou-cal
Binary file not shown.
Binary file modified spec/resources/chou-cal.ipa
Binary file not shown.
Binary file modified spec/resources/chou.app/chou
Binary file not shown.
Binary file modified spec/resources/chou.ipa
Binary file not shown.
Binary file modified spec/resources/dylibs/libCalabashDyn.dylib
Binary file not shown.
Binary file modified spec/resources/dylibs/libCalabashDynSim.dylib
Binary file not shown.

0 comments on commit 263530d

Please sign in to comment.