Remove the last vestiges of null-unsafety in flutter_tools. (#164026)

The internal code using this was deleted in `cl/730558889`.
This commit is contained in:
Matan Lurey 2025-02-27 08:31:22 -08:00 committed by GitHub
parent 8c7e18612f
commit d8856b9e50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
34 changed files with 20 additions and 309 deletions

View File

@ -617,7 +617,6 @@ class AndroidDevice extends Device {
);
}
final String dartVmFlags = computeDartVmFlags(debuggingOptions);
final String? traceAllowlist = debuggingOptions.traceAllowlist;
final String? traceSkiaAllowlist = debuggingOptions.traceSkiaAllowlist;
final String? traceToFile = debuggingOptions.traceToFile;
@ -684,7 +683,11 @@ class AndroidDevice extends Device {
'disable-service-auth-codes',
'true',
],
if (dartVmFlags.isNotEmpty) ...<String>['--es', 'dart-flags', dartVmFlags],
if (debuggingOptions.dartFlags.isNotEmpty) ...<String>[
'--es',
'dart-flags',
debuggingOptions.dartFlags,
],
if (debuggingOptions.useTestFonts) ...<String>['--ez', 'use-test-fonts', 'true'],
if (debuggingOptions.verboseSystemLogs) ...<String>['--ez', 'verbose-logging', 'true'],
if (userIdentifier != null) ...<String>['--user', userIdentifier],

View File

