[flutter_plugin_tools] Add a command to lint Android code (#4206)

Adds a new `lint-android` command to run `gradlew lint` on Android plugins.

Also standardizes the names of the Cirrus tasks that run all the build and platform-specific (i.e., not Dart unit test) tests for each platform, as they were getting unnecessarily long and complex in some cases.

Fixes https://github.com/flutter/flutter/issues/87071
This commit is contained in:
stuartmorgan
2021-08-18 06:51:10 -07:00
committed by GitHub
parent 954804f68d
commit 721421a091
9 changed files with 495 additions and 40 deletions

View File

@ -6,6 +6,7 @@ import 'package:file/file.dart';
import 'package:platform/platform.dart';
import 'common/core.dart';
import 'common/gradle.dart';
import 'common/package_looping_command.dart';
import 'common/plugin_utils.dart';
import 'common/process_runner.dart';
@ -47,8 +48,6 @@ class NativeTestCommand extends PackageLoopingCommand {
help: 'Runs native integration (UI) tests', defaultsTo: true);
}
static const String _gradleWrapper = 'gradlew';
// The device destination flags for iOS tests.
List<String> _iosDestinationFlags = <String>[];
@ -243,9 +242,12 @@ this command.
final String exampleName = getPackageDescription(example);
_printRunningExampleTestsMessage(example, 'Android');
final Directory androidDirectory = example.childDirectory('android');
final File gradleFile = androidDirectory.childFile(_gradleWrapper);
if (!gradleFile.existsSync()) {
final GradleProject project = GradleProject(
example,
processRunner: processRunner,
platform: platform,
);
if (!project.isConfigured()) {
printError('ERROR: Run "flutter build apk" on $exampleName, or run '
'this tool\'s "build-examples --apk" command, '
'before executing tests.');
@ -256,9 +258,7 @@ this command.
if (runUnitTests) {
print('Running unit tests...');
final int exitCode = await processRunner.runAndStream(
gradleFile.path, <String>['testDebugUnitTest'],
workingDir: androidDirectory);
final int exitCode = await project.runCommand('testDebugUnitTest');
if (exitCode != 0) {
printError('$exampleName unit tests failed.');
failed = true;
@ -275,13 +275,12 @@ this command.
'notAnnotation=io.flutter.plugins.DartIntegrationTest';
print('Running integration tests...');
final int exitCode = await processRunner.runAndStream(
gradleFile.path,
<String>[
'app:connectedAndroidTest',
'-Pandroid.testInstrumentationRunnerArguments.$filter',
],
workingDir: androidDirectory);
final int exitCode = await project.runCommand(
'app:connectedAndroidTest',
arguments: <String>[
'-Pandroid.testInstrumentationRunnerArguments.$filter',
],
);
if (exitCode != 0) {
printError('$exampleName integration tests failed.');
failed = true;