Enable developers to run pod from terminal directly and skip pod install if possible. (#13374)
Avoids running pod install if .flutter-plugins and its flutter framework pod dependency didn't change
This commit is contained in:
@@ -41,7 +41,7 @@ void main() {
|
||||
when(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
)).thenReturn(exitsHappy);
|
||||
});
|
||||
|
||||
@@ -50,13 +50,12 @@ void main() {
|
||||
() async {
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
iosEngineDir: 'engine/path',
|
||||
);
|
||||
expect(fs.file(fs.path.join('project', 'ios', 'Podfile')).readAsStringSync() , 'Objective-C podfile template');
|
||||
verify(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
@@ -70,14 +69,13 @@ void main() {
|
||||
() async {
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
iosEngineDir: 'engine/path',
|
||||
isSwift: true,
|
||||
);
|
||||
expect(fs.file(fs.path.join('project', 'ios', 'Podfile')).readAsStringSync() , 'Swift podfile template');
|
||||
verify(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
@@ -94,12 +92,11 @@ void main() {
|
||||
..writeAsString('Existing Podfile');
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
iosEngineDir: 'engine/path',
|
||||
); expect(fs.file(fs.path.join('project', 'ios', 'Podfile')).readAsStringSync() , 'Existing Podfile');
|
||||
verify(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
@@ -115,14 +112,13 @@ void main() {
|
||||
try {
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
iosEngineDir: 'engine/path',
|
||||
);
|
||||
fail('Expected tool error');
|
||||
} catch (ToolExit) {
|
||||
verifyNever(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
}
|
||||
},
|
||||
@@ -142,7 +138,7 @@ void main() {
|
||||
when(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
)).thenReturn(new ProcessResult(
|
||||
1,
|
||||
1,
|
||||
@@ -165,7 +161,6 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
|
||||
try {
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
iosEngineDir: 'engine/path',
|
||||
); expect(fs.file(fs.path.join('project', 'ios', 'Podfile')).readAsStringSync() , 'Existing Podfile');
|
||||
fail('Exception expected');
|
||||
} catch (ToolExit) {
|
||||
@@ -177,6 +172,62 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
|
||||
ProcessManager: () => mockProcessManager,
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'Run pod install if plugins or flutter framework have changes.',
|
||||
() async {
|
||||
fs.file(fs.path.join('project', 'ios', 'Podfile'))
|
||||
..createSync()
|
||||
..writeAsString('Existing Podfile');
|
||||
fs.file(fs.path.join('project', 'ios', 'Podfile.lock'))
|
||||
..createSync()
|
||||
..writeAsString('Existing lock files.');
|
||||
fs.file(fs.path.join('project', 'ios', 'Pods','Manifest.lock'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsString('Existing lock files.');
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
pluginOrFlutterPodChanged: true
|
||||
);
|
||||
verify(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'Skip pod install if plugins and flutter framework remain unchanged.',
|
||||
() async {
|
||||
fs.file(fs.path.join('project', 'ios', 'Podfile'))
|
||||
..createSync()
|
||||
..writeAsString('Existing Podfile');
|
||||
fs.file(fs.path.join('project', 'ios', 'Podfile.lock'))
|
||||
..createSync()
|
||||
..writeAsString('Existing lock files.');
|
||||
fs.file(fs.path.join('project', 'ios', 'Pods','Manifest.lock'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsString('Existing lock files.');
|
||||
await cocoaPodsUnderTest.processPods(
|
||||
appIosDir: projectUnderTest,
|
||||
pluginOrFlutterPodChanged: false
|
||||
);
|
||||
verifyNever(mockProcessManager.run(
|
||||
<String>['pod', 'install', '--verbose'],
|
||||
workingDirectory: 'project/ios',
|
||||
environment: <String, String>{'COCOAPODS_DISABLE_STATS': 'true'},
|
||||
));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class MockProcessManager extends Mock implements ProcessManager {}
|
||||
|
||||
Reference in New Issue
Block a user