@@ -573,7 +573,9 @@ Future<void> _runExampleProjectBuildTests(Directory exampleDirectory, [File? mai
573
573
// Only verify caching with flutter gallery.
574
574
final bool verifyCaching = exampleDirectory.path.contains ('flutter_gallery' );
575
575
final String examplePath = path.relative (exampleDirectory.path, from: Directory .current.path);
576
+ final bool hasNullSafety = File (path.join (examplePath, 'null_safety' )).existsSync ();
576
577
final List <String > additionalArgs = < String > [
578
+ if (hasNullSafety) '--no-sound-null-safety' ,
577
579
if (mainFile != null ) path.relative (mainFile.path, from: exampleDirectory.absolute.path),
578
580
];
579
581
if (Directory (path.join (examplePath, 'android' )).existsSync ()) {
@@ -769,14 +771,16 @@ Future<void> _runAddToAppLifeCycleTests() async {
769
771
}
770
772
771
773
Future <void > _runFrameworkTests () async {
774
+ final List <String > soundNullSafetyOptions = < String > ['--null-assertions' , '--sound-null-safety' ];
775
+ final List <String > mixedModeNullSafetyOptions = < String > ['--null-assertions' , '--no-sound-null-safety' ];
772
776
final List <String > trackWidgetCreationAlternatives = < String > ['--track-widget-creation' , '--no-track-widget-creation' ];
773
777
774
778
Future <void > runWidgets () async {
775
779
printProgress ('${green }Running packages/flutter tests $reset for ${cyan }test/widgets/$reset ' );
776
780
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
777
781
await _runFlutterTest (
778
782
path.join (flutterRoot, 'packages' , 'flutter' ),
779
- options: < String > [trackWidgetCreationOption],
783
+ options: < String > [trackWidgetCreationOption, ...soundNullSafetyOptions ],
780
784
tests: < String > [ path.join ('test' , 'widgets' ) + path.separator ],
781
785
);
782
786
}
@@ -791,13 +795,13 @@ Future<void> _runFrameworkTests() async {
791
795
// Run release mode tests (see packages/flutter/test_release/README.md)
792
796
await _runFlutterTest (
793
797
path.join (flutterRoot, 'packages' , 'flutter' ),
794
- options: < String > ['--dart-define=dart.vm.product=true' ],
798
+ options: < String > ['--dart-define=dart.vm.product=true' , ...soundNullSafetyOptions ],
795
799
tests: < String > ['test_release${path .separator }' ],
796
800
);
797
801
// Run profile mode tests (see packages/flutter/test_profile/README.md)
798
802
await _runFlutterTest (
799
803
path.join (flutterRoot, 'packages' , 'flutter' ),
800
- options: < String > ['--dart-define=dart.vm.product=false' , '--dart-define=dart.vm.profile=true' ],
804
+ options: < String > ['--dart-define=dart.vm.product=false' , '--dart-define=dart.vm.profile=true' , ...soundNullSafetyOptions ],
801
805
tests: < String > ['test_profile${path .separator }' ],
802
806
);
803
807
}
@@ -813,7 +817,7 @@ Future<void> _runFrameworkTests() async {
813
817
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
814
818
await _runFlutterTest (
815
819
path.join (flutterRoot, 'packages' , 'flutter' ),
816
- options: < String > [trackWidgetCreationOption],
820
+ options: < String > [trackWidgetCreationOption, ...soundNullSafetyOptions ],
817
821
tests: tests,
818
822
);
819
823
}
@@ -833,9 +837,9 @@ Future<void> _runFrameworkTests() async {
833
837
workingDirectory: path.join (flutterRoot, 'examples' , 'api' ),
834
838
);
835
839
}
836
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'api' ));
837
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'hello_world' ));
838
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'layers' ));
840
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'api' ), options : soundNullSafetyOptions );
841
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'hello_world' ), options : soundNullSafetyOptions );
842
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'layers' ), options : soundNullSafetyOptions );
839
843
}
840
844
841
845
Future <void > runTracingTests () async {
@@ -941,6 +945,7 @@ Future<void> _runFrameworkTests() async {
941
945
942
946
Future <void > runPrivateTests () async {
943
947
final List <String > args = < String > [
948
+ '--sound-null-safety' ,
944
949
'run' ,
945
950
'bin/test_private.dart' ,
946
951
];
@@ -984,17 +989,17 @@ Future<void> _runFrameworkTests() async {
984
989
await _runFlutterTest (path.join (flutterRoot, 'dev' , 'tools' , 'gen_defaults' ));
985
990
await _runFlutterTest (path.join (flutterRoot, 'dev' , 'tools' , 'gen_keycodes' ));
986
991
await _runFlutterTest (path.join (flutterRoot, 'dev' , 'benchmarks' , 'test_apps' , 'stocks' ));
987
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_driver' ), tests: < String > [path.join ('test' , 'src' , 'real_tests' )]);
992
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_driver' ), tests: < String > [path.join ('test' , 'src' , 'real_tests' )], options : soundNullSafetyOptions );
988
993
await _runFlutterTest (path.join (flutterRoot, 'packages' , 'integration_test' ), options: < String > [
989
994
'--enable-vmservice' ,
990
995
// Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard.
991
996
'--exclude-tags=web' ,
992
997
]);
993
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_goldens' ));
994
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_localizations' ));
995
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_test' ));
996
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'fuchsia_remote_debug_protocol' ));
997
- await _runFlutterTest (path.join (flutterRoot, 'dev' , 'integration_tests' , 'non_nullable' ));
998
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_goldens' ), options : soundNullSafetyOptions );
999
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_localizations' ), options : soundNullSafetyOptions );
1000
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_test' ), options : soundNullSafetyOptions );
1001
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'fuchsia_remote_debug_protocol' ), options : soundNullSafetyOptions );
1002
+ await _runFlutterTest (path.join (flutterRoot, 'dev' , 'integration_tests' , 'non_nullable' ), options : mixedModeNullSafetyOptions );
998
1003
const String httpClientWarning =
999
1004
'Warning: At least one test in this suite creates an HttpClient. When\n '
1000
1005
'running a test suite that uses TestWidgetsFlutterBinding, all HTTP\n '
@@ -1229,7 +1234,7 @@ Future<void> _runWebLongRunningTests() async {
1229
1234
'--dart-define=TEST_FLUTTER_ENGINE_VERSION=$engineVersion ' ,
1230
1235
]),
1231
1236
() => _runWebDebugTest ('test/test.dart' ),
1232
- () => _runWebDebugTest ('lib/null_safe_main.dart' ),
1237
+ () => _runWebDebugTest ('lib/null_safe_main.dart' , enableNullSafety : true ),
1233
1238
() => _runWebDebugTest ('lib/web_define_loading.dart' ,
1234
1239
additionalArguments: < String > [
1235
1240
'--dart-define=test.valueA=Example,A' ,
@@ -1242,8 +1247,12 @@ Future<void> _runWebLongRunningTests() async {
1242
1247
'--dart-define=test.valueB=Value' ,
1243
1248
]
1244
1249
),
1245
- () => _runWebDebugTest ('lib/sound_mode.dart' ),
1246
- () => _runWebReleaseTest ('lib/sound_mode.dart' ),
1250
+ () => _runWebDebugTest ('lib/sound_mode.dart' , additionalArguments: < String > [
1251
+ '--sound-null-safety' ,
1252
+ ]),
1253
+ () => _runWebReleaseTest ('lib/sound_mode.dart' , additionalArguments: < String > [
1254
+ '--sound-null-safety' ,
1255
+ ]),
1247
1256
() => _runFlutterWebTest (
1248
1257
'html' ,
1249
1258
path.join (flutterRoot, 'packages' , 'integration_test' ),
@@ -1302,6 +1311,7 @@ Future<void> _runFlutterDriverWebTest({
1302
1311
if (driver != null ) '--driver=$driver ' ,
1303
1312
'--target=$target ' ,
1304
1313
'--browser-name=chrome' ,
1314
+ '--no-sound-null-safety' ,
1305
1315
'-d' ,
1306
1316
'web-server' ,
1307
1317
'--$buildMode ' ,
@@ -1343,6 +1353,7 @@ Future<void> _runWebTreeshakeTest() async {
1343
1353
'build' ,
1344
1354
'web' ,
1345
1355
'--target=$target ' ,
1356
+ '--no-sound-null-safety' ,
1346
1357
'--profile' ,
1347
1358
],
1348
1359
workingDirectory: testAppDirectory,
@@ -1568,6 +1579,7 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
1568
1579
'--driver=test_driver/transitions_perf_e2e_test.dart' ,
1569
1580
'--target=test_driver/transitions_perf_e2e.dart' ,
1570
1581
'--browser-name=chrome' ,
1582
+ '--no-sound-null-safety' ,
1571
1583
'-d' ,
1572
1584
'web-server' ,
1573
1585
'--$buildMode ' ,
@@ -1674,6 +1686,7 @@ Future<void> _runWebReleaseTest(String target, {
1674
1686
///
1675
1687
/// Instead, we use `flutter run --debug` and sniff out the standard output.
1676
1688
Future <void > _runWebDebugTest (String target, {
1689
+ bool enableNullSafety = false ,
1677
1690
List <String > additionalArguments = const < String > [],
1678
1691
}) async {
1679
1692
final String testAppDirectory = path.join (flutterRoot, 'dev' , 'integration_tests' , 'web' );
@@ -1687,6 +1700,11 @@ Future<void> _runWebDebugTest(String target, {
1687
1700
< String > [
1688
1701
'run' ,
1689
1702
'--debug' ,
1703
+ if (enableNullSafety)
1704
+ ...< String > [
1705
+ '--no-sound-null-safety' ,
1706
+ '--null-assertions' ,
1707
+ ],
1690
1708
'-d' ,
1691
1709
'chrome' ,
1692
1710
'--web-run-headless' ,
@@ -1729,6 +1747,7 @@ Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, Lis
1729
1747
'--platform=chrome' ,
1730
1748
'--web-renderer=$webRenderer ' ,
1731
1749
'--dart-define=DART_HHH_BOT=$_runningInDartHHHBot ' ,
1750
+ '--sound-null-safety' ,
1732
1751
...flutterTestArgs,
1733
1752
...tests,
1734
1753
],
0 commit comments