[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

@ -9,6 +9,7 @@ import 'common/core.dart';
import 'common/package_looping_command.dart';
import 'common/plugin_utils.dart';
import 'common/process_runner.dart';
import 'common/pub_utils.dart';
import 'common/repository_package.dart';
/// A command to run Dart unit tests for packages.
@ -130,21 +131,16 @@ class DartTestCommand extends PackageLoopingCommand {
/// Runs the Dart tests for a non-Flutter package, returning true on success.
Future<bool> _runDartTests(RepositoryPackage package,
{String? platform}) async {
// Unlike `flutter test`, `pub run test` does not automatically get
// Unlike `flutter test`, `dart run test` does not automatically get
// packages
int exitCode = await processRunner.runAndStream(
'dart',
<String>['pub', 'get'],
workingDir: package.directory,
);
if (exitCode != 0) {
if (!await runPubGet(package, processRunner, super.platform)) {
printError('Unable to fetch dependencies.');
return false;
}
final String experiment = getStringArg(kEnableExperiment);
exitCode = await processRunner.runAndStream(
final int exitCode = await processRunner.runAndStream(
'dart',
<String>[
'run',