Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
0fc24622
Commit
0fc24622
authored
Jul 17, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3818 from CocoaPods/seg-which
[Executable] Dont use a subprocess for which
parents
4e74f0da
89a29416
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
17 deletions
+44
-17
executable.rb
lib/cocoapods/executable.rb
+22
-2
validator.rb
lib/cocoapods/validator.rb
+1
-1
spec_helper.rb
spec/spec_helper.rb
+1
-1
executable_spec.rb
spec/unit/executable_spec.rb
+2
-1
bridge_support_spec.rb
spec/unit/generator/bridge_support_spec.rb
+12
-10
validator_spec.rb
spec/unit/validator_spec.rb
+6
-2
No files found.
lib/cocoapods/executable.rb
View file @
0fc24622
...
...
@@ -48,8 +48,8 @@ module Pod
# @todo Find a way to display the live output of the commands.
#
def
self
.
execute_command
(
executable
,
command
,
raise_on_failure
)
bin
=
`which
#{
executable
}
`
.
strip
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
if
bin
.
empty?
bin
=
which
(
executable
)
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
unless
bin
require
'shellwords'
...
...
@@ -75,6 +75,26 @@ module Pod
output
end
# Returns the absolute path to the binary with the given name on the current
# `PATH`, or `nil` if none is found.
#
# @param [String] program
# The name of the program being searched for.
#
# @return [String,Nil] The absolute path to the given program, or `nil` if
# it wasn't found in the current `PATH`.
#
def
self
.
which
(
program
)
program
=
program
.
to_s
ENV
[
'PATH'
].
split
(
File
::
PATH_SEPARATOR
).
each
do
|
path
|
bin
=
File
.
expand_path
(
program
,
path
)
if
File
.
file?
(
bin
)
&&
File
.
executable?
(
bin
)
return
bin
end
end
nil
end
private
def
self
.
popen3
(
bin
,
command
,
stdout
,
stderr
)
...
...
lib/cocoapods/validator.rb
View file @
0fc24622
...
...
@@ -381,7 +381,7 @@ module Pod
# @return [void]
#
def
build_pod
if
`which xcodebuild`
.
strip
.
empty
?
if
Executable
.
which
(
'xcodebuild'
).
nil
?
UI
.
warn
"Skipping compilation with `xcodebuild' because it can't be found.
\n
"
.
yellow
else
UI
.
message
"
\n
Building with xcodebuild.
\n
"
.
yellow
do
...
...
spec/spec_helper.rb
View file @
0fc24622
...
...
@@ -70,7 +70,7 @@ end
#-----------------------------------------------------------------------------#
ENV
[
'SKIP_SETUP'
]
=
'true'
if
ENV
[
'SKIP_XCODEBUILD'
].
nil?
&&
`which xcodebuild`
.
strip
.
empty
?
if
ENV
[
'SKIP_XCODEBUILD'
].
nil?
&&
Pod
::
Executable
.
which
(
'xcodebuild'
).
nil
?
ENV
[
'SKIP_XCODEBUILD'
]
=
'true'
end
...
...
spec/unit/executable_spec.rb
View file @
0fc24622
...
...
@@ -12,7 +12,8 @@ module Pod
it
'should support spaces in the full path of the command'
do
cmd
=
'/Spa ces/are"/fun/false'
Executable
.
stubs
(
:`
).
returns
(
cmd
)
File
.
expects
(
:file?
).
with
(
cmd
).
returns
(
true
)
File
.
expects
(
:executable?
).
with
(
cmd
).
returns
(
true
)
result
=
mock
result
.
stubs
(
:success?
).
returns
(
true
)
...
...
spec/unit/generator/bridge_support_spec.rb
View file @
0fc24622
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
describe
'Pod::Generator::BridgeSupport'
do
if
`which gen_bridge_metadata`
.
strip
.
empty?
puts
' ! '
.
red
<<
"Skipping because the `gen_bridge_metadata` executable can't be found."
else
it
'generates a metadata file with the appropriate search paths'
do
headers
=
%w(/some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h)
.
map
{
|
h
|
Pathname
.
new
(
h
)
}
generator
=
Pod
::
Generator
::
BridgeSupport
.
new
(
headers
)
expected
=
[
'-c'
,
"-I '/some/dir' -I '/some/other/dir'"
,
'-o'
,
'/path/to/Pods.bridgesupport'
,
*
headers
]
generator
.
expects
(
:gen_bridge_metadata
).
with
{
|*
command
|
command
.
map
(
&
:to_s
)
==
expected
.
map
(
&
:to_s
)
}
generator
.
save_as
(
Pathname
.
new
(
'/path/to/Pods.bridgesupport'
))
module
Pod
describe
'Pod::Generator::BridgeSupport'
do
if
Executable
.
which
(
'gen_bridge_metadata'
).
nil?
puts
' ! '
.
red
<<
"Skipping because the `gen_bridge_metadata` executable can't be found."
else
it
'generates a metadata file with the appropriate search paths'
do
headers
=
%w(/some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h)
.
map
{
|
h
|
Pathname
.
new
(
h
)
}
generator
=
Generator
::
BridgeSupport
.
new
(
headers
)
expected
=
[
'-c'
,
"-I '/some/dir' -I '/some/other/dir'"
,
'-o'
,
'/path/to/Pods.bridgesupport'
,
*
headers
]
generator
.
expects
(
:gen_bridge_metadata
).
with
{
|*
command
|
command
.
map
(
&
:to_s
)
==
expected
.
map
(
&
:to_s
)
}
generator
.
save_as
(
Pathname
.
new
(
'/path/to/Pods.bridgesupport'
))
end
end
end
end
spec/unit/validator_spec.rb
View file @
0fc24622
...
...
@@ -378,7 +378,9 @@ module Pod
validator
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
))
validator
.
stubs
(
:check_file_patterns
)
validator
.
stubs
(
:validate_url
)
validator
.
expects
(
:`
).
with
(
'which xcodebuild'
).
times
(
3
).
returns
(
'/usr/bin/xcodebuild'
)
git
=
Executable
.
which
(
:git
)
Executable
.
stubs
(
:which
).
with
(
'git'
).
returns
(
git
)
Executable
.
expects
(
:which
).
with
(
'xcodebuild'
).
times
(
3
).
returns
(
'/usr/bin/xcodebuild'
)
status
=
mock
status
.
stubs
(
:success?
).
returns
(
false
)
validator
.
stubs
(
:_xcodebuild
).
returns
([
'Output'
,
status
])
...
...
@@ -393,7 +395,9 @@ module Pod
validator
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
))
validator
.
stubs
(
:check_file_patterns
)
validator
.
stubs
(
:validate_url
)
validator
.
expects
(
:`
).
with
(
'which xcodebuild'
).
times
(
3
).
returns
(
'/usr/bin/xcodebuild'
)
git
=
Executable
.
which
(
:git
)
Executable
.
stubs
(
:which
).
with
(
'git'
).
returns
(
git
)
Executable
.
expects
(
:which
).
with
(
'xcodebuild'
).
times
(
3
).
returns
(
'/usr/bin/xcodebuild'
)
command
=
'xcodebuild clean build -target Pods'
validator
.
expects
(
:`
).
with
(
"
#{
command
}
2>&1"
).
twice
.
returns
(
''
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk iphonesimulator 2>&1"
).
once
.
returns
(
''
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment