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
c9323bdc
Unverified
Commit
c9323bdc
authored
Mar 24, 2020
by
Jenn Magder
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert cocoapods_validator_test to testWithoutContext (#53177)
parent
70c651b0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
46 deletions
+42
-46
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+4
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+2
-0
cocoapod_utils.dart
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
+1
-2
cocoapods.dart
packages/flutter_tools/lib/src/macos/cocoapods.dart
+0
-3
cocoapods_validator.dart
...ages/flutter_tools/lib/src/macos/cocoapods_validator.dart
+20
-11
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+4
-6
macos_test.dart
...s/test/general.shard/build_system/targets/macos_test.dart
+0
-2
cocoapods_validator_test.dart
...ls/test/general.shard/macos/cocoapods_validator_test.dart
+11
-21
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
c9323bdc
...
...
@@ -106,7 +106,10 @@ Future<T> runInContext<T>(
platform:
globals
.
platform
,
),
CocoaPods:
()
=>
CocoaPods
(),
CocoaPodsValidator:
()
=>
const
CocoaPodsValidator
(),
CocoaPodsValidator:
()
=>
CocoaPodsValidator
(
globals
.
cocoaPods
,
globals
.
userMessages
,
),
Config:
()
=>
Config
(
Config
.
kFlutterSettings
,
fileSystem:
globals
.
fs
,
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
c9323bdc
...
...
@@ -28,6 +28,7 @@ import 'ios/ios_workflow.dart';
import
'ios/plist_parser.dart'
;
import
'ios/simulators.dart'
;
import
'ios/xcodeproj.dart'
;
import
'macos/cocoapods.dart'
;
import
'macos/xcode.dart'
;
import
'persistent_tool_state.dart'
;
import
'reporting/reporting.dart'
;
...
...
@@ -71,6 +72,7 @@ Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
AndroidStudio
get
androidStudio
=>
context
.
get
<
AndroidStudio
>();
AndroidSdk
get
androidSdk
=>
context
.
get
<
AndroidSdk
>();
CocoaPods
get
cocoaPods
=>
context
.
get
<
CocoaPods
>();
FlutterVersion
get
flutterVersion
=>
context
.
get
<
FlutterVersion
>();
FuchsiaArtifacts
get
fuchsiaArtifacts
=>
context
.
get
<
FuchsiaArtifacts
>();
IOSDeploy
get
iosDeploy
=>
context
.
get
<
IOSDeploy
>();
...
...
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
View file @
c9323bdc
...
...
@@ -10,7 +10,6 @@ import '../globals.dart' as globals;
import
'../ios/xcodeproj.dart'
;
import
'../plugins.dart'
;
import
'../project.dart'
;
import
'cocoapods.dart'
;
/// For a given build, determines whether dependencies have changed since the
/// last call to processPods, then calls processPods with that information.
...
...
@@ -33,7 +32,7 @@ Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject, String buildDir
properties:
<
String
,
String
>{},
);
final
bool
didPodInstall
=
await
cocoaPods
.
processPods
(
final
bool
didPodInstall
=
await
globals
.
cocoaPods
.
processPods
(
xcodeProject:
xcodeProject
,
engineDir:
flutterFrameworkDir
(
buildMode
),
dependenciesChanged:
!
fingerprinter
.
doesFingerprintMatch
(),
...
...
packages/flutter_tools/lib/src/macos/cocoapods.dart
View file @
c9323bdc
...
...
@@ -8,7 +8,6 @@ import 'package:file/file.dart';
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -45,8 +44,6 @@ const String cocoaPodsUpgradeInstructions = '''
const
String
podfileMigrationInstructions
=
'''
rm ios/Podfile'''
;
CocoaPods
get
cocoaPods
=>
context
.
get
<
CocoaPods
>();
/// Result of evaluating the CocoaPods installation.
enum
CocoaPodsStatus
{
/// iOS plugins will not work, installation required.
...
...
packages/flutter_tools/lib/src/macos/cocoapods_validator.dart
View file @
c9323bdc
...
...
@@ -12,42 +12,51 @@ import 'cocoapods.dart';
CocoaPodsValidator
get
cocoapodsValidator
=>
context
.
get
<
CocoaPodsValidator
>();
class
CocoaPodsValidator
extends
DoctorValidator
{
const
CocoaPodsValidator
()
:
super
(
'CocoaPods subvalidator'
);
CocoaPodsValidator
(
CocoaPods
cocoaPods
,
UserMessages
userMessages
,
)
:
_cocoaPods
=
cocoaPods
,
_userMessages
=
userMessages
,
super
(
'CocoaPods subvalidator'
);
final
CocoaPods
_cocoaPods
;
final
UserMessages
_userMessages
;
@override
Future
<
ValidationResult
>
validate
()
async
{
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
final
CocoaPodsStatus
cocoaPodsStatus
=
await
cocoaPods
.
evaluateCocoaPodsInstallation
;
final
CocoaPodsStatus
cocoaPodsStatus
=
await
_
cocoaPods
.
evaluateCocoaPodsInstallation
;
ValidationType
status
=
ValidationType
.
installed
;
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
recommended
)
{
if
(
await
cocoaPods
.
isCocoaPodsInitialized
)
{
messages
.
add
(
ValidationMessage
(
userMessages
.
cocoaPodsVersion
(
await
cocoaPods
.
cocoaPodsVersionText
)));
if
(
await
_
cocoaPods
.
isCocoaPodsInitialized
)
{
messages
.
add
(
ValidationMessage
(
_userMessages
.
cocoaPodsVersion
(
await
_
cocoaPods
.
cocoaPodsVersionText
)));
}
else
{
status
=
ValidationType
.
partial
;
messages
.
add
(
ValidationMessage
.
error
(
userMessages
.
cocoaPodsUninitialized
(
noCocoaPodsConsequence
)));
messages
.
add
(
ValidationMessage
.
error
(
_
userMessages
.
cocoaPodsUninitialized
(
noCocoaPodsConsequence
)));
}
}
else
{
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
notInstalled
)
{
status
=
ValidationType
.
missing
;
messages
.
add
(
ValidationMessage
.
error
(
userMessages
.
cocoaPodsMissing
(
noCocoaPodsConsequence
,
cocoaPodsInstallInstructions
)));
_userMessages
.
cocoaPodsMissing
(
noCocoaPodsConsequence
,
cocoaPodsInstallInstructions
)));
}
else
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
brokenInstall
)
{
status
=
ValidationType
.
missing
;
messages
.
add
(
ValidationMessage
.
error
(
userMessages
.
cocoaPodsBrokenInstall
(
brokenCocoaPodsConsequence
,
cocoaPodsInstallInstructions
)));
_
userMessages
.
cocoaPodsBrokenInstall
(
brokenCocoaPodsConsequence
,
cocoaPodsInstallInstructions
)));
}
else
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
unknownVersion
)
{
status
=
ValidationType
.
partial
;
messages
.
add
(
ValidationMessage
.
hint
(
userMessages
.
cocoaPodsUnknownVersion
(
unknownCocoaPodsConsequence
,
cocoaPodsUpgradeInstructions
)));
_
userMessages
.
cocoaPodsUnknownVersion
(
unknownCocoaPodsConsequence
,
cocoaPodsUpgradeInstructions
)));
}
else
{
status
=
ValidationType
.
partial
;
final
String
currentVersionText
=
await
cocoaPods
.
cocoaPodsVersionText
;
final
String
currentVersionText
=
await
_
cocoaPods
.
cocoaPodsVersionText
;
messages
.
add
(
ValidationMessage
.
hint
(
userMessages
.
cocoaPodsOutdated
(
currentVersionText
,
cocoaPods
.
cocoaPodsRecommendedVersion
,
noCocoaPodsConsequence
,
cocoaPodsUpgradeInstructions
)));
_userMessages
.
cocoaPodsOutdated
(
currentVersionText
,
_
cocoaPods
.
cocoaPodsRecommendedVersion
,
noCocoaPodsConsequence
,
cocoaPodsUpgradeInstructions
)));
}
}
...
...
packages/flutter_tools/lib/src/plugins.dart
View file @
c9323bdc
...
...
@@ -15,7 +15,6 @@ import 'convert.dart';
import
'dart/package_map.dart'
;
import
'features.dart'
;
import
'globals.dart'
as
globals
;
import
'macos/cocoapods.dart'
;
import
'platform_plugins.dart'
;
import
'project.dart'
;
import
'windows/property_sheet.dart'
;
...
...
@@ -1058,12 +1057,12 @@ void refreshPluginsList(FlutterProject project, {bool checkProjects = false}) {
if
(
changed
||
legacyChanged
)
{
createPluginSymlinks
(
project
,
force:
true
);
if
(!
checkProjects
||
project
.
ios
.
existsSync
())
{
cocoaPods
.
invalidatePodInstallOutput
(
project
.
ios
);
globals
.
cocoaPods
.
invalidatePodInstallOutput
(
project
.
ios
);
}
// TODO(stuartmorgan): Potentially add checkProjects once a decision has
// made about how to handle macOS in existing projects.
if
(
project
.
macos
.
existsSync
())
{
cocoaPods
.
invalidatePodInstallOutput
(
project
.
macos
);
globals
.
cocoaPods
.
invalidatePodInstallOutput
(
project
.
macos
);
}
}
}
...
...
@@ -1097,14 +1096,13 @@ Future<void> injectPlugins(FlutterProject project, {bool checkProjects = false})
}
for
(
final
XcodeBasedProject
subproject
in
<
XcodeBasedProject
>[
project
.
ios
,
project
.
macos
])
{
if
(!
project
.
isModule
&&
(!
checkProjects
||
subproject
.
existsSync
()))
{
final
CocoaPods
cocoaPods
=
CocoaPods
();
if
(
plugins
.
isNotEmpty
)
{
await
cocoaPods
.
setupPodfile
(
subproject
);
await
globals
.
cocoaPods
.
setupPodfile
(
subproject
);
}
/// The user may have a custom maintained Podfile that they're running `pod install`
/// on themselves.
else
if
(
subproject
.
podfile
.
existsSync
()
&&
subproject
.
podfileLock
.
existsSync
())
{
cocoaPods
.
addPodsDependencyToFlutterXcconfig
(
subproject
);
globals
.
cocoaPods
.
addPodsDependencyToFlutterXcconfig
(
subproject
);
}
}
}
...
...
packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
View file @
c9323bdc
...
...
@@ -9,7 +9,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import
'package:flutter_tools/src/build_system/targets/dart.dart'
;
import
'package:flutter_tools/src/build_system/targets/macos.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/macos/cocoapods.dart'
;
import
'package:flutter_tools/src/macos/xcode.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -193,7 +192,6 @@ void main() {
}
class
MockPlatform
extends
Mock
implements
Platform
{}
class
MockCocoaPods
extends
Mock
implements
CocoaPods
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockGenSnapshot
extends
Mock
implements
GenSnapshot
{}
class
MockXcode
extends
Mock
implements
Xcode
{}
...
...
packages/flutter_tools/test/general.shard/macos/cocoapods_validator_test.dart
View file @
c9323bdc
...
...
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/user_messages.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/macos/cocoapods.dart'
;
import
'package:flutter_tools/src/macos/cocoapods_validator.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
group
(
'CocoaPods validation'
,
()
{
...
...
@@ -22,44 +22,36 @@ void main() {
when
(
cocoaPods
.
cocoaPodsVersionText
).
thenAnswer
((
_
)
async
=>
'1.8.0'
);
});
test
Using
Context
(
'Emits installed status when CocoaPods is installed'
,
()
async
{
const
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
);
test
Without
Context
(
'Emits installed status when CocoaPods is installed'
,
()
async
{
final
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
cocoaPods
,
UserMessages
()
);
final
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
installed
);
},
overrides:
<
Type
,
Generator
>{
CocoaPods:
()
=>
cocoaPods
,
});
test
Using
Context
(
'Emits missing status when CocoaPods is not installed'
,
()
async
{
test
Without
Context
(
'Emits missing status when CocoaPods is not installed'
,
()
async
{
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
notInstalled
);
const
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
);
final
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
cocoaPods
,
UserMessages
()
);
final
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
},
overrides:
<
Type
,
Generator
>{
CocoaPods:
()
=>
cocoaPods
,
});
test
Using
Context
(
'Emits partial status when CocoaPods is installed with unknown version'
,
()
async
{
test
Without
Context
(
'Emits partial status when CocoaPods is installed with unknown version'
,
()
async
{
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
unknownVersion
);
const
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
);
final
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
cocoaPods
,
UserMessages
()
);
final
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
CocoaPods:
()
=>
cocoaPods
,
});
test
Using
Context
(
'Emits partial status when CocoaPods is not initialized'
,
()
async
{
test
Without
Context
(
'Emits partial status when CocoaPods is not initialized'
,
()
async
{
when
(
cocoaPods
.
isCocoaPodsInitialized
).
thenAnswer
((
_
)
async
=>
false
);
const
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
);
final
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
cocoaPods
,
UserMessages
()
);
final
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
CocoaPods:
()
=>
cocoaPods
,
});
test
Using
Context
(
'Emits partial status when CocoaPods version is too low'
,
()
async
{
test
Without
Context
(
'Emits partial status when CocoaPods version is too low'
,
()
async
{
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
belowRecommendedVersion
);
const
String
currentVersion
=
'1.4.0'
;
...
...
@@ -68,7 +60,7 @@ void main() {
const
String
recommendedVersion
=
'1.8.0'
;
when
(
cocoaPods
.
cocoaPodsRecommendedVersion
)
.
thenAnswer
((
_
)
=>
recommendedVersion
);
const
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
);
final
CocoaPodsValidator
workflow
=
CocoaPodsValidator
(
cocoaPods
,
UserMessages
()
);
final
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
expect
(
result
.
messages
.
length
,
1
);
...
...
@@ -76,8 +68,6 @@ void main() {
expect
(
message
.
type
,
ValidationMessageType
.
hint
);
expect
(
message
.
message
,
contains
(
'CocoaPods
$currentVersion
out of date'
));
expect
(
message
.
message
,
contains
(
'(
$recommendedVersion
is recommended)'
));
},
overrides:
<
Type
,
Generator
>{
CocoaPods:
()
=>
cocoaPods
,
});
});
}
...
...
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