[ddc] Migrate modular test suite runners to null safety
- Migrate the test runner suites to null safety.
- Cleanup old "non-nullable" experiment flags
- Force null safety mode in the two suites:
- modular_suite.dart: weak null safety
- modular_suite_nnbd.dart: sound null safety
NOTE: in both cases the source code is treated as null safe code.
There are no tests written in a legacy dart version.
Change-Id: I19ec25f7b5abc712971771a193c02ebd5283b987
Fixes: https://github.com/dart-lang/sdk/issues/43096
Issue: https://github.com/dart-lang/sdk/issues/46617
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244500
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/test/modular_suite.dart b/pkg/dev_compiler/test/modular_suite.dart
index 1d540ba..1a53fcd 100644
--- a/pkg/dev_compiler/test/modular_suite.dart
+++ b/pkg/dev_compiler/test/modular_suite.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// @dart = 2.9
-
/// Test the modular compilation pipeline of ddc.
///
/// This is a shell that runs multiple tests, one per folder under `data/`.
@@ -18,9 +16,9 @@
String packageConfigJsonPath = '.dart_tool/package_config.json';
Uri sdkRoot = Platform.script.resolve('../../../');
Uri packageConfigUri = sdkRoot.resolve(packageConfigJsonPath);
-Options _options;
-String _dartdevcScript;
-String _kernelWorkerScript;
+late Options _options;
+late String _dartdevcScript;
+late String _kernelWorkerScript;
void main(List<String> args) async {
_options = Options.parse(args);
@@ -89,8 +87,7 @@
extraArgs = [
'--libraries-file',
'$rootScheme:///sdk/lib/libraries.json',
- '--enable-experiment',
- 'non-nullable',
+ '--no-sound-null-safety',
];
assert(transitiveDependencies.isEmpty);
} else {
@@ -175,8 +172,7 @@
'--compile-sdk',
'--libraries-file',
'$rootScheme:///sdk/lib/libraries.json',
- '--enable-experiment',
- 'non-nullable',
+ '--no-sound-null-safety',
];
assert(transitiveDependencies.isEmpty);
} else {
@@ -319,7 +315,7 @@
String _sourceToImportUri(Module module, String rootScheme, Uri relativeUri) {
if (module.isPackage) {
- var basePath = module.packageBase.path;
+ var basePath = module.packageBase!.path;
var packageRelativePath = basePath == './'
? relativeUri.path
: relativeUri.path.substring(basePath.length);
diff --git a/pkg/dev_compiler/test/modular_suite_nnbd.dart b/pkg/dev_compiler/test/modular_suite_nnbd.dart
index 4a19cfb..c5c0567 100644
--- a/pkg/dev_compiler/test/modular_suite_nnbd.dart
+++ b/pkg/dev_compiler/test/modular_suite_nnbd.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// @dart = 2.9
-
/// Test the modular compilation pipeline of ddc.
///
/// This is a shell that runs multiple tests, one per folder under `data/`.
@@ -18,9 +16,9 @@
String packageConfigJsonPath = '.dart_tool/package_config.json';
Uri sdkRoot = Platform.script.resolve('../../../');
Uri packageConfigUri = sdkRoot.resolve(packageConfigJsonPath);
-Options _options;
-String _dartdevcScript;
-String _kernelWorkerScript;
+late Options _options;
+late String _dartdevcScript;
+late String _kernelWorkerScript;
void main(List<String> args) async {
_options = Options.parse(args);
@@ -120,10 +118,7 @@
.where((m) => !m.isSdk)
.expand((m) => ['--input-summary', '${toUri(m, dillId)}']),
...sources.expand((String uri) => ['--source', uri]),
- // TODO(40266) After unfork of dart:_runtime only need experiment when
- // compiling SDK. For now always use the Null Safety experiment.
- '--enable-experiment',
- 'non-nullable',
+ '--sound-null-safety',
...flags.expand((String flag) => ['--enable-experiment', flag]),
];
@@ -206,10 +201,7 @@
rootScheme,
...sources,
...extraArgs,
- // TODO(40266) After unfork of dart:_runtime only need experiment when
- // compiling SDK. For now always use the Null Safety experiment.
- '--enable-experiment',
- 'non-nullable',
+ '--sound-null-safety',
for (String flag in flags) '--enable-experiment=$flag',
...transitiveDependencies
.where((m) => !m.isSdk)
@@ -323,7 +315,7 @@
String _sourceToImportUri(Module module, String rootScheme, Uri relativeUri) {
if (module.isPackage) {
- var basePath = module.packageBase.path;
+ var basePath = module.packageBase!.path;
var packageRelativePath = basePath == './'
? relativeUri.path
: relativeUri.path.substring(basePath.length);