[null-safety] add integration tests for sound null safety modes, add support for sound null safety in dart2js (#67171)
Add integration tests to verify that ddc and dart2js can be built and run in sound mode. Updates dart2js compilation to insert a language version comment into the generated entrypoint if necessary.
dart-lang/sdk#42253
diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index e785f40..3de74c6 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -765,6 +765,16 @@
'--dart-define=test.valueB=Value',
]
);
+ await _runWebDebugTest('lib/sound_mode.dart', additionalArguments: <String>[
+ '--enable-experiment',
+ 'non-nullable',
+ '--sound-null-safety',
+ ]);
+ await _runWebReleaseTest('lib/sound_mode.dart', additionalArguments: <String>[
+ '--enable-experiment',
+ 'non-nullable',
+ '--sound-null-safety',
+ ]);
}
Future<void> _runWebStackTraceTest(String buildMode) async {
diff --git a/dev/integration_tests/web/analysis_options.yaml b/dev/integration_tests/web/analysis_options.yaml
index 8c534b5..a6c220d 100644
--- a/dev/integration_tests/web/analysis_options.yaml
+++ b/dev/integration_tests/web/analysis_options.yaml
@@ -3,3 +3,4 @@
analyzer:
exclude:
- lib/null_safe_main.dart
+ - lib/sound_mode.dart
diff --git a/dev/integration_tests/web/lib/sound_mode.dart b/dev/integration_tests/web/lib/sound_mode.dart
new file mode 100644
index 0000000..a507692
--- /dev/null
+++ b/dev/integration_tests/web/lib/sound_mode.dart
@@ -0,0 +1,24 @@
+// 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.
+
+// @dart=2.10
+
+import 'dart:html' as html;
+
+// Verify that web applications can be run in sound mode.
+void main() {
+ const isWeak = <int?>[] is List<int>;
+ String output;
+ if (isWeak) {
+ output = '--- TEST FAILED ---';
+ } else {
+ output = '--- TEST SUCCEEDED ---';
+ }
+ print(output);
+ html.HttpRequest.request(
+ '/test-result',
+ method: 'POST',
+ sendData: '$output',
+ );
+}