Revert "[flutter_tools] Remove --no-sound-null-safety #3"
This commit is contained in:
@@ -67,52 +67,6 @@ void main() {
|
||||
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 {
|
||||
fileSystem.file('lib/main.dart').createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
|
||||
@@ -176,10 +176,7 @@ 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, 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.)');
|
||||
// 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.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, 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.');
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// 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}');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user