@ -85,7 +85,6 @@ class AttachCommand extends FlutterCommand {
usesDartDefineOption();
usesDeviceUserOption();
addEnableExperimentation(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesInitializeFromDillOption(hide: !verboseHelp);
usesNativeAssetsOption(hide: !verboseHelp);
argParser

View File

@ -48,7 +48,6 @@ class BuildAarCommand extends BuildSubCommand {
usesDartDefineOption();
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
usesTrackWidgetCreation(verboseHelp: false);
addNullSafetyModeOptions(hide: !verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
addAndroidSpecificBuildOptions(hide: !verboseHelp);
argParser.addMultiOption(

View File

@ -31,7 +31,6 @@ class BuildApkCommand extends BuildSubCommand {
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
addAndroidSpecificBuildOptions(hide: !verboseHelp);
addIgnoreDeprecationOption();

View File

@ -34,7 +34,6 @@ class BuildAppBundleCommand extends BuildSubCommand {
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
usesAnalyzeSizeFlag();
addAndroidSpecificBuildOptions(hide: !verboseHelp);

View File

@ -676,7 +676,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
argParser.addFlag(
'codesign',

View File

@ -45,7 +45,6 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
addSplitDebugInfoOption();
addDartObfuscationOption();
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
argParser

View File

@ -32,7 +32,6 @@ class BuildWebCommand extends BuildSubCommand {
addBuildModeFlags(verboseHelp: verboseHelp);
usesDartDefineOption();
addEnableExperimentation(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
addNativeNullAssertions();
//

View File

@ -243,7 +243,6 @@ class PackagesGetCommand extends FlutterCommand {
argParser.addFlag('enforce-lockfile');
argParser.addFlag('precompile');
argParser.addFlag('major-versions');
argParser.addFlag('null-safety');
argParser.addFlag('example', defaultsTo: true);
argParser.addOption('sdk');
argParser.addOption('path');

View File

@ -209,7 +209,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
usesIpv6Flag(verboseHelp: verboseHelp);
usesPubOption();
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesDeviceUserOption();
usesDeviceTimeoutOption();
usesDeviceConnectionOption();
@ -360,7 +359,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
argParser.options.containsKey('fast-start') &&
boolArg('fast-start') &&
!runningWithPrebuiltApplication,
nullAssertions: boolArg('null-assertions'),
nativeNullAssertions: boolArg('native-null-assertions'),
enableImpeller: enableImpeller,
enableVulkanValidation: enableVulkanValidation,

View File

@ -71,7 +71,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
}) {
requiresPubspecYaml();
usesPubOption();
addNullSafetyModeOptions(hide: !verboseHelp);
usesFrontendServerStarterPathOption(verboseHelp: verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
@ -457,7 +456,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
// On iOS >=14, keeping this enabled will leave a prompt on the screen.
disablePortPublication: true,
enableDds: enableDds,
nullAssertions: boolArg(FlutterOptions.kNullAssertions),
usingCISystem: usingCISystem,
enableImpeller: ImpellerStatus.fromBool(argResults!['enable-impeller'] as bool?),
debugLogsDirectoryPath: debugLogsDirectoryPath,

View File

@ -278,7 +278,6 @@ class CustomDeviceAppSession {
bool traceStartup,
String? route,
) {
final String dartVmFlags = computeDartVmFlags(debuggingOptions);
return <String>[
if (traceStartup) 'trace-startup=true',
if (route != null) 'route=$route',
@ -301,7 +300,7 @@ class CustomDeviceAppSession {
],
if (debuggingOptions.startPaused) 'start-paused=true',
if (debuggingOptions.disableServiceAuthCodes) 'disable-service-auth-codes=true',
if (dartVmFlags.isNotEmpty) 'dart-flags=$dartVmFlags',
if (debuggingOptions.dartFlags.isNotEmpty) 'dart-flags=${debuggingOptions.dartFlags}',
if (debuggingOptions.useTestFonts) 'use-test-fonts=true',
if (debuggingOptions.verboseSystemLogs) 'verbose-logging=true',
],

View File

@ -311,7 +311,7 @@ abstract class DesktopDevice extends Device {
if (debuggingOptions.disableServiceAuthCodes) {
addFlag('disable-service-auth-codes=true');
}
final String dartVmFlags = computeDartVmFlags(debuggingOptions);
final String dartVmFlags = debuggingOptions.dartFlags;
if (dartVmFlags.isNotEmpty) {
addFlag('dart-flags=$dartVmFlags');
}

View File

@ -964,7 +964,6 @@ class DebuggingOptions {
this.webUseWasm = false,
this.vmserviceOutFile,
this.fastStart = false,
this.nullAssertions = false,
this.nativeNullAssertions = false,
this.enableImpeller = ImpellerStatus.platformDefault,
this.enableVulkanValidation = false,
@ -1031,7 +1030,6 @@ class DebuggingOptions {
vmserviceOutFile = null,
fastStart = false,
webEnableExpressionEvaluation = false,
nullAssertions = false,
nativeNullAssertions = false,
serveObservatory = false,
enableDevTools = false,
@ -1083,7 +1081,6 @@ class DebuggingOptions {
required this.webUseWasm,
required this.vmserviceOutFile,
required this.fastStart,
required this.nullAssertions,
required this.nativeNullAssertions,
required this.enableImpeller,
required this.enableVulkanValidation,
@ -1181,8 +1178,6 @@ class DebuggingOptions {
final String? vmserviceOutFile;
final bool fastStart;
final bool nullAssertions;
/// Additional null runtime checks inserted for web applications.
///
/// See also:
@ -1196,17 +1191,16 @@ class DebuggingOptions {
DeviceConnectionInterface interfaceType = DeviceConnectionInterface.attached,
bool isCoreDevice = false,
}) {
final String dartVmFlags = computeDartVmFlags(this);
return <String>[
if (enableDartProfiling) '--enable-dart-profiling',
if (disableServiceAuthCodes) '--disable-service-auth-codes',
if (disablePortPublication) '--disable-vm-service-publication',
if (startPaused) '--start-paused',
// Wrap dart flags in quotes for physical devices
if (environmentType == EnvironmentType.physical && dartVmFlags.isNotEmpty)
'--dart-flags="$dartVmFlags"',
if (environmentType == EnvironmentType.simulator && dartVmFlags.isNotEmpty)
'--dart-flags=$dartVmFlags',
if (environmentType == EnvironmentType.physical && dartFlags.isNotEmpty)
'--dart-flags="$dartFlags"',
if (environmentType == EnvironmentType.simulator && dartFlags.isNotEmpty)
'--dart-flags=$dartFlags',
if (useTestFonts) '--use-test-fonts',
// Core Devices (iOS 17 devices) are debugged through Xcode so don't
// include these flags, which are used to check if the app was launched
@ -1284,7 +1278,6 @@ class DebuggingOptions {
'webUseWasm': webUseWasm,
'vmserviceOutFile': vmserviceOutFile,
'fastStart': fastStart,
'nullAssertions': nullAssertions,
'nativeNullAssertions': nativeNullAssertions,
'enableImpeller': enableImpeller.asBool,
'enableVulkanValidation': enableVulkanValidation,
@ -1354,7 +1347,6 @@ class DebuggingOptions {
webUseWasm: json['webUseWasm']! as bool,
vmserviceOutFile: json['vmserviceOutFile'] as String?,
fastStart: json['fastStart']! as bool,
nullAssertions: json['nullAssertions']! as bool,
nativeNullAssertions: json['nativeNullAssertions']! as bool,
enableImpeller: ImpellerStatus.fromBool(json['enableImpeller'] as bool?),
enableVulkanValidation: (json['enableVulkanValidation'] as bool?) ?? false,
@ -1434,12 +1426,3 @@ class NoOpDeviceLogReader implements DeviceLogReader {
@override
Future<void> provideVmService(FlutterVmService connectedVmService) async {}
}
/// Append --null_assertions to any existing Dart VM flags if
/// [debuggingOptions.nullAssertions] is true.
String computeDartVmFlags(DebuggingOptions debuggingOptions) {
return <String>[
if (debuggingOptions.dartFlags.isNotEmpty) debuggingOptions.dartFlags,
if (debuggingOptions.nullAssertions) '--null_assertions',
].join(',');
}

View File

@ -46,7 +46,6 @@ import 'pre_run_validator.dart';
import 'project.dart';
import 'reporting/crash_reporting.dart';
import 'reporting/reporting.dart';
import 'runner/flutter_command.dart';
import 'runner/local_engine.dart';
import 'version.dart';
@ -286,11 +285,6 @@ final RegExp kVMServiceMessageRegExp = RegExp(
r'The Dart VM service is listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)',
);
// The official tool no longer allows non-null safe builds. This can be
// overridden in other clients.
NonNullSafeBuilds get nonNullSafeBuilds =>
context.get<NonNullSafeBuilds>() ?? NonNullSafeBuilds.notAllowed;
/// Contains information about the JRE/JDK to use for Java-dependent operations.
///
/// A value of [null] indicates that no installation of java could be found on

View File

@ -831,7 +831,6 @@ class WebDevFS implements DevFS {
required this.expressionCompiler,
required this.extraHeaders,
required this.chromiumLauncher,
required this.nullAssertions,
required this.nativeNullAssertions,
required this.ddcModuleSystem,
required this.canaryFeatures,
@ -865,7 +864,6 @@ class WebDevFS implements DevFS {
final bool canaryFeatures;
final ExpressionCompiler? expressionCompiler;
final ChromiumLauncher? chromiumLauncher;
final bool nullAssertions;
final bool nativeNullAssertions;
final int _port;
final String? tlsCertPath;
@ -1086,13 +1084,11 @@ class WebDevFS implements DevFS {
ddcModuleSystem
? generateDDCLibraryBundleMainModule(
entrypoint: entrypoint,
nullAssertions: nullAssertions,
nativeNullAssertions: nativeNullAssertions,
onLoadEndBootstrap: onLoadEndBootstrap,
)
: generateMainModule(
entrypoint: entrypoint,
nullAssertions: nullAssertions,
nativeNullAssertions: nativeNullAssertions,
loaderRootDirectory: _baseUri.toString(),
),

View File

@ -319,7 +319,6 @@ Please provide a valid TCP port (an integer between 0 and 65535, inclusive).
expressionCompiler: expressionCompiler,
extraHeaders: debuggingOptions.webHeaders,
chromiumLauncher: _chromiumLauncher,
nullAssertions: debuggingOptions.nullAssertions,
nativeNullAssertions: debuggingOptions.nativeNullAssertions,
ddcModuleSystem: debuggingOptions.buildInfo.ddcModuleFormat == DdcModuleFormat.ddc,
canaryFeatures: debuggingOptions.buildInfo.canaryFeatures ?? false,

View File

@ -132,13 +132,11 @@ abstract final class FlutterOptions {
static const String kDartDefinesOption = 'dart-define';
static const String kDartDefineFromFileOption = 'dart-define-from-file';
static const String kPerformanceMeasurementFile = 'performance-measurement-file';
static const String kNullSafety = 'sound-null-safety';
static const String kDeviceUser = 'device-user';
static const String kDeviceTimeout = 'device-timeout';
static const String kDeviceConnection = 'device-connection';
static const String kAnalyzeSize = 'analyze-size';
static const String kCodeSizeDirectory = 'code-size-directory';
static const String kNullAssertions = 'null-assertions';
static const String kAndroidGradleDaemon = 'android-gradle-daemon';
static const String kDeferredComponents = 'deferred-components';
static const String kAndroidProjectArgs = 'android-project-arg';
@ -997,20 +995,6 @@ abstract class FlutterCommand extends Command<void> {
);
}
void addNullSafetyModeOptions({required bool hide}) {
argParser.addFlag(
FlutterOptions.kNullSafety,
help: 'This flag is deprecated as only null-safe code is supported.',
defaultsTo: true,
hide: true,
);
argParser.addFlag(
FlutterOptions.kNullAssertions,
help: 'This flag is deprecated as only null-safe code is supported.',
hide: true,
);
}
void usesFrontendServerStarterPathOption({required bool verboseHelp}) {
argParser.addOption(
FlutterOptions.kFrontendServerStarterPath,
@ -1173,7 +1157,6 @@ abstract class FlutterCommand extends Command<void> {
addBuildPerformanceFile(hide: !verboseHelp);
addDartObfuscationOption();
addEnableExperimentation(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
addSplitDebugInfoOption();
addTreeShakeIconsFlag();
usesAnalyzeSizeFlag();
@ -1844,16 +1827,6 @@ abstract class FlutterCommand extends Command<void> {
/// rather than calling [runCommand] directly.
@mustCallSuper
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
if (argParser.options.containsKey(FlutterOptions.kNullSafety) &&
argResults![FlutterOptions.kNullSafety] == false &&
globals.nonNullSafeBuilds == NonNullSafeBuilds.notAllowed) {
throwToolExit('''
Could not find an option named "no-${FlutterOptions.kNullSafety}".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
''');
}
globals.preRunValidator.validate();
if (refreshWirelessDevices) {
@ -2153,9 +2126,3 @@ DevelopmentArtifact? artifactFromTargetPlatform(TargetPlatform targetPlatform) {
/// Returns true if s is either null, empty or is solely made of whitespace characters (as defined by String.trim).
bool _isBlank(String s) => s.trim().isEmpty;
/// Whether the tool should allow non-null safe builds.
///
/// The Dart SDK no longer supports non-null safe builds, so this value in the
/// tool's context should always be [NonNullSafeBuilds.notAllowed].
enum NonNullSafeBuilds { allowed, notAllowed }

View File

@ -118,7 +118,6 @@ class FlutterTesterTestDevice extends TestDevice {
'--disable-asset-fonts',
'--packages=${debuggingOptions.buildInfo.packageConfigPath}',
if (testAssetDirectory != null) '--flutter-assets-dir=$testAssetDirectory',
if (debuggingOptions.nullAssertions) '--dart-flags=--null_assertions',
...debuggingOptions.dartEntrypointArgs,
entrypointPath,
];

View File

@ -69,7 +69,6 @@ class FlutterWebPlatform extends PlatformPlugin {
this._server,
this._config,
this._root, {
this.nullAssertions,
required this.updateGoldens,
required this.buildInfo,
required this.webMemoryFS,
@ -141,7 +140,6 @@ class FlutterWebPlatform extends PlatformPlugin {
final Logger _logger;
final Artifacts? _artifacts;
final bool updateGoldens;
final bool? nullAssertions;
final OneOffHandler _webSocketHandler = OneOffHandler();
final AsyncMemoizer<void> _closeMemo = AsyncMemoizer<void>();
final String _root;
@ -164,7 +162,6 @@ class FlutterWebPlatform extends PlatformPlugin {
String root, {
bool updateGoldens = false,
bool pauseAfterLoad = false,
bool nullAssertions = false,
required FlutterProject flutterProject,
required String flutterTesterBinPath,
required BuildInfo buildInfo,
@ -215,7 +212,6 @@ class FlutterWebPlatform extends PlatformPlugin {
chromiumLauncher: chromiumLauncher,
artifacts: artifacts,
logger: logger,
nullAssertions: nullAssertions,
processManager: processManager,
webRenderer: webRenderer,
useWasm: useWasm,
@ -332,7 +328,6 @@ class FlutterWebPlatform extends PlatformPlugin {
if (request.url.path.endsWith('main.dart.bootstrap.js')) {
return shelf.Response.ok(
generateMainModule(
nullAssertions: nullAssertions!,
nativeNullAssertions: true,
bootstrapModule: 'main.dart.bootstrap',
entrypoint: '/main.dart.js',

View File

@ -117,7 +117,6 @@ interface class FlutterTestRunner {
flutterTesterBinPath: flutterTesterBinPath,
flutterProject: flutterProject,
pauseAfterLoad: debuggingOptions.startPaused,
nullAssertions: debuggingOptions.nullAssertions,
buildInfo: debuggingOptions.buildInfo,
webMemoryFS: result,
logger: globals.logger,
@ -697,7 +696,6 @@ class SpawnPlugin extends PlatformPlugin {
'--disable-asset-fonts',
'--packages=${debuggingOptions.buildInfo.packageConfigPath}',
if (testAssetDirectory != null) '--flutter-assets-dir=$testAssetDirectory',
if (debuggingOptions.nullAssertions) '--dart-flags=--null_assertions',
...debuggingOptions.dartEntrypointArgs,
rootTestIsolateSpawnerDillFile.absolute.path,
];

View File

@ -471,45 +471,10 @@ document.addEventListener('dart-app-ready', function (e) {
''';
}
// TODO(srujzs): Delete this once it's no longer used internally.
String generateDDCMainModule({
required String entrypoint,
required bool nullAssertions,
required bool nativeNullAssertions,
String? exportedMain,
}) {
final String entrypointMainName = exportedMain ?? entrypoint.split('.')[0];
// The typo below in "EXTENTION" is load-bearing, package:build depends on it.
return '''
/* ENTRYPOINT_EXTENTION_MARKER */
(function() {
// Flutter Web uses a generated main entrypoint, which shares app and module names.
let appName = "$entrypoint";
let moduleName = "$entrypoint";
// Use a dummy UUID since multi-apps are not supported on Flutter Web.
let uuid = "00000000-0000-0000-0000-000000000000";
let child = {};
child.main = function() {
let dart = self.dart_library.import('dart_sdk', appName).dart;
dart.nonNullAsserts($nullAssertions);
dart.nativeNonNullAsserts($nativeNullAssertions);
self.dart_library.start(appName, uuid, moduleName, "$entrypointMainName");
}
/* MAIN_EXTENSION_MARKER */
child.main();
})();
''';
}
const String _onLoadEndCallback = r'$onLoadEndCallback';
String generateDDCLibraryBundleMainModule({
required String entrypoint,
required bool nullAssertions,
required bool nativeNullAssertions,
required String onLoadEndBootstrap,
}) {
@ -536,7 +501,6 @@ String generateDDCLibraryBundleMainModule({
let child = {};
child.main = function() {
let sdkOptions = {
nonNullAsserts: $nullAssertions,
nativeNonNullAsserts: $nativeNullAssertions,
};
dartDevEmbedder.runMain(appName, sdkOptions);
@ -566,7 +530,6 @@ String generateDDCLibraryBundleOnLoadEndBootstrap() {
/// this object is the module.
String generateMainModule({
required String entrypoint,
required bool nullAssertions,
required bool nativeNullAssertions,
String bootstrapModule = 'main_module.bootstrap',
String loaderRootDirectory = '',
@ -582,7 +545,6 @@ require.config({
define("$bootstrapModule", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) {
dart_sdk.dart.setStartAsyncSynchronously(true);
dart_sdk._debugger.registerDevtoolsFormatter();
dart_sdk.dart.nonNullAsserts($nullAssertions);
dart_sdk.dart.nativeNonNullAsserts($nativeNullAssertions);
// See the generateMainModule doc comment.

View File

@ -567,7 +567,6 @@ void main() {
'--trace-systrace',
'--trace-to-file=path/to/trace.binpb',
'--verbose-system-logs',
'--null-assertions',
'--native-null-assertions',
'--enable-impeller',
'--trace-systrace',
@ -588,7 +587,6 @@ void main() {
expect(options.traceSystrace, true);
expect(options.traceToFile, 'path/to/trace.binpb');
expect(options.verboseSystemLogs, true);
expect(options.nullAssertions, true);
expect(options.nativeNullAssertions, true);
expect(options.enableImpeller, ImpellerStatus.enabled);
expect(options.traceSystrace, true);

View File

@ -75,34 +75,6 @@ void main() {
},
);
testUsingContext(
'does not support --no-sound-null-safety by default',
() async {
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.dart_tool/package_config.json').createSync(recursive: true);
final TestRunCommandThatOnlyValidates command = TestRunCommandThatOnlyValidates();
await expectLater(
() => createTestCommandRunner(
command,
).run(<String>['run', '--use-application-binary=app/bar/faz', '--no-sound-null-safety']),
throwsA(
isException.having(
(Exception exception) => exception.toString(),
'toString',
contains('Could not find an option named "no-sound-null-safety"'),
),
),
);
},
overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Logger: () => logger,
},
);
testUsingContext(
'does not support "--use-application-binary" and "--fast-start"',
() async {
@ -1283,7 +1255,6 @@ void main() {
'--trace-systrace',
'--trace-to-file=path/to/trace.binpb',
'--verbose-system-logs',
'--null-assertions',
'--native-null-assertions',
'--enable-impeller',
'--enable-vulkan-validation',
@ -1306,7 +1277,6 @@ void main() {
expect(options.traceSystrace, true);
expect(options.traceToFile, 'path/to/trace.binpb');
expect(options.verboseSystemLogs, true);
expect(options.nullAssertions, true);
expect(options.nativeNullAssertions, true);
expect(options.traceSystrace, true);
expect(options.enableImpeller, ImpellerStatus.enabled);

View File

@ -262,7 +262,7 @@ void main() {
'--ez', 'verify-entry-points', 'true',
'--ez', 'start-paused', 'true',
'--ez', 'disable-service-auth-codes', 'true',
'--es', 'dart-flags', 'foo,--null_assertions',
'--es', 'dart-flags', 'foo',
'--ez', 'use-test-fonts', 'true',
'--ez', 'verbose-logging', 'true',
'--user', '10',
@ -291,7 +291,6 @@ void main() {
useTestFonts: true,
verboseSystemLogs: true,
enableImpeller: ImpellerStatus.enabled,
nullAssertions: true,
),
platformArgs: <String, dynamic>{},
userIdentifier: '10',

View File

@ -258,10 +258,7 @@ void verifyOptions(String? command, Iterable<Option> options) {
);
// Deprecated options and flags should be hidden but still have help text.
const List<String> deprecatedOptions = <String>[
FlutterOptions.kNullSafety,
FlutterOptions.kNullAssertions,
];
const List<String> deprecatedOptions = <String>[];
final bool isOptionDeprecated = deprecatedOptions.contains(option.name);
if (!isOptionDeprecated) {
expect(

View File

@ -2,100 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/signals.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/commands/attach.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_aar.dart';
import 'package:flutter_tools/src/commands/build_apk.dart';
import 'package:flutter_tools/src/commands/build_appbundle.dart';
import 'package:flutter_tools/src/commands/build_ios.dart';
import 'package:flutter_tools/src/commands/build_ios_framework.dart';
import 'package:flutter_tools/src/commands/build_linux.dart';
import 'package:flutter_tools/src/commands/build_macos.dart';
import 'package:flutter_tools/src/commands/build_web.dart';
import 'package:flutter_tools/src/commands/build_windows.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fakes.dart';
import '../../src/test_build_system.dart';
class FakeTerminal extends Fake implements AnsiTerminal {
FakeTerminal({this.stdinHasTerminal = true});
@override
final bool stdinHasTerminal;
}
class FakeProcessInfo extends Fake implements ProcessInfo {
@override
int maxRss = 0;
}
void main() {
testUsingContext('All build commands support null safety options', () {
final FileSystem fileSystem = MemoryFileSystem.test();
final Platform platform = FakePlatform();
final BufferLogger logger = BufferLogger.test();
final List<FlutterCommand> commands = <FlutterCommand>[
BuildWindowsCommand(
logger: BufferLogger.test(),
operatingSystemUtils: FakeOperatingSystemUtils(),
),
BuildLinuxCommand(
logger: BufferLogger.test(),
operatingSystemUtils: FakeOperatingSystemUtils(),
),
BuildMacosCommand(logger: BufferLogger.test(), verboseHelp: false),
BuildWebCommand(fileSystem: fileSystem, logger: BufferLogger.test(), verboseHelp: false),
BuildApkCommand(logger: BufferLogger.test()),
BuildIOSCommand(logger: BufferLogger.test(), verboseHelp: false),
BuildIOSArchiveCommand(logger: BufferLogger.test(), verboseHelp: false),
BuildAppBundleCommand(logger: BufferLogger.test()),
BuildAarCommand(
logger: BufferLogger.test(),
androidSdk: FakeAndroidSdk(),
fileSystem: fileSystem,
verboseHelp: false,
),
BuildIOSFrameworkCommand(
logger: BufferLogger.test(),
verboseHelp: false,
buildSystem: FlutterBuildSystem(fileSystem: fileSystem, platform: platform, logger: logger),
),
AttachCommand(
stdio: FakeStdio(),
logger: logger,
terminal: FakeTerminal(),
signals: Signals.test(),
platform: platform,
processInfo: FakeProcessInfo(),
fileSystem: MemoryFileSystem.test(),
),
];
for (final FlutterCommand command in commands) {
final ArgResults results = command.argParser.parse(<String>[
'--sound-null-safety',
'--enable-experiment=non-nullable',
]);
expect(results.wasParsed('sound-null-safety'), true);
expect(results.wasParsed('enable-experiment'), true);
}
});
testUsingContext('Include only supported sub commands', () {
final BufferLogger logger = BufferLogger.test();
final MemoryFileSystem fs = MemoryFileSystem.test();

View File

@ -172,10 +172,9 @@ void main() {
'FLUTTER_ENGINE_SWITCH_14': 'verify-entry-points=true',
'FLUTTER_ENGINE_SWITCH_15': 'start-paused=true',
'FLUTTER_ENGINE_SWITCH_16': 'disable-service-auth-codes=true',
'FLUTTER_ENGINE_SWITCH_17': 'dart-flags=--null_assertions',
'FLUTTER_ENGINE_SWITCH_18': 'use-test-fonts=true',
'FLUTTER_ENGINE_SWITCH_19': 'verbose-logging=true',
'FLUTTER_ENGINE_SWITCHES': '19',
'FLUTTER_ENGINE_SWITCH_17': 'use-test-fonts=true',
'FLUTTER_ENGINE_SWITCH_18': 'verbose-logging=true',
'FLUTTER_ENGINE_SWITCHES': '18',
},
),
]);
@ -200,7 +199,6 @@ void main() {
purgePersistentCache: true,
useTestFonts: true,
verboseSystemLogs: true,
nullAssertions: true,
),
);

View File

@ -692,27 +692,6 @@ void main() {
});
});
testWithoutContext(
'computeDartVmFlags handles various combinations of Dart VM flags and null_assertions',
() {
expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug)), '');
expect(
computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, dartFlags: '--foo')),
'--foo',
);
expect(
computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, nullAssertions: true)),
'--null_assertions',
);
expect(
computeDartVmFlags(
DebuggingOptions.enabled(BuildInfo.debug, dartFlags: '--foo', nullAssertions: true),
),
'--foo,--null_assertions',
);
},
);
group('JSON encode DebuggingOptions', () {
testWithoutContext('can preserve the original options', () {
final DebuggingOptions original = DebuggingOptions.enabled(
@ -764,7 +743,6 @@ void main() {
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: ImpellerStatus.disabled,
nullAssertions: true,
deviceVmServicePort: 0,
hostVmServicePort: 1,
);
@ -782,7 +760,7 @@ void main() {
'--disable-service-auth-codes',
'--disable-vm-service-publication',
'--start-paused',
'--dart-flags="--foo,--null_assertions"',
'--dart-flags="--foo"',
'--use-test-fonts',
'--enable-checked-mode',
'--verify-entry-points',
@ -934,7 +912,6 @@ void main() {
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: ImpellerStatus.disabled,
nullAssertions: true,
deviceVmServicePort: 0,
hostVmServicePort: 1,
);
@ -952,7 +929,7 @@ void main() {
'--disable-service-auth-codes',
'--disable-vm-service-publication',
'--start-paused',
'--dart-flags=--foo,--null_assertions',
'--dart-flags=--foo',
'--use-test-fonts',
'--enable-checked-mode',
'--verify-entry-points',

View File

@ -521,7 +521,7 @@ void main() {
'--disable-service-auth-codes',
'--disable-vm-service-publication',
'--start-paused',
'--dart-flags="--foo,--null_assertions"',
'--dart-flags="--foo"',
'--use-test-fonts',
'--enable-checked-mode',
'--verify-entry-points',
@ -588,7 +588,6 @@ void main() {
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: ImpellerStatus.disabled,
nullAssertions: true,
enableEmbedderApi: true,
),
platformArgs: <String, dynamic>{},

View File

@ -1406,7 +1406,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''',
purgePersistentCache: true,
dartFlags: '--baz',
enableImpeller: ImpellerStatus.disabled,
nullAssertions: true,
hostVmServicePort: 0,
);
@ -1431,7 +1430,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''',
'--verbose-logging',
'--purge-persistent-cache',
'--enable-impeller=false',
'--dart-flags=--baz,--null_assertions',
'--dart-flags=--baz',
'--vm-service-port=0',
]),
);

View File

@ -62,7 +62,6 @@ void main() {
test('generateMainModule removes timeout from requireJS', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
);
@ -83,7 +82,6 @@ void main() {
test('generateMainModule hides requireJS injected by DDC', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
);
expect(
@ -101,7 +99,6 @@ void main() {
test('generateMainModule embeds urls correctly', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
);
// bootstrap main module has correct defined module.
@ -117,7 +114,6 @@ void main() {
test('generateMainModule can set bootstrap name', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
bootstrapModule: 'foo_module.bootstrap',
);
@ -134,22 +130,18 @@ void main() {
test('generateMainModule includes null safety switches', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: true,
nativeNullAssertions: true,
);
expect(result, contains('''dart_sdk.dart.nonNullAsserts(true);'''));
expect(result, contains('''dart_sdk.dart.nativeNonNullAsserts(true);'''));
});
test('generateMainModule can disable null safety switches', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
);
expect(result, contains('''dart_sdk.dart.nonNullAsserts(false);'''));
expect(result, contains('''dart_sdk.dart.nativeNonNullAsserts(false);'''));
});
@ -157,7 +149,6 @@ void main() {
const String root = 'http://localhost:12345';
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
nullAssertions: false,
nativeNullAssertions: false,
loaderRootDirectory: root,
);
@ -271,7 +262,6 @@ void main() {
test('generateDDCLibraryBundleMainModule embeds the entrypoint correctly', () {
final String result = generateDDCLibraryBundleMainModule(
entrypoint: 'main.js',
nullAssertions: false,
nativeNullAssertions: false,
onLoadEndBootstrap: 'on_load_end_bootstrap.js',
);
@ -283,24 +273,20 @@ void main() {
test('generateDDCLibraryBundleMainModule includes null safety switches', () {
final String result = generateDDCLibraryBundleMainModule(
entrypoint: 'main.js',
nullAssertions: true,
nativeNullAssertions: true,
onLoadEndBootstrap: 'on_load_end_bootstrap.js',
);
expect(result, contains('nonNullAsserts: true'));
expect(result, contains('nativeNonNullAsserts: true'));
});
test('generateDDCLibraryBundleMainModule can disable null safety switches', () {
final String result = generateDDCLibraryBundleMainModule(
entrypoint: 'main.js',
nullAssertions: false,
nativeNullAssertions: false,
onLoadEndBootstrap: 'on_load_end_bootstrap.js',
);
expect(result, contains('nonNullAsserts: false'));
expect(result, contains('nativeNonNullAsserts: false'));
});

View File

@ -790,7 +790,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -901,7 +900,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -989,7 +987,6 @@ void main() {
expressionCompiler: null,
extraHeaders: const <String, String>{},
chromiumLauncher: null,
nullAssertions: true,
nativeNullAssertions: true,
ddcModuleSystem: usesDdcModuleSystem,
canaryFeatures: canaryFeatures,
@ -1025,7 +1022,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -1082,7 +1078,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: BuildInfo.debug,
enableDwds: false,
@ -1243,7 +1238,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: BuildInfo.debug,
enableDwds: false,

View File

@ -910,7 +910,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -1019,7 +1018,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -1134,7 +1132,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -1225,7 +1222,6 @@ void main() {
expressionCompiler: null,
extraHeaders: const <String, String>{},
chromiumLauncher: null,
nullAssertions: true,
nativeNullAssertions: true,
ddcModuleSystem: usesDdcModuleSystem,
canaryFeatures: canaryFeatures,
@ -1264,7 +1260,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: const BuildInfo(
BuildMode.debug,
@ -1324,7 +1319,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: BuildInfo.debug,
enableDwds: false,
@ -1495,7 +1489,6 @@ void main() {
useSseForDebugProxy: true,
useSseForDebugBackend: true,
useSseForInjectedClient: true,
nullAssertions: true,
nativeNullAssertions: true,
buildInfo: BuildInfo.debug,
enableDwds: false,