Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
86389be6
Unverified
Commit
86389be6
authored
Mar 25, 2020
by
Jenn Magder
Committed by
GitHub
Mar 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert CocoaPods tests to testWithoutContext (#53291)
parent
ff20bb8c
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
121 deletions
+104
-121
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+8
-1
cocoapods.dart
packages/flutter_tools/lib/src/macos/cocoapods.dart
+53
-26
cocoapods_test.dart
...lutter_tools/test/general.shard/macos/cocoapods_test.dart
+43
-94
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
86389be6
...
...
@@ -104,7 +104,14 @@ Future<T> runInContext<T>(
operatingSystemUtils:
globals
.
os
,
platform:
globals
.
platform
,
),
CocoaPods:
()
=>
CocoaPods
(),
CocoaPods:
()
=>
CocoaPods
(
fileSystem:
globals
.
fs
,
processManager:
globals
.
processManager
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
xcodeProjectInterpreter:
globals
.
xcodeProjectInterpreter
,
timeoutConfiguration:
timeoutConfiguration
,
),
CocoaPodsValidator:
()
=>
CocoaPodsValidator
(
globals
.
cocoaPods
,
globals
.
userMessages
,
...
...
packages/flutter_tools/lib/src/macos/cocoapods.dart
View file @
86389be6
...
...
@@ -6,6 +6,8 @@ import 'dart:async';
import
'package:file/file.dart'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
...
...
@@ -14,7 +16,7 @@ import '../base/logger.dart';
import
'../base/process.dart'
;
import
'../base/version.dart'
;
import
'../cache.dart'
;
import
'../
globals.dart'
as
globals
;
import
'../
ios/xcodeproj.dart'
;
import
'../project.dart'
;
const
String
noCocoaPodsConsequence
=
'''
...
...
@@ -62,16 +64,41 @@ enum CocoaPodsStatus {
}
class
CocoaPods
{
CocoaPods
({
@required
FileSystem
fileSystem
,
@required
ProcessManager
processManager
,
@required
XcodeProjectInterpreter
xcodeProjectInterpreter
,
@required
Logger
logger
,
@required
Platform
platform
,
@required
TimeoutConfiguration
timeoutConfiguration
,
})
:
_fileSystem
=
fileSystem
,
_processManager
=
processManager
,
_xcodeProjectInterpreter
=
xcodeProjectInterpreter
,
_logger
=
logger
,
_platform
=
platform
,
_processUtils
=
ProcessUtils
(
processManager:
processManager
,
logger:
logger
),
_fileSystemUtils
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
),
_timeoutConfiguration
=
timeoutConfiguration
;
final
FileSystem
_fileSystem
;
final
ProcessManager
_processManager
;
final
FileSystemUtils
_fileSystemUtils
;
final
ProcessUtils
_processUtils
;
final
XcodeProjectInterpreter
_xcodeProjectInterpreter
;
final
Logger
_logger
;
final
Platform
_platform
;
final
TimeoutConfiguration
_timeoutConfiguration
;
Future
<
String
>
_versionText
;
String
get
cocoaPodsMinimumVersion
=>
'1.6.0'
;
String
get
cocoaPodsRecommendedVersion
=>
'1.8.0'
;
Future
<
bool
>
get
isInstalled
=>
globals
.
processUtils
.
exitsHappy
(<
String
>[
'which'
,
'pod'
]);
_
processUtils
.
exitsHappy
(<
String
>[
'which'
,
'pod'
]);
Future
<
String
>
get
cocoaPodsVersionText
{
_versionText
??=
globals
.
processUtils
.
run
(
_versionText
??=
_
processUtils
.
run
(
<
String
>[
'pod'
,
'--version'
],
environment:
<
String
,
String
>{
'LANG'
:
'en_US.UTF-8'
,
...
...
@@ -124,9 +151,9 @@ class CocoaPods {
if
(
installedVersion
!=
null
&&
installedVersion
>=
Version
.
parse
(
'1.8.0'
))
{
return
true
;
}
final
String
cocoapodsReposDir
=
globals
.
platform
.
environment
[
'CP_REPOS_DIR'
]
??
globals
.
fs
.
path
.
join
(
globals
.
fs
Utils
.
homeDirPath
,
'.cocoapods'
,
'repos'
);
return
globals
.
fs
.
isDirectory
(
globals
.
fs
.
path
.
join
(
cocoapodsReposDir
,
'master'
));
final
String
cocoapodsReposDir
=
_
platform
.
environment
[
'CP_REPOS_DIR'
]
??
_fileSystem
.
path
.
join
(
_fileSystem
Utils
.
homeDirPath
,
'.cocoapods'
,
'repos'
);
return
_fileSystem
.
isDirectory
(
_fileSystem
.
path
.
join
(
cocoapodsReposDir
,
'master'
));
}
Future
<
bool
>
processPods
({
...
...
@@ -155,7 +182,7 @@ class CocoaPods {
final
CocoaPodsStatus
installation
=
await
evaluateCocoaPodsInstallation
;
switch
(
installation
)
{
case
CocoaPodsStatus
.
notInstalled
:
globals
.
printError
(
_logger
.
printError
(
'Warning: CocoaPods not installed. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To install:
\n
'
...
...
@@ -164,7 +191,7 @@ class CocoaPods {
);
return
false
;
case
CocoaPodsStatus
.
brokenInstall
:
globals
.
printError
(
_logger
.
printError
(
'Warning: CocoaPods is installed but broken. Skipping pod install.
\n
'
'
$brokenCocoaPodsConsequence
\n
'
'To re-install:
\n
'
...
...
@@ -173,7 +200,7 @@ class CocoaPods {
);
return
false
;
case
CocoaPodsStatus
.
unknownVersion
:
globals
.
printError
(
_logger
.
printError
(
'Warning: Unknown CocoaPods version installed.
\n
'
'
$unknownCocoaPodsConsequence
\n
'
'To upgrade:
\n
'
...
...
@@ -182,7 +209,7 @@ class CocoaPods {
);
break
;
case
CocoaPodsStatus
.
belowMinimumVersion
:
globals
.
printError
(
_logger
.
printError
(
'Warning: CocoaPods minimum required version
$cocoaPodsMinimumVersion
or greater not installed. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To upgrade:
\n
'
...
...
@@ -191,7 +218,7 @@ class CocoaPods {
);
return
false
;
case
CocoaPodsStatus
.
belowRecommendedVersion
:
globals
.
printError
(
_logger
.
printError
(
'Warning: CocoaPods recommended version
$cocoaPodsRecommendedVersion
or greater not installed.
\n
'
'Pods handling may fail on some projects involving plugins.
\n
'
'To upgrade:
\n
'
...
...
@@ -203,7 +230,7 @@ class CocoaPods {
break
;
}
if
(!
await
isCocoaPodsInitialized
)
{
globals
.
printError
(
_logger
.
printError
(
'Warning: CocoaPods installed but not initialized. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To initialize CocoaPods, run:
\n
'
...
...
@@ -221,7 +248,7 @@ class CocoaPods {
/// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files
/// include pods configuration.
Future
<
void
>
setupPodfile
(
XcodeBasedProject
xcodeProject
)
async
{
if
(!
globals
.
xcodeProjectInterpreter
.
isInstalled
)
{
if
(!
_
xcodeProjectInterpreter
.
isInstalled
)
{
// Don't do anything for iOS when host platform doesn't support it.
return
;
}
...
...
@@ -238,13 +265,13 @@ class CocoaPods {
if
(
xcodeProject
is
MacOSProject
)
{
podfileTemplateName
=
'Podfile-macos'
;
}
else
{
final
bool
isSwift
=
(
await
globals
.
xcodeProjectInterpreter
.
getBuildSettings
(
final
bool
isSwift
=
(
await
_
xcodeProjectInterpreter
.
getBuildSettings
(
runnerProject
.
path
,
'Runner'
,
)).
containsKey
(
'SWIFT_VERSION'
);
podfileTemplateName
=
isSwift
?
'Podfile-ios-swift'
:
'Podfile-ios-objc'
;
}
final
File
podfileTemplate
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
final
File
podfileTemplate
=
_fileSystem
.
file
(
_fileSystem
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
,
...
...
@@ -305,10 +332,10 @@ class CocoaPods {
}
Future
<
void
>
_runPodInstall
(
XcodeBasedProject
xcodeProject
,
String
engineDirectory
)
async
{
final
Status
status
=
globals
.
logger
.
startProgress
(
'Running pod install...'
,
timeout:
timeoutConfiguration
.
slowOperation
);
final
ProcessResult
result
=
await
globals
.
processManager
.
run
(
final
Status
status
=
_logger
.
startProgress
(
'Running pod install...'
,
timeout:
_
timeoutConfiguration
.
slowOperation
);
final
ProcessResult
result
=
await
_
processManager
.
run
(
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
workingDirectory:
globals
.
fs
.
path
.
dirname
(
xcodeProject
.
podfile
.
path
),
workingDirectory:
_fileSystem
.
path
.
dirname
(
xcodeProject
.
podfile
.
path
),
environment:
<
String
,
String
>{
'FLUTTER_FRAMEWORK_DIR'
:
engineDirectory
,
// See https://github.com/flutter/flutter/issues/10873.
...
...
@@ -318,16 +345,16 @@ class CocoaPods {
},
);
status
.
stop
();
if
(
globals
.
logger
.
isVerbose
||
result
.
exitCode
!=
0
)
{
if
(
_
logger
.
isVerbose
||
result
.
exitCode
!=
0
)
{
final
String
stdout
=
result
.
stdout
as
String
;
if
(
stdout
.
isNotEmpty
)
{
globals
.
printStatus
(
"CocoaPods' output:
\n
↳"
);
globals
.
printStatus
(
stdout
,
indent:
4
);
_logger
.
printStatus
(
"CocoaPods' output:
\n
↳"
);
_logger
.
printStatus
(
stdout
,
indent:
4
);
}
final
String
stderr
=
result
.
stderr
as
String
;
if
(
stderr
.
isNotEmpty
)
{
globals
.
printStatus
(
'Error output from CocoaPods:
\n
↳'
);
globals
.
printStatus
(
stderr
,
indent:
4
);
_logger
.
printStatus
(
'Error output from CocoaPods:
\n
↳'
);
_logger
.
printStatus
(
stderr
,
indent:
4
);
}
}
if
(
result
.
exitCode
!=
0
)
{
...
...
@@ -340,7 +367,7 @@ class CocoaPods {
void
_diagnosePodInstallFailure
(
ProcessResult
result
)
{
final
dynamic
stdout
=
result
.
stdout
;
if
(
stdout
is
String
&&
stdout
.
contains
(
'out-of-date source repos'
))
{
globals
.
printError
(
_logger
.
printError
(
"Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
\n
"
'To update the CocoaPods specs, run:
\n
'
' pod repo update
\n
'
,
...
...
@@ -360,12 +387,12 @@ class CocoaPods {
if
(
xcodeProject
is
!
IosProject
)
{
return
;
}
final
Link
flutterSymlink
=
globals
.
fs
.
link
(
globals
.
fs
.
path
.
join
(
final
Link
flutterSymlink
=
_fileSystem
.
link
(
_fileSystem
.
path
.
join
(
xcodeProject
.
symlinks
.
path
,
'flutter'
,
));
if
(
flutterSymlink
.
existsSync
())
{
globals
.
printError
(
_logger
.
printError
(
'Warning: Podfile is out of date
\n
'
'
$outOfDatePodfileConsequence
\n
'
'To regenerate the Podfile, run:
\n
'
...
...
packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
View file @
86389be6
This diff is collapsed.
Click to expand it.
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