Unverified Commit 820ec70a authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] Remove --no-sound-null-safety #3 (#123297)

[flutter_tools] Remove --no-sound-null-safety #3
parent 91311156
...@@ -573,9 +573,7 @@ Future<void> _runExampleProjectBuildTests(Directory exampleDirectory, [File? mai ...@@ -573,9 +573,7 @@ Future<void> _runExampleProjectBuildTests(Directory exampleDirectory, [File? mai
// Only verify caching with flutter gallery. // Only verify caching with flutter gallery.
final bool verifyCaching = exampleDirectory.path.contains('flutter_gallery'); final bool verifyCaching = exampleDirectory.path.contains('flutter_gallery');
final String examplePath = path.relative(exampleDirectory.path, from: Directory.current.path); final String examplePath = path.relative(exampleDirectory.path, from: Directory.current.path);
final bool hasNullSafety = File(path.join(examplePath, 'null_safety')).existsSync();
final List<String> additionalArgs = <String>[ final List<String> additionalArgs = <String>[
if (hasNullSafety) '--no-sound-null-safety',
if (mainFile != null) path.relative(mainFile.path, from: exampleDirectory.absolute.path), if (mainFile != null) path.relative(mainFile.path, from: exampleDirectory.absolute.path),
]; ];
if (Directory(path.join(examplePath, 'android')).existsSync()) { if (Directory(path.join(examplePath, 'android')).existsSync()) {
...@@ -771,8 +769,6 @@ Future<void> _runAddToAppLifeCycleTests() async { ...@@ -771,8 +769,6 @@ Future<void> _runAddToAppLifeCycleTests() async {
} }
Future<void> _runFrameworkTests() async { Future<void> _runFrameworkTests() async {
final List<String> soundNullSafetyOptions = <String>['--null-assertions', '--sound-null-safety'];
final List<String> mixedModeNullSafetyOptions = <String>['--null-assertions', '--no-sound-null-safety'];
final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation']; final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation'];
Future<void> runWidgets() async { Future<void> runWidgets() async {
...@@ -780,7 +776,7 @@ Future<void> _runFrameworkTests() async { ...@@ -780,7 +776,7 @@ Future<void> _runFrameworkTests() async {
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) { for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions], options: <String>[trackWidgetCreationOption],
tests: <String>[ path.join('test', 'widgets') + path.separator ], tests: <String>[ path.join('test', 'widgets') + path.separator ],
); );
} }
...@@ -795,13 +791,13 @@ Future<void> _runFrameworkTests() async { ...@@ -795,13 +791,13 @@ Future<void> _runFrameworkTests() async {
// Run release mode tests (see packages/flutter/test_release/README.md) // Run release mode tests (see packages/flutter/test_release/README.md)
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>['--dart-define=dart.vm.product=true', ...soundNullSafetyOptions], options: <String>['--dart-define=dart.vm.product=true'],
tests: <String>['test_release${path.separator}'], tests: <String>['test_release${path.separator}'],
); );
// Run profile mode tests (see packages/flutter/test_profile/README.md) // Run profile mode tests (see packages/flutter/test_profile/README.md)
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>['--dart-define=dart.vm.product=false', '--dart-define=dart.vm.profile=true', ...soundNullSafetyOptions], options: <String>['--dart-define=dart.vm.product=false', '--dart-define=dart.vm.profile=true'],
tests: <String>['test_profile${path.separator}'], tests: <String>['test_profile${path.separator}'],
); );
} }
...@@ -817,7 +813,7 @@ Future<void> _runFrameworkTests() async { ...@@ -817,7 +813,7 @@ Future<void> _runFrameworkTests() async {
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) { for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions], options: <String>[trackWidgetCreationOption],
tests: tests, tests: tests,
); );
} }
...@@ -837,9 +833,9 @@ Future<void> _runFrameworkTests() async { ...@@ -837,9 +833,9 @@ Future<void> _runFrameworkTests() async {
workingDirectory: path.join(flutterRoot, 'examples', 'api'), workingDirectory: path.join(flutterRoot, 'examples', 'api'),
); );
} }
await _runFlutterTest(path.join(flutterRoot, 'examples', 'api'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'examples', 'api'));
await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'));
await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'));
} }
Future<void> runTracingTests() async { Future<void> runTracingTests() async {
...@@ -945,7 +941,6 @@ Future<void> _runFrameworkTests() async { ...@@ -945,7 +941,6 @@ Future<void> _runFrameworkTests() async {
Future<void> runPrivateTests() async { Future<void> runPrivateTests() async {
final List<String> args = <String>[ final List<String> args = <String>[
'--sound-null-safety',
'run', 'run',
'bin/test_private.dart', 'bin/test_private.dart',
]; ];
...@@ -989,17 +984,17 @@ Future<void> _runFrameworkTests() async { ...@@ -989,17 +984,17 @@ Future<void> _runFrameworkTests() async {
await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_defaults')); await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_defaults'));
await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_keycodes')); await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_keycodes'));
await _runFlutterTest(path.join(flutterRoot, 'dev', 'benchmarks', 'test_apps', 'stocks')); await _runFlutterTest(path.join(flutterRoot, 'dev', 'benchmarks', 'test_apps', 'stocks'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'), tests: <String>[path.join('test', 'src', 'real_tests')], options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'), tests: <String>[path.join('test', 'src', 'real_tests')]);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'integration_test'), options: <String>[ await _runFlutterTest(path.join(flutterRoot, 'packages', 'integration_test'), options: <String>[
'--enable-vmservice', '--enable-vmservice',
// Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard. // Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard.
'--exclude-tags=web', '--exclude-tags=web',
]); ]);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'));
await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'), options: mixedModeNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'));
const String httpClientWarning = const String httpClientWarning =
'Warning: At least one test in this suite creates an HttpClient. When\n' 'Warning: At least one test in this suite creates an HttpClient. When\n'
'running a test suite that uses TestWidgetsFlutterBinding, all HTTP\n' 'running a test suite that uses TestWidgetsFlutterBinding, all HTTP\n'
...@@ -1234,7 +1229,7 @@ Future<void> _runWebLongRunningTests() async { ...@@ -1234,7 +1229,7 @@ Future<void> _runWebLongRunningTests() async {
'--dart-define=TEST_FLUTTER_ENGINE_VERSION=$engineVersion', '--dart-define=TEST_FLUTTER_ENGINE_VERSION=$engineVersion',
]), ]),
() => _runWebDebugTest('test/test.dart'), () => _runWebDebugTest('test/test.dart'),
() => _runWebDebugTest('lib/null_safe_main.dart', enableNullSafety: true), () => _runWebDebugTest('lib/null_safe_main.dart'),
() => _runWebDebugTest('lib/web_define_loading.dart', () => _runWebDebugTest('lib/web_define_loading.dart',
additionalArguments: <String>[ additionalArguments: <String>[
'--dart-define=test.valueA=Example,A', '--dart-define=test.valueA=Example,A',
...@@ -1247,12 +1242,8 @@ Future<void> _runWebLongRunningTests() async { ...@@ -1247,12 +1242,8 @@ Future<void> _runWebLongRunningTests() async {
'--dart-define=test.valueB=Value', '--dart-define=test.valueB=Value',
] ]
), ),
() => _runWebDebugTest('lib/sound_mode.dart', additionalArguments: <String>[ () => _runWebDebugTest('lib/sound_mode.dart'),
'--sound-null-safety', () => _runWebReleaseTest('lib/sound_mode.dart'),
]),
() => _runWebReleaseTest('lib/sound_mode.dart', additionalArguments: <String>[
'--sound-null-safety',
]),
() => _runFlutterWebTest( () => _runFlutterWebTest(
'html', 'html',
path.join(flutterRoot, 'packages', 'integration_test'), path.join(flutterRoot, 'packages', 'integration_test'),
...@@ -1311,7 +1302,6 @@ Future<void> _runFlutterDriverWebTest({ ...@@ -1311,7 +1302,6 @@ Future<void> _runFlutterDriverWebTest({
if (driver != null) '--driver=$driver', if (driver != null) '--driver=$driver',
'--target=$target', '--target=$target',
'--browser-name=chrome', '--browser-name=chrome',
'--no-sound-null-safety',
'-d', '-d',
'web-server', 'web-server',
'--$buildMode', '--$buildMode',
...@@ -1353,7 +1343,6 @@ Future<void> _runWebTreeshakeTest() async { ...@@ -1353,7 +1343,6 @@ Future<void> _runWebTreeshakeTest() async {
'build', 'build',
'web', 'web',
'--target=$target', '--target=$target',
'--no-sound-null-safety',
'--profile', '--profile',
], ],
workingDirectory: testAppDirectory, workingDirectory: testAppDirectory,
...@@ -1579,7 +1568,6 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false }) ...@@ -1579,7 +1568,6 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
'--driver=test_driver/transitions_perf_e2e_test.dart', '--driver=test_driver/transitions_perf_e2e_test.dart',
'--target=test_driver/transitions_perf_e2e.dart', '--target=test_driver/transitions_perf_e2e.dart',
'--browser-name=chrome', '--browser-name=chrome',
'--no-sound-null-safety',
'-d', '-d',
'web-server', 'web-server',
'--$buildMode', '--$buildMode',
...@@ -1686,7 +1674,6 @@ Future<void> _runWebReleaseTest(String target, { ...@@ -1686,7 +1674,6 @@ Future<void> _runWebReleaseTest(String target, {
/// ///
/// Instead, we use `flutter run --debug` and sniff out the standard output. /// Instead, we use `flutter run --debug` and sniff out the standard output.
Future<void> _runWebDebugTest(String target, { Future<void> _runWebDebugTest(String target, {
bool enableNullSafety = false,
List<String> additionalArguments = const<String>[], List<String> additionalArguments = const<String>[],
}) async { }) async {
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web'); final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web');
...@@ -1700,11 +1687,6 @@ Future<void> _runWebDebugTest(String target, { ...@@ -1700,11 +1687,6 @@ Future<void> _runWebDebugTest(String target, {
<String>[ <String>[
'run', 'run',
'--debug', '--debug',
if (enableNullSafety)
...<String>[
'--no-sound-null-safety',
'--null-assertions',
],
'-d', '-d',
'chrome', 'chrome',
'--web-run-headless', '--web-run-headless',
...@@ -1747,7 +1729,6 @@ Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, Lis ...@@ -1747,7 +1729,6 @@ Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, Lis
'--platform=chrome', '--platform=chrome',
'--web-renderer=$webRenderer', '--web-renderer=$webRenderer',
'--dart-define=DART_HHH_BOT=$_runningInDartHHHBot', '--dart-define=DART_HHH_BOT=$_runningInDartHHHBot',
'--sound-null-safety',
...flutterTestArgs, ...flutterTestArgs,
...tests, ...tests,
], ],
......
...@@ -56,7 +56,7 @@ abstract final class Clipboard { ...@@ -56,7 +56,7 @@ abstract final class Clipboard {
if (result == null) { if (result == null) {
return null; return null;
} }
return ClipboardData(text: result['text'] as String); return ClipboardData(text: result['text']! as String);
} }
/// Returns a future that resolves to true iff the clipboard contains string /// Returns a future that resolves to true iff the clipboard contains string
......
...@@ -80,8 +80,7 @@ Future<int> test5CallCompute(int value) { ...@@ -80,8 +80,7 @@ Future<int> test5CallCompute(int value) {
return compute(test5, value); return compute(test5, value);
} }
Future<void> expectFileSuccessfullyCompletes(String filename, Future<void> expectFileSuccessfullyCompletes(String filename) async {
[bool unsound = false]) async {
// Run a Dart script that calls compute(). // Run a Dart script that calls compute().
// The Dart process will terminate only if the script exits cleanly with // The Dart process will terminate only if the script exits cleanly with
// all isolate ports closed. // all isolate ports closed.
...@@ -93,12 +92,10 @@ Future<void> expectFileSuccessfullyCompletes(String filename, ...@@ -93,12 +92,10 @@ Future<void> expectFileSuccessfullyCompletes(String filename,
final String packageRoot = fs.path.dirname(fs.path.fromUri(platform.script)); final String packageRoot = fs.path.dirname(fs.path.fromUri(platform.script));
final String scriptPath = final String scriptPath =
fs.path.join(packageRoot, 'test', 'foundation', filename); fs.path.join(packageRoot, 'test', 'foundation', filename);
final String nullSafetyArg =
unsound ? '--no-sound-null-safety' : '--sound-null-safety';
// Enable asserts to also catch potentially invalid assertions. // Enable asserts to also catch potentially invalid assertions.
final ProcessResult result = await Process.run( final ProcessResult result = await Process.run(
dartPath, <String>[nullSafetyArg, 'run', '--enable-asserts', scriptPath]); dartPath, <String>['run', '--enable-asserts', scriptPath]);
expect(result.exitCode, 0); expect(result.exitCode, 0);
} }
......
...@@ -225,7 +225,7 @@ class TestCase { ...@@ -225,7 +225,7 @@ class TestCase {
for (final File test in tests) { for (final File test in tests) {
final String testPath = path.join(path.dirname(test.path), 'lib', path.basenameWithoutExtension(test.path)); final String testPath = path.join(path.dirname(test.path), 'lib', path.basenameWithoutExtension(test.path));
final ProcessRunnerResult result = await runner.runProcess( final ProcessRunnerResult result = await runner.runProcess(
<String>[flutter, 'test', '--enable-experiment=non-nullable', '--no-sound-null-safety', '--null-assertions', testPath], <String>[flutter, 'test', testPath],
failOk: true, failOk: true,
); );
if (result.exitCode != 0) { if (result.exitCode != 0) {
......
...@@ -43,6 +43,7 @@ import 'pre_run_validator.dart'; ...@@ -43,6 +43,7 @@ import 'pre_run_validator.dart';
import 'project.dart'; import 'project.dart';
import 'reporting/crash_reporting.dart'; import 'reporting/crash_reporting.dart';
import 'reporting/reporting.dart'; import 'reporting/reporting.dart';
import 'runner/flutter_command.dart';
import 'runner/local_engine.dart'; import 'runner/local_engine.dart';
import 'version.dart'; import 'version.dart';
...@@ -285,3 +286,7 @@ const String kDefaultFrameworkChannel = 'master'; ...@@ -285,3 +286,7 @@ const String kDefaultFrameworkChannel = 'master';
// Used to build RegExp instances which can detect the VM service message. // Used to build RegExp instances which can detect the VM service message.
final RegExp kVMServiceMessageRegExp = RegExp(r'The Dart VM service is listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)'); 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;
...@@ -816,20 +816,13 @@ abstract class FlutterCommand extends Command<void> { ...@@ -816,20 +816,13 @@ abstract class FlutterCommand extends Command<void> {
void addNullSafetyModeOptions({ required bool hide }) { void addNullSafetyModeOptions({ required bool hide }) {
argParser.addFlag(FlutterOptions.kNullSafety, argParser.addFlag(FlutterOptions.kNullSafety,
help: help: 'This flag is deprecated as only null-safe code is supported.',
'Whether to override the inferred null safety mode. This allows null-safe '
'libraries to depend on un-migrated (non-null safe) libraries. By default, '
'Flutter mobile & desktop applications will attempt to run at the null safety '
'level of their entrypoint library (usually lib/main.dart). Flutter web '
'applications will default to sound null-safety, unless specifically configured.',
defaultsTo: true, defaultsTo: true,
hide: hide, hide: true,
); );
argParser.addFlag(FlutterOptions.kNullAssertions, argParser.addFlag(FlutterOptions.kNullAssertions,
help: help: 'This flag is deprecated as only null-safe code is supported.',
'Perform additional null assertions on the boundaries of migrated and ' hide: true,
'un-migrated code. This setting is not currently supported on desktop '
'devices.'
); );
} }
...@@ -1462,6 +1455,16 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1462,6 +1455,16 @@ abstract class FlutterCommand extends Command<void> {
/// rather than calling [runCommand] directly. /// rather than calling [runCommand] directly.
@mustCallSuper @mustCallSuper
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async { 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(); globals.preRunValidator.validate();
// Populate the cache. We call this before pub get below so that the // Populate the cache. We call this before pub get below so that the
// sky_engine package is available in the flutter cache for pub to find. // sky_engine package is available in the flutter cache for pub to find.
...@@ -1718,3 +1721,12 @@ DevelopmentArtifact? artifactFromTargetPlatform(TargetPlatform targetPlatform) { ...@@ -1718,3 +1721,12 @@ DevelopmentArtifact? artifactFromTargetPlatform(TargetPlatform targetPlatform) {
/// Returns true if s is either null, empty or is solely made of whitespace characters (as defined by String.trim). /// 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; 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,
}
...@@ -67,6 +67,52 @@ void main() { ...@@ -67,6 +67,52 @@ void main() {
Logger: () => BufferLogger.test(), Logger: () => BufferLogger.test(),
}); });
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('.packages').createSync();
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: () => BufferLogger.test(),
});
testUsingContext('supports --no-sound-null-safety with an overridden NonNullSafeBuilds', () async {
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.packages').createSync();
final FakeDevice device = FakeDevice(isLocalEmulator: true, platformType: PlatformType.android);
testDeviceManager.devices = <Device>[device];
final TestRunCommandThatOnlyValidates command = TestRunCommandThatOnlyValidates();
await createTestCommandRunner(command).run(const <String>[
'run',
'--use-application-binary=app/bar/faz',
'--no-sound-null-safety',
]);
}, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager,
FileSystem: () => fileSystem,
Logger: () => BufferLogger.test(),
NonNullSafeBuilds: () => NonNullSafeBuilds.allowed,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('does not support "--use-application-binary" and "--fast-start"', () async { testUsingContext('does not support "--use-application-binary" and "--fast-start"', () async {
fileSystem.file('lib/main.dart').createSync(recursive: true); fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
......
...@@ -176,7 +176,10 @@ void verifyOptions(String? command, Iterable<Option> options) { ...@@ -176,7 +176,10 @@ void verifyOptions(String? command, Iterable<Option> options) {
expect(option.name, matches(_allowedArgumentNamePattern), reason: '$_header$target--${option.name}" is not a valid name for a command line argument. (Is it all lowercase? Does it use hyphens rather than underscores?)'); expect(option.name, matches(_allowedArgumentNamePattern), reason: '$_header$target--${option.name}" is not a valid name for a command line argument. (Is it all lowercase? Does it use hyphens rather than underscores?)');
} }
expect(option.name, isNot(matches(_bannedArgumentNamePattern)), reason: '$_header$target--${option.name}" is not a valid name for a command line argument. (We use "--foo-url", not "--foo-uri", for example.)'); expect(option.name, isNot(matches(_bannedArgumentNamePattern)), reason: '$_header$target--${option.name}" is not a valid name for a command line argument. (We use "--foo-url", not "--foo-uri", for example.)');
expect(option.hide, isFalse, reason: '${_header}Help for $target--${option.name}" is always hidden. $_needHelp'); // The flag --sound-null-safety is deprecated
if (option.name != FlutterOptions.kNullSafety && option.name != FlutterOptions.kNullAssertions) {
expect(option.hide, isFalse, reason: '${_header}Help for $target--${option.name}" is always hidden. $_needHelp');
}
expect(option.help, isNotNull, reason: '${_header}Help for $target--${option.name}" has null help. $_needHelp'); expect(option.help, isNotNull, reason: '${_header}Help for $target--${option.name}" has null help. $_needHelp');
expect(option.help, isNotEmpty, reason: '${_header}Help for $target--${option.name}" has empty help. $_needHelp'); expect(option.help, isNotEmpty, reason: '${_header}Help for $target--${option.name}" has empty help. $_needHelp');
expect(option.help, isNot(matches(_bannedLeadingPatterns)), reason: '${_header}A line in the help for $target--${option.name}" starts with a lowercase letter. For stylistic consistency, all help messages must start with a capital letter.'); expect(option.help, isNot(matches(_bannedLeadingPatterns)), reason: '${_header}A line in the help for $target--${option.name}" starts with a lowercase letter. For stylistic consistency, all help messages must start with a capital letter.');
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/io.dart';
import '../src/common.dart';
import 'test_utils.dart';
void main() {
late Directory tempDir;
late Directory projectRoot;
late String flutterBin;
final List<String> targetPlatforms = <String>[
'apk',
'web',
if (platform.isWindows) 'windows',
if (platform.isMacOS) ...<String>['macos', 'ios'],
];
setUpAll(() {
tempDir = createResolvedTempDirectorySync('build_null_unsafe_test.');
flutterBin = fileSystem.path.join(
getFlutterRoot(),
'bin',
'flutter',
);
processManager.runSync(<String>[
flutterBin,
'config',
'--enable-macos-desktop',
'--enable-windows-desktop',
'--enable-web',
]);
processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),
'create',
'hello',
], workingDirectory: tempDir.path);
projectRoot = tempDir.childDirectory('hello');
writeFile(fileSystem.path.join(projectRoot.path, 'pubspec.yaml'), '''
name: hello
environment:
sdk: '>=2.12.0 <4.0.0'
''');
writeFile(fileSystem.path.join(projectRoot.path, 'lib', 'main.dart'), '''
import 'unsafe.dart';
void main() {
print(unsafeString);
}
''');
writeFile(fileSystem.path.join(projectRoot.path, 'lib', 'unsafe.dart'), '''
// @dart=2.9
String unsafeString = null;
''');
});
tearDownAll(() {
tryToDelete(tempDir);
});
for (final String targetPlatform in targetPlatforms) {
testWithoutContext('flutter build $targetPlatform --no-sound-null-safety', () {
final ProcessResult result = processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
targetPlatform,
'--no-pub',
'--no-sound-null-safety',
if (targetPlatform == 'ios') '--no-codesign',
], workingDirectory: projectRoot.path);
if (result.exitCode != 0) {
fail('build --no-sound-null-safety failed: ${result.exitCode}\n${result.stderr}\n${result.stdout}');
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment