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
34 changed files with 20 additions and 309 deletions

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,