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
7a2fb00c
Commit
7a2fb00c
authored
Oct 25, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Add spec for testing that pods are importable
parent
e7386e9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
4 deletions
+116
-4
validator.rb
lib/cocoapods/validator.rb
+9
-4
validator_spec.rb
spec/unit/validator_spec.rb
+107
-0
No files found.
lib/cocoapods/validator.rb
View file @
7a2fb00c
...
...
@@ -380,6 +380,14 @@ module Pod
def
add_app_project_import
app_project
=
Xcodeproj
::
Project
.
open
(
validation_dir
+
'App.xcodeproj'
)
pod_target
=
@installer
.
pod_targets
.
find
{
|
pt
|
pt
.
pod_name
==
spec
.
root
.
name
}
source_file
=
write_app_import_source_file
(
pod_target
)
source_file_ref
=
app_project
.
new_group
(
'App'
,
'App'
).
new_file
(
source_file
)
app_project
.
targets
.
first
.
add_file_references
([
source_file_ref
])
app_project
.
save
end
def
write_app_import_source_file
(
pod_target
)
language
=
pod_target
.
uses_swift?
?
:
swift
:
:objc
if
language
==
:swift
...
...
@@ -402,10 +410,7 @@ module Pod
end
source_file
.
open
(
'w'
)
{
|
f
|
f
<<
"@import Foundation;
\n
#{
import_statement
}
int main() {}
\n
"
}
end
source_file_ref
=
app_project
.
new_group
(
'App'
,
'App'
).
new_file
(
source_file
)
app_project
.
targets
.
first
.
add_file_references
([
source_file_ref
])
app_project
.
save
source_file
end
# It creates a podfile in memory and builds a library containing the pod
...
...
spec/unit/validator_spec.rb
View file @
7a2fb00c
...
...
@@ -445,6 +445,113 @@ module Pod
validator
.
results
.
count
.
should
==
0
end
describe
'import validation'
do
before
do
@validator
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
))
@validator
.
stubs
(
:validate_url
)
@consumer
=
Specification
.
from_file
(
podspec_path
).
consumer
(
:ios
)
@validator
.
instance_variable_set
(
:@consumer
,
@consumer
)
@validator
.
send
(
:setup_validation_environment
)
end
after
do
@validator
.
send
(
:tear_down_validation_environment
)
end
it
'creates an empty app project & target to integrate into'
do
@validator
.
send
(
:create_app_project
)
project
=
Xcodeproj
::
Project
.
open
(
@validator
.
validation_dir
+
'App.xcodeproj'
)
target
=
project
.
native_targets
.
find
{
|
t
|
t
.
name
==
'App'
}
target
.
should
.
not
.
be
.
nil
target
.
symbol_type
.
should
==
:application
target
.
deployment_target
.
should
.
be
.
nil
target
.
platform_name
.
should
==
:ios
Xcodeproj
::
Project
.
schemes
(
project
.
path
).
should
==
%w(App)
end
describe
'creating the importing file'
do
describe
'when linting as a framework'
do
before
do
@validator
.
stubs
(
:use_frameworks
).
returns
(
true
)
end
it
'creates a swift import'
do
pod_target
=
stub
(
:uses_swift?
=>
true
,
:product_module_name
=>
'ModuleName'
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.swift'
file
.
read
.
should
==
<<-
SWIFT
.
strip_heredoc
import ModuleName
SWIFT
end
it
'creates an objective-c import'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.m'
file
.
read
.
should
==
<<-
OBJC
.
strip_heredoc
@import Foundation;
@import ModuleName;
int main() {}
OBJC
end
end
describe
'when linting as a static lib'
do
before
do
@validator
.
stubs
(
:use_frameworks
).
returns
(
false
)
@sandbox
=
config
.
sandbox
end
it
'creates an objective-c import when a plausible umbrella header is found'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
header_name
=
"
#{
pod_target
.
product_module_name
}
/
#{
pod_target
.
product_module_name
}
.h"
umbrella
=
pod_target
.
sandbox
.
public_headers
.
root
.
+
(
header_name
)
umbrella
.
dirname
.
mkpath
umbrella
.
open
(
'w'
)
{}
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.m'
file
.
read
.
should
==
<<-
OBJC
.
strip_heredoc
@import Foundation;
#import <ModuleName/ModuleName.h>
int main() {}
OBJC
end
it
'does not create an objective-c import when no umbrella header is found'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.m'
file
.
read
.
should
==
<<-
OBJC
.
strip_heredoc
@import Foundation;
int main() {}
OBJC
end
end
end
it
'adds the importing file to the app target'
do
@validator
.
stubs
(
:use_frameworks
).
returns
(
true
)
@validator
.
send
(
:create_app_project
)
pod_target
=
stub
(
:uses_swift?
=>
true
,
:pod_name
=>
'JSONKit'
,
:product_module_name
=>
'ModuleName'
)
installer
=
stub
(
:pod_targets
=>
[
pod_target
])
@validator
.
instance_variable_set
(
:@installer
,
installer
)
@validator
.
send
(
:add_app_project_import
)
project
=
Xcodeproj
::
Project
.
open
(
@validator
.
validation_dir
+
'App.xcodeproj'
)
group
=
project
[
'App'
]
file
=
group
.
find_file_by_path
(
'main.swift'
)
file
.
should
.
not
.
be
.
nil
target
=
project
.
native_targets
.
find
{
|
t
|
t
.
name
==
'App'
}
target
.
source_build_phase
.
files_references
.
should
.
include
(
file
)
end
end
describe
'file pattern validation'
do
it
'checks for file patterns'
do
file
=
write_podspec
(
stub_podspec
(
/.*source_files.*/
,
'"source_files": "wrong_paht.*",'
))
...
...
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