[tool] Use 'flutter pub get' for Flutter packages (#4397)

Extracts common logic for running `pub get`, and switches commands to use it. The common logic always uses `flutter pub get` for Flutter packages, rather than `dart pub get`, since the latter will fail if someone has a non-Flutter `dart` in their path before `flutter` (e.g., Dart team members contributing PRs).
This commit is contained in:
stuartmorgan
2023-07-07 16:22:19 -04:00
committed by GitHub
parent 958750d1fa
commit 12ec9fe3f0
11 changed files with 179 additions and 52 deletions

View File

@ -88,7 +88,7 @@ void main() {
final Iterable<ProcessCall> pubGetCalls =
plugin1.getExamples().map((RepositoryPackage example) {
return ProcessCall(
'dart',
getFlutterCommand(mockPlatform),
const <String>['pub', 'get'],
example.path,
);
@ -117,6 +117,7 @@ void main() {
createFakePlugin('plugin_tools_test_package_a', packagesDir);
processRunner.mockProcessesForExecutable['flutter'] = <FakeProcessInfo>[
FakeProcessInfo(MockProcess(), <String>['pub', 'get']),
FakeProcessInfo(MockProcess(exitCode: 1, stdout: 'Some error from pub'),
<String>['pub', 'publish'])
];
@ -205,7 +206,8 @@ void main() {
'Packages with an SDK constraint on a pre-release of the Dart '
'SDK should themselves be published as a pre-release version.');
processRunner.mockProcessesForExecutable['flutter'] = <FakeProcessInfo>[
FakeProcessInfo(process, <String>['pub', 'publish'])
FakeProcessInfo(MockProcess(), <String>['pub', 'get']),
FakeProcessInfo(process, <String>['pub', 'publish']),
];
expect(
@ -223,7 +225,8 @@ void main() {
'Packages with an SDK constraint on a pre-release of the Dart '
'SDK should themselves be published as a pre-release version.');
processRunner.mockProcessesForExecutable['flutter'] = <FakeProcessInfo>[
FakeProcessInfo(process, <String>['pub', 'publish'])
FakeProcessInfo(MockProcess(), <String>['pub', 'get']),
FakeProcessInfo(process, <String>['pub', 'publish']),
];
Error? commandError;
@ -247,6 +250,7 @@ void main() {
createFakePlugin('d', packagesDir);
processRunner.mockProcessesForExecutable['flutter'] = <FakeProcessInfo>[
FakeProcessInfo(MockProcess(), <String>['pub', 'get']),
FakeProcessInfo(MockProcess(stdout: 'Package has 0 warnings.'),
<String>['pub', 'publish']),
];