[flutter_plugin_tools] Make having no Java unit tests a failure (#4310)

This brings the native Android unit tests in line with the policy of having tests that we expect all plugins to have—unless there's a very specific reason to opt them out—fail when missing instead of skipping when missing, to help guard against errors where we silently fail to run tests we think we are running.

Adds an explicit exclusion list covering the plugins that have a reason to be opted out.

Android portion of flutter/flutter#85469
This commit is contained in:
stuartmorgan
2021-09-10 16:07:16 -04:00
committed by GitHub
parent 4ea49f8625
commit 188d56248a
3 changed files with 106 additions and 11 deletions

View File

@ -242,7 +242,8 @@ this command.
final Iterable<RepositoryPackage> examples = plugin.getExamples();
bool ranTests = false;
bool ranUnitTests = false;
bool ranAnyTests = false;
bool failed = false;
bool hasMissingBuild = false;
for (final RepositoryPackage example in examples) {
@ -289,7 +290,8 @@ this command.
printError('$exampleName unit tests failed.');
failed = true;
}
ranTests = true;
ranUnitTests = true;
ranAnyTests = true;
}
if (runIntegrationTests) {
@ -311,7 +313,7 @@ this command.
printError('$exampleName integration tests failed.');
failed = true;
}
ranTests = true;
ranAnyTests = true;
}
}
@ -321,7 +323,12 @@ this command.
? 'Examples must be built before testing.'
: null);
}
if (!ranTests) {
if (!mode.integrationOnly && !ranUnitTests) {
printError('No unit tests ran. Plugins are required to have unit tests.');
return _PlatformResult(RunState.failed,
error: 'No unit tests ran (use --exclude if this is intentional).');
}
if (!ranAnyTests) {
return _PlatformResult(RunState.skipped);
}
return _PlatformResult(RunState.succeeded);