[flutter_plugin_tools] Run pub get for custom-test (#5322)

When running a Dart test script for `custom-test`, `pub get` needs to be
run first in order for it to work in a clean environment such as CI.

This will unblock enabling Pigeon's Dart tests in flutter/packages.
This commit is contained in:
stuartmorgan
2022-04-21 16:08:21 -04:00
committed by GitHub
parent 57e6a62dc8
commit cc32f688bb
4 changed files with 59 additions and 6 deletions

View File

@ -43,10 +43,19 @@ class CustomTestCommand extends PackageLoopingCommand {
// Run the custom Dart script if presest.
if (script.existsSync()) {
final int exitCode = await processRunner.runAndStream(
// Ensure that dependencies are available.
final int pubGetExitCode = await processRunner.runAndStream(
'dart', <String>['pub', 'get'],
workingDir: package.directory);
if (pubGetExitCode != 0) {
return PackageResult.fail(
<String>['Unable to get script dependencies']);
}
final int testExitCode = await processRunner.runAndStream(
'dart', <String>['run', 'tool/$_scriptName'],
workingDir: package.directory);
if (exitCode != 0) {
if (testExitCode != 0) {
return PackageResult.fail();
}
ranTests = true;