mirror of
https://github.com/flutter/packages.git
synced 2025-08-24 03:18:54 +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:
@ -8,7 +8,9 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:platform/platform.dart';
|
||||
import 'common.dart';
|
||||
|
||||
/// A command to run the example applications for packages via Flutter driver.
|
||||
class DriveExamplesCommand extends PluginCommand {
|
||||
/// Creates an instance of the drive command.
|
||||
DriveExamplesCommand(
|
||||
Directory packagesDir,
|
||||
FileSystem fileSystem, {
|
||||
@ -48,20 +50,19 @@ class DriveExamplesCommand extends PluginCommand {
|
||||
'integration_test/*_test.dart.';
|
||||
|
||||
@override
|
||||
Future<Null> run() async {
|
||||
checkSharding();
|
||||
Future<void> run() async {
|
||||
final List<String> failingTests = <String>[];
|
||||
final bool isLinux = argResults[kLinux];
|
||||
final bool isMacos = argResults[kMacos];
|
||||
final bool isWeb = argResults[kWeb];
|
||||
final bool isWindows = argResults[kWindows];
|
||||
await for (Directory plugin in getPlugins()) {
|
||||
final bool isLinux = argResults[kLinux] == true;
|
||||
final bool isMacos = argResults[kMacos] == true;
|
||||
final bool isWeb = argResults[kWeb] == true;
|
||||
final bool isWindows = argResults[kWindows] == true;
|
||||
await for (final Directory plugin in getPlugins()) {
|
||||
final String flutterCommand =
|
||||
LocalPlatform().isWindows ? 'flutter.bat' : 'flutter';
|
||||
for (Directory example in getExamplesForPlugin(plugin)) {
|
||||
const LocalPlatform().isWindows ? 'flutter.bat' : 'flutter';
|
||||
for (final Directory example in getExamplesForPlugin(plugin)) {
|
||||
final String packageName =
|
||||
p.relative(example.path, from: packagesDir.path);
|
||||
if (!(await pluginSupportedOnCurrentPlatform(plugin, fileSystem))) {
|
||||
if (!(await _pluginSupportedOnCurrentPlatform(plugin, fileSystem))) {
|
||||
continue;
|
||||
}
|
||||
final Directory driverTests =
|
||||
@ -71,7 +72,7 @@ class DriveExamplesCommand extends PluginCommand {
|
||||
continue;
|
||||
}
|
||||
// Look for driver tests ending in _test.dart in test_driver/
|
||||
await for (FileSystemEntity test in driverTests.list()) {
|
||||
await for (final FileSystemEntity test in driverTests.list()) {
|
||||
final String driverTestName =
|
||||
p.relative(test.path, from: driverTests.path);
|
||||
if (!driverTestName.endsWith('_test.dart')) {
|
||||
@ -100,7 +101,7 @@ class DriveExamplesCommand extends PluginCommand {
|
||||
fileSystem.directory(p.join(example.path, 'integration_test'));
|
||||
|
||||
if (await integrationTests.exists()) {
|
||||
await for (FileSystemEntity integration_test
|
||||
await for (final FileSystemEntity integration_test
|
||||
in integrationTests.list()) {
|
||||
if (!integration_test.basename.endsWith('_test.dart')) {
|
||||
continue;
|
||||
@ -125,7 +126,8 @@ Tried searching for the following:
|
||||
|
||||
final List<String> driveArgs = <String>['drive'];
|
||||
|
||||
final String enableExperiment = argResults[kEnableExperiment];
|
||||
final String enableExperiment =
|
||||
argResults[kEnableExperiment] as String;
|
||||
if (enableExperiment.isNotEmpty) {
|
||||
driveArgs.add('--enable-experiment=$enableExperiment');
|
||||
}
|
||||
@ -157,10 +159,10 @@ Tried searching for the following:
|
||||
]);
|
||||
}
|
||||
|
||||
for (final targetPath in targetPaths) {
|
||||
for (final String targetPath in targetPaths) {
|
||||
final int exitCode = await processRunner.runAndStream(
|
||||
flutterCommand,
|
||||
[
|
||||
<String>[
|
||||
...driveArgs,
|
||||
'--driver',
|
||||
p.join('test_driver', driverTestName),
|
||||
@ -180,7 +182,7 @@ Tried searching for the following:
|
||||
|
||||
if (failingTests.isNotEmpty) {
|
||||
print('The following driver tests are failing (see above for details):');
|
||||
for (String test in failingTests) {
|
||||
for (final String test in failingTests) {
|
||||
print(' * $test');
|
||||
}
|
||||
throw ToolExit(1);
|
||||
@ -189,16 +191,16 @@ Tried searching for the following:
|
||||
print('All driver tests successful!');
|
||||
}
|
||||
|
||||
Future<bool> pluginSupportedOnCurrentPlatform(
|
||||
Future<bool> _pluginSupportedOnCurrentPlatform(
|
||||
FileSystemEntity plugin, FileSystem fileSystem) async {
|
||||
final bool isAndroid = argResults[kAndroid];
|
||||
final bool isIOS = argResults[kIos];
|
||||
final bool isLinux = argResults[kLinux];
|
||||
final bool isMacos = argResults[kMacos];
|
||||
final bool isWeb = argResults[kWeb];
|
||||
final bool isWindows = argResults[kWindows];
|
||||
final bool isAndroid = argResults[kAndroid] == true;
|
||||
final bool isIOS = argResults[kIos] == true;
|
||||
final bool isLinux = argResults[kLinux] == true;
|
||||
final bool isMacos = argResults[kMacos] == true;
|
||||
final bool isWeb = argResults[kWeb] == true;
|
||||
final bool isWindows = argResults[kWindows] == true;
|
||||
if (isAndroid) {
|
||||
return (isAndroidPlugin(plugin, fileSystem));
|
||||
return isAndroidPlugin(plugin, fileSystem);
|
||||
}
|
||||
if (isIOS) {
|
||||
return isIosPlugin(plugin, fileSystem);
|
||||
@ -216,9 +218,9 @@ Tried searching for the following:
|
||||
return isWindowsPlugin(plugin, fileSystem);
|
||||
}
|
||||
// When we are here, no flags are specified. Only return true if the plugin
|
||||
// supports Android for legacy command support. TODO(cyanglaz): Make Android
|
||||
// flag also required like other platforms (breaking change).
|
||||
// https://github.com/flutter/flutter/issues/58285
|
||||
// supports Android for legacy command support.
|
||||
// TODO(cyanglaz): Make Android flag also required like other platforms
|
||||
// (breaking change). https://github.com/flutter/flutter/issues/58285
|
||||
return isAndroidPlugin(plugin, fileSystem);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user