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
91eaa5f7
Commit
91eaa5f7
authored
Apr 17, 2016
by
Orta Therox
Committed by
Samuel Giddins
Apr 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for multiple tests inside a target
parent
7010d7f4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
9 deletions
+48
-9
init.rb
lib/cocoapods/command/init.rb
+10
-9
init_spec.rb
spec/functional/command/init_spec.rb
+38
-0
No files found.
lib/cocoapods/command/init.rb
View file @
91eaa5f7
...
@@ -68,31 +68,32 @@ module Pod
...
@@ -68,31 +68,32 @@ module Pod
# Create an array of [app, (optional)test] target pairs
# Create an array of [app, (optional)test] target pairs
app_test_pairs
=
all_app_targets
.
map
do
|
target
|
app_test_pairs
=
all_app_targets
.
map
do
|
target
|
test
=
all_tests_targets
.
find
{
|
t
|
t
.
name
.
start_with?
target
.
name
}
test
=
all_tests_targets
.
select
{
|
t
|
t
.
name
.
start_with?
target
.
name
}
[
target
,
test
].
compact
[
target
,
*
test
].
compact
end
end
app_test_pairs
.
each
do
|
target_pair
|
app_test_pairs
.
each
do
|
target_pair
|
podfile
<<
target_module
(
target_pair
)
podfile
<<
target_module
(
target_pair
)
end
end
podfile
end
end
# @param [[Xcodeproj::PBXTarget]] targets
# @param [[Xcodeproj::PBXTarget]] targets
# An array which always has a target as it's first item
# An array which always has a target as it's first item
# and may optionally contain
a second target as its test target
# and may optionally contain
related test targets
#
#
# @return [String] the text for the target module
# @return [String] the text for the target module
#
#
def
target_module
(
targets
)
def
target_module
(
targets
)
app
=
targets
.
first
app
=
targets
.
first
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
)
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
,
"Pods for
#{
app
.
name
}
\n
"
)
test
=
targets
[
1
]
targets
[
1
..-
1
].
each
do
|
test
|
if
test
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
)
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
,
"Pods for testing"
)
target_module
<<
"
\n
end
\n
"
target_module
<<
"
\n
end
\n
"
end
end
...
@@ -105,11 +106,11 @@ module Pod
...
@@ -105,11 +106,11 @@ module Pod
#
#
# @return [String] the text for the target module
# @return [String] the text for the target module
#
#
def
template_contents
(
path
,
prefix
)
def
template_contents
(
path
,
prefix
,
fallback
)
if
path
.
exist?
if
path
.
exist?
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
prefix
}#{
line
}
"
}.
join
(
"
\n
"
)
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
prefix
}#{
line
}
"
}.
join
(
"
\n
"
)
else
else
''
"
#{
prefix
}
#
#{
fallback
}
"
end
end
end
end
end
end
...
...
spec/functional/command/init_spec.rb
View file @
91eaa5f7
...
@@ -86,6 +86,44 @@ module Pod
...
@@ -86,6 +86,44 @@ module Pod
end
end
end
end
fit
'handles hooking up mulitple test targets based on an xcodeproj project'
do
Dir
.
chdir
(
temporary_directory
)
do
project
=
Xcodeproj
::
Project
.
new
(
temporary_directory
+
'test.xcodeproj'
)
project
.
new_target
(
:application
,
'App'
,
:ios
)
project
.
new_target
(
:application
,
'AppTests'
,
:ios
)
project
.
new_target
(
:application
,
"AppFeatureTests"
,
:ios
)
project
.
save
run_command
(
'init'
)
podfile_text
=
File
.
read
(
temporary_directory
+
"Podfile"
)
podfile_exact
=
<<-
PODFILE
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'App' do
# Pods for App
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
target 'AppFeatureTests' do
inherit! :search_paths
# Pods for testing
end
end
PODFILE
podfile_text
.
should
==
podfile_exact
end
end
it
'includes default test pods in test targets in a Podfile'
do
it
'includes default test pods in test targets in a Podfile'
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
tmp_templates_dir
=
Pathname
.
pwd
+
'templates_dir'
tmp_templates_dir
=
Pathname
.
pwd
+
'templates_dir'
...
...
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