Skip to content

Commit

Permalink
Revert "Revert "[flutter_tools] Remove sound null safety flag (flutte…
Browse files Browse the repository at this point in the history
…r#120936)" (flutter#122909)" (flutter#123031)

[flutter_tools] Remove sound null safety flag #2
  • Loading branch information
christopherfujino authored Mar 20, 2023
1 parent 484c226 commit f4c3fac
Show file tree
Hide file tree
Showing 67 changed files with 130 additions and 1,126 deletions.
51 changes: 16 additions & 35 deletions dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,7 @@ Future<void> _runExampleProjectBuildTests(Directory exampleDirectory, [File? mai
// Only verify caching with flutter gallery.
final bool verifyCaching = exampleDirectory.path.contains('flutter_gallery');
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>[
if (hasNullSafety) '--no-sound-null-safety',
if (mainFile != null) path.relative(mainFile.path, from: exampleDirectory.absolute.path),
];
if (Directory(path.join(examplePath, 'android')).existsSync()) {
Expand Down Expand Up @@ -771,16 +769,14 @@ Future<void> _runAddToAppLifeCycleTests() 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'];

Future<void> runWidgets() async {
printProgress('${green}Running packages/flutter tests $reset for ${cyan}test/widgets/$reset');
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
options: <String>[trackWidgetCreationOption],
tests: <String>[ path.join('test', 'widgets') + path.separator ],
);
}
Expand All @@ -795,13 +791,13 @@ Future<void> _runFrameworkTests() async {
// Run release mode tests (see packages/flutter/test_release/README.md)
await _runFlutterTest(
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}'],
);
// Run profile mode tests (see packages/flutter/test_profile/README.md)
await _runFlutterTest(
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}'],
);
}
Expand All @@ -817,7 +813,7 @@ Future<void> _runFrameworkTests() async {
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
options: <String>[trackWidgetCreationOption],
tests: tests,
);
}
Expand All @@ -837,9 +833,9 @@ Future<void> _runFrameworkTests() async {
workingDirectory: path.join(flutterRoot, 'examples', 'api'),
);
}
await _runFlutterTest(path.join(flutterRoot, 'examples', 'api'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'api'));
await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'));
await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'));
}

