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
3a8cc9cf
Commit
3a8cc9cf
authored
Mar 12, 2017
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a better error message if a podspec is found but cannot be parsed
parent
f5d7b5bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
27 deletions
+59
-27
CHANGELOG.md
CHANGELOG.md
+4
-0
abstract_external_source.rb
lib/cocoapods/external_sources/abstract_external_source.rb
+22
-14
podspec_finder.rb
lib/cocoapods/sandbox/podspec_finder.rb
+3
-7
abstract_external_source_spec.rb
spec/unit/external_sources/abstract_external_source_spec.rb
+30
-0
podspec_finder_spec.rb
spec/unit/sandbox/podspec_finder_spec.rb
+0
-6
No files found.
CHANGELOG.md
View file @
3a8cc9cf
...
...
@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
*
Provide a better error message if a podspec is found but cannot be parsed.
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6457
](
https://github.com/CocoaPods/CocoaPods/issues/6457
)
*
Only share pod target xcscheme if present during validation.
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6558
](
https://github.com/CocoaPods/CocoaPods/pull/6558
)
...
...
lib/cocoapods/external_sources/abstract_external_source.rb
View file @
3a8cc9cf
...
...
@@ -111,11 +111,15 @@ module Pod
title
=
"Pre-downloading: `
#{
name
}
`
#{
description
}
"
UI
.
titled_section
(
title
,
:verbose_prefix
=>
'-> '
)
do
target
=
sandbox
.
pod_dir
(
name
)
download_result
=
Downloader
.
download
(
download_request
,
target
,
:can_cache
=>
can_cache
)
begin
download_result
=
Downloader
.
download
(
download_request
,
target
,
:can_cache
=>
can_cache
)
rescue
Pod
::
DSLError
=>
e
raise
Informative
,
"Failed to load '
#{
name
}
' podspec:
#{
e
.
message
}
"
rescue
=>
_
raise
Informative
,
"Unable to find a specification for '
#{
name
}
'."
end
spec
=
download_result
.
spec
raise
Informative
,
"Unable to find a specification for '
#{
name
}
'."
unless
spec
store_podspec
(
sandbox
,
spec
)
sandbox
.
store_pre_downloaded_pod
(
name
)
sandbox
.
store_checkout_source
(
name
,
download_result
.
checkout_options
)
...
...
@@ -147,17 +151,21 @@ module Pod
# @return [void]
#
def
store_podspec
(
sandbox
,
spec
,
json
=
false
)
spec
=
case
spec
when
Pathname
Specification
.
from_file
(
spec
)
when
String
path
=
"
#{
name
}
.podspec"
path
<<
'.json'
if
json
Specification
.
from_string
(
spec
,
path
)
when
Specification
spec
.
dup
else
raise
"Unknown spec type:
#{
spec
}
"
begin
spec
=
case
spec
when
Pathname
Specification
.
from_file
(
spec
)
when
String
path
=
"
#{
name
}
.podspec"
path
<<
'.json'
if
json
Specification
.
from_string
(
spec
,
path
)
when
Specification
spec
.
dup
else
raise
"Unknown spec type:
#{
spec
}
"
end
rescue
Pod
::
DSLError
=>
e
raise
Informative
,
"Failed to load '
#{
name
}
' podspec:
#{
e
.
message
}
"
end
spec
.
defined_in_file
=
nil
validate_podspec
(
spec
)
...
...
lib/cocoapods/sandbox/podspec_finder.rb
View file @
3a8cc9cf
...
...
@@ -12,13 +12,9 @@ module Pod
@specs_by_name
=
{}
spec_files
=
Pathname
.
glob
(
root
+
'{,*}.podspec{,.json}'
)
spec_files
.
sort_by
{
|
p
|
-
p
.
to_path
.
split
(
File
::
SEPARATOR
).
size
}.
each
do
|
file
|
begin
spec
=
Specification
.
from_file
(
file
)
spec
.
validate_cocoapods_version
@specs_by_name
[
spec
.
name
]
=
spec
rescue
=>
e
UI
.
warn
"Unable to load a podspec from `
#{
file
.
basename
}
`, skipping:
\n\n
#{
e
}
"
end
spec
=
Specification
.
from_file
(
file
)
spec
.
validate_cocoapods_version
@specs_by_name
[
spec
.
name
]
=
spec
end
@specs_by_name
end
...
...
spec/unit/external_sources/abstract_external_source_spec.rb
View file @
3a8cc9cf
...
...
@@ -26,6 +26,36 @@ module Pod
@subject
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
specification
(
'Reachability'
).
name
.
should
==
'Reachability'
end
it
'raises appropriate error if a DSLError was raised'
do
Downloader
.
stubs
(
:download
).
raises
(
Pod
::
DSLError
.
new
(
'Invalid `Reachability.podspec` file:'
,
'some/path/to/podspec'
,
Exception
.
new
(
'Error Message'
)))
should
.
raise
(
Informative
)
do
e
=
@subject
.
send
(
:pre_download
,
config
.
sandbox
)
e
.
message
.
should
.
include
"Failed to load 'Reachability' podspec:"
e
.
message
.
should
.
include
'Invalid `Reachability.podspec` file:'
end
end
it
'raises appropriate error if a DSLError when storing a podspec from string'
do
podspec
=
'Pod::Spec.new do |s|; error; end'
should
.
raise
(
Informative
)
{
@subject
.
send
(
:store_podspec
,
config
.
sandbox
,
podspec
)
}.
message
.
should
.
include
"Invalid `Reachability.podspec` file: undefined local variable or method `error'"
end
it
'raises appropriate error if a DSLError when storing a podspec from file'
do
podspec
=
'Pod::Spec.new do |s|; error; end'
path
=
SpecHelper
.
temporary_directory
+
'BananaLib.podspec'
File
.
open
(
path
,
'w'
)
{
|
f
|
f
.
write
(
podspec
)
}
should
.
raise
(
Informative
)
{
@subject
.
send
(
:store_podspec
,
config
.
sandbox
,
path
)
}.
message
.
should
.
include
"Invalid `BananaLib.podspec` file: undefined local variable or method `error'"
end
it
'raises a generic error if a podspec was not found'
do
Downloader
.
stubs
(
:download
).
raises
(
Pod
::
Downloader
::
DownloaderError
.
new
(
'Some generic exception'
))
should
.
raise
(
Informative
)
do
@subject
.
send
(
:pre_download
,
config
.
sandbox
).
message
.
should
==
"Unable to find a specification for 'Reachability'."
end
end
end
#--------------------------------------#
...
...
spec/unit/sandbox/podspec_finder_spec.rb
View file @
3a8cc9cf
...
...
@@ -15,12 +15,6 @@ module Pod
@finder
.
podspecs
.
should
.
be
.
empty
end
it
"warns when a found podspec can't be parsed"
do
@root
.
+
(
'RestKit.podspec.json'
).
open
(
'w'
)
{
|
f
|
f
<<
'{]'
}
@finder
.
podspecs
.
should
.
be
.
empty
UI
.
warnings
.
should
.
include
"Unable to load a podspec from `RestKit.podspec.json`, skipping:
\n\n
"
end
it
'ignores podspecs not in the root'
do
path
=
@root
+
'Dir/RestKit.podspec.json'
path
.
parent
.
mkpath
...
...
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