mirror of
https://github.com/flutter/packages.git
synced 2025-06-09 22:35:33 +08:00
Switch script/tools over to the new analysis options (#3777)
Removes the legacy analysis options override and fixes all resulting issues. This is a combination of dart fix and manual changes (mostly mechanical, but some small restructuring to address warnings more cleanly, such as creating typed structs from args when they are used repeatedly to avoid repeated casting, or making things that were unnecessarily public private). One small opportunistic extra cleanup is that the handling of null-safety prerelease versions is removed, as any new plugin would be written null-safe from the start, so we no longer need to allow those versions. Part of flutter/flutter#76229
This commit is contained in:
@ -11,7 +11,9 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
/// A command to run tests via Firebase test lab.
|
||||
class FirebaseTestLabCommand extends PluginCommand {
|
||||
/// Creates an instance of the test runner command.
|
||||
FirebaseTestLabCommand(
|
||||
Directory packagesDir,
|
||||
FileSystem fileSystem, {
|
||||
@ -76,11 +78,11 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
'activate-service-account',
|
||||
'--key-file=${argResults['service-key']}',
|
||||
]);
|
||||
int exitCode = await processRunner.runAndStream('gcloud', <String>[
|
||||
final int exitCode = await processRunner.runAndStream('gcloud', <String>[
|
||||
'config',
|
||||
'set',
|
||||
'project',
|
||||
argResults['project'],
|
||||
argResults['project'] as String,
|
||||
]);
|
||||
if (exitCode == 0) {
|
||||
_print('\nFirebase project configured.');
|
||||
@ -93,8 +95,7 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> run() async {
|
||||
checkSharding();
|
||||
Future<void> run() async {
|
||||
final Stream<Directory> packagesWithTests = getPackages().where(
|
||||
(Directory d) =>
|
||||
isFlutterPackage(d, fileSystem) &&
|
||||
@ -107,7 +108,7 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
final List<String> missingFlutterBuild = <String>[];
|
||||
int resultsCounter =
|
||||
0; // We use a unique GCS bucket for each Firebase Test Lab run
|
||||
await for (Directory package in packagesWithTests) {
|
||||
await for (final Directory package in packagesWithTests) {
|
||||
// See https://github.com/flutter/flutter/issues/38983
|
||||
|
||||
final Directory exampleDirectory =
|
||||
@ -119,7 +120,7 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
final Directory androidDirectory =
|
||||
fileSystem.directory(p.join(exampleDirectory.path, 'android'));
|
||||
|
||||
final String enableExperiment = argResults[kEnableExperiment];
|
||||
final String enableExperiment = argResults[kEnableExperiment] as String;
|
||||
final String encodedEnableExperiment =
|
||||
Uri.encodeComponent('--enable-experiment=$enableExperiment');
|
||||
|
||||
@ -166,16 +167,18 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
// Look for tests recursively in folders that start with 'test' and that
|
||||
// live in the root or example folders.
|
||||
bool isTestDir(FileSystemEntity dir) {
|
||||
return p.basename(dir.path).startsWith('test') ||
|
||||
p.basename(dir.path) == 'integration_test';
|
||||
return dir is Directory &&
|
||||
(p.basename(dir.path).startsWith('test') ||
|
||||
p.basename(dir.path) == 'integration_test');
|
||||
}
|
||||
|
||||
final List<FileSystemEntity> testDirs =
|
||||
package.listSync().where(isTestDir).toList();
|
||||
final List<Directory> testDirs =
|
||||
package.listSync().where(isTestDir).cast<Directory>().toList();
|
||||
final Directory example =
|
||||
fileSystem.directory(p.join(package.path, 'example'));
|
||||
testDirs.addAll(example.listSync().where(isTestDir).toList());
|
||||
for (Directory testDir in testDirs) {
|
||||
testDirs.addAll(
|
||||
example.listSync().where(isTestDir).cast<Directory>().toList());
|
||||
for (final Directory testDir in testDirs) {
|
||||
bool isE2ETest(FileSystemEntity file) {
|
||||
return file.path.endsWith('_e2e.dart') ||
|
||||
(file.parent.basename == 'integration_test' &&
|
||||
@ -186,7 +189,7 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
.listSync(recursive: true, followLinks: true)
|
||||
.where(isE2ETest)
|
||||
.toList();
|
||||
for (FileSystemEntity test in testFiles) {
|
||||
for (final FileSystemEntity test in testFiles) {
|
||||
exitCode = await processRunner.runAndStream(
|
||||
p.join(androidDirectory.path, _gradleWrapper),
|
||||
<String>[
|
||||
@ -205,7 +208,7 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
continue;
|
||||
}
|
||||
final String buildId = io.Platform.environment['CIRRUS_BUILD_ID'];
|
||||
final String testRunId = argResults['test-run-id'];
|
||||
final String testRunId = argResults['test-run-id'] as String;
|
||||
final String resultsDir =
|
||||
'plugins_android_test/$packageName/$buildId/$testRunId/${resultsCounter++}/';
|
||||
final List<String> args = <String>[
|
||||
@ -222,9 +225,9 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
'--timeout',
|
||||
'5m',
|
||||
'--results-bucket=${argResults['results-bucket']}',
|
||||
'--results-dir=${resultsDir}',
|
||||
'--results-dir=$resultsDir',
|
||||
];
|
||||
for (String device in argResults['device']) {
|
||||
for (final String device in argResults['device'] as List<String>) {
|
||||
args.addAll(<String>['--device', device]);
|
||||
}
|
||||
exitCode = await processRunner.runAndStream('gcloud', args,
|
||||
@ -243,14 +246,14 @@ class FirebaseTestLabCommand extends PluginCommand {
|
||||
_print(
|
||||
'The instrumentation tests for the following packages are failing (see above for'
|
||||
'details):');
|
||||
for (String package in failingPackages) {
|
||||
for (final String package in failingPackages) {
|
||||
_print(' * $package');
|
||||
}
|
||||
}
|
||||
if (missingFlutterBuild.isNotEmpty) {
|
||||
_print('Run "pub global run flutter_plugin_tools build-examples --apk" on'
|
||||
'the following packages before executing tests again:');
|
||||
for (String package in missingFlutterBuild) {
|
||||
for (final String package in missingFlutterBuild) {
|
||||
_print(' * $package');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user