Future<void> runTracingTests() async {
Expand Down Expand Up @@ -945,7 +941,6 @@ Future<void> _runFrameworkTests() async {

Future<void> runPrivateTests() async {
final List<String> args = <String>[
'--sound-null-safety',
'run',
'bin/test_private.dart',
];
Expand Down Expand Up @@ -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_keycodes'));
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>[
'--enable-vmservice',
// Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard.
'--exclude-tags=web',
]);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'), options: soundNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'), options: mixedModeNullSafetyOptions);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'));
await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'));
const String httpClientWarning =
'Warning: At least one test in this suite creates an HttpClient. When\n'
'running a test suite that uses TestWidgetsFlutterBinding, all HTTP\n'
Expand Down Expand Up @@ -1229,7 +1224,7 @@ Future<void> _runWebLongRunningTests() async {
() => _runWebDebugTest('lib/framework_stack_trace.dart'),
() => _runWebDebugTest('lib/web_directory_loading.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',
additionalArguments: <String>[
'--dart-define=test.valueA=Example,A',
Expand All @@ -1242,12 +1237,8 @@ Future<void> _runWebLongRunningTests() async {
'--dart-define=test.valueB=Value',
]
),
() => _runWebDebugTest('lib/sound_mode.dart', additionalArguments: <String>[
'--sound-null-safety',
]),
() => _runWebReleaseTest('lib/sound_mode.dart', additionalArguments: <String>[
'--sound-null-safety',
]),
() => _runWebDebugTest('lib/sound_mode.dart'),
() => _runWebReleaseTest('lib/sound_mode.dart'),
() => _runFlutterWebTest(
'html',
path.join(flutterRoot, 'packages', 'integration_test'),
Expand Down Expand Up @@ -1306,7 +1297,6 @@ Future<void> _runFlutterDriverWebTest({
if (driver != null) '--driver=$driver',
'--target=$target',
'--browser-name=chrome',
'--no-sound-null-safety',
'-d',
'web-server',
'--$buildMode',
Expand Down Expand Up @@ -1348,7 +1338,6 @@ Future<void> _runWebTreeshakeTest() async {
'build',
'web',
'--target=$target',
'--no-sound-null-safety',
'--profile',
],
workingDirectory: testAppDirectory,
Expand Down Expand Up @@ -1574,7 +1563,6 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
'--driver=test_driver/transitions_perf_e2e_test.dart',
'--target=test_driver/transitions_perf_e2e.dart',
'--browser-name=chrome',
'--no-sound-null-safety',
'-d',
'web-server',
'--$buildMode',
Expand Down Expand Up @@ -1681,7 +1669,6 @@ Future<void> _runWebReleaseTest(String target, {
///
/// Instead, we use `flutter run --debug` and sniff out the standard output.
Future<void> _runWebDebugTest(String target, {
bool enableNullSafety = false,
List<String> additionalArguments = const<String>[],
}) async {
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web');
Expand All @@ -1695,11 +1682,6 @@ Future<void> _runWebDebugTest(String target, {
<String>[
'run',
'--debug',
if (enableNullSafety)
...<String>[
'--no-sound-null-safety',
'--null-assertions',
],
'-d',
'chrome',
'--web-run-headless',
Expand Down Expand Up @@ -1742,7 +1724,6 @@ Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, Lis
'--platform=chrome',
'--web-renderer=$webRenderer',
'--dart-define=DART_HHH_BOT=$_runningInDartHHHBot',
'--sound-null-safety',
...flutterTestArgs,
...tests,
],
Expand Down
7 changes: 2 additions & 5 deletions packages/flutter/test/foundation/isolates_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ Future<int> test5CallCompute(int value) {
return compute(test5, value);
}

Future<void> expectFileSuccessfullyCompletes(String filename,
[bool unsound = false]) async {
Future<void> expectFileSuccessfullyCompletes(String filename) async {
// Run a Dart script that calls compute().
// The Dart process will terminate only if the script exits cleanly with
// all isolate ports closed.
Expand All @@ -93,12 +92,10 @@ Future<void> expectFileSuccessfullyCompletes(String filename,
final String packageRoot = fs.path.dirname(fs.path.fromUri(platform.script));
final String scriptPath =
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.
final ProcessResult result = await Process.run(
dartPath, <String>[nullSafetyArg, 'run', '--enable-asserts', scriptPath]);
dartPath, <String>['run', '--enable-asserts', scriptPath]);
expect(result.exitCode, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test_private/bin/test_private.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class TestCase {
for (final File test in tests) {
final String testPath = path.join(path.dirname(test.path), 'lib', path.basenameWithoutExtension(test.path));
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,
);
if (result.exitCode != 0) {
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ List<FlutterCommand> generateCommands({
osUtils: globals.os,
verboseHelp: verboseHelp,
androidSdk: globals.androidSdk,
logger: globals.logger,
),
ChannelCommand(verboseHelp: verboseHelp),
CleanCommand(verbose: verbose),
Expand Down
49 changes: 1 addition & 48 deletions packages/flutter_tools/lib/src/artifacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ enum HostArtifact {
webPlatformDart2JSSoundKernelDill,

/// The precompiled SDKs and sourcemaps for web debug builds.
webPrecompiledSdk,
webPrecompiledSdkSourcemaps,
webPrecompiledCanvaskitSdk,
webPrecompiledCanvaskitSdkSourcemaps,
webPrecompiledCanvaskitAndHtmlSdk,
webPrecompiledCanvaskitAndHtmlSdkSourcemaps,
webPrecompiledSoundSdk,
webPrecompiledSoundSdkSourcemaps,
webPrecompiledCanvaskitSoundSdk,
Expand Down Expand Up @@ -248,16 +243,10 @@ String _hostArtifactToFileName(HostArtifact artifact, Platform platform) {
return 'dart2js_platform.dill';
case HostArtifact.flutterWebLibrariesJson:
return 'libraries.json';
case HostArtifact.webPrecompiledSdk:
case HostArtifact.webPrecompiledCanvaskitSdk:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledSoundSdk:
case HostArtifact.webPrecompiledCanvaskitSoundSdk:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSoundSdk:
return 'dart_sdk.js';
case HostArtifact.webPrecompiledSdkSourcemaps:
case HostArtifact.webPrecompiledCanvaskitSdkSourcemaps:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps:
case HostArtifact.webPrecompiledSoundSdkSourcemaps:
case HostArtifact.webPrecompiledCanvaskitSoundSdkSourcemaps:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSoundSdkSourcemaps:
Expand Down Expand Up @@ -407,18 +396,6 @@ class CachedArtifacts implements Artifacts {
case HostArtifact.webPlatformDart2JSSoundKernelDill:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSdk:
case HostArtifact.webPrecompiledSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitSdk:
case HostArtifact.webPrecompiledCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit-html', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSoundSdk:
case HostArtifact.webPrecompiledSoundSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-sound', _hostArtifactToFileName(artifact, _platform));
Expand Down Expand Up @@ -851,18 +828,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
case HostArtifact.webPlatformDart2JSSoundKernelDill:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSdk:
case HostArtifact.webPrecompiledSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitSdk:
case HostArtifact.webPrecompiledCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit-html', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSoundSdk:
case HostArtifact.webPrecompiledSoundSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-sound', _hostArtifactToFileName(artifact, _platform));
Expand Down Expand Up @@ -1153,18 +1118,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
case HostArtifact.webPlatformDart2JSSoundKernelDill:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSdk:
case HostArtifact.webPrecompiledSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitSdk:
case HostArtifact.webPrecompiledCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit-html', _hostArtifactToFileName(artifact, _platform));
return _fileSystem.file(path);
case HostArtifact.webPrecompiledSoundSdk:
case HostArtifact.webPrecompiledSoundSdkSourcemaps:
final String path = _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-sound', _hostArtifactToFileName(artifact, _platform));
Expand Down
6 changes: 0 additions & 6 deletions packages/flutter_tools/lib/src/build_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class BuildInfo {
this.performanceMeasurementFile,
this.dartDefineConfigJsonMap,
this.packagesPath = '.dart_tool/package_config.json', // TODO(zanderso): make this required and remove the default.
this.nullSafetyMode = NullSafetyMode.sound,
this.codeSizeDirectory,
this.androidGradleDaemon = true,
this.packageConfig = PackageConfig.empty,
Expand All @@ -54,11 +53,6 @@ class BuildInfo {

final BuildMode mode;

/// The null safety mode the application should be run in.
///
/// If not provided, defaults to [NullSafetyMode.autodetect].
final NullSafetyMode nullSafetyMode;

/// Whether the build should subset icon fonts.
final bool treeShakeIcons;

Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/commands/attach.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class AttachCommand extends FlutterCommand {
usesDartDefineOption();
usesDeviceUserOption();
addEnableExperimentation(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesInitializeFromDillOption(hide: !verboseHelp);
argParser
..addOption(
Expand Down
Loading

0 comments on commit f4c3fac

Please sign in to comment.