@@ -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 '
@@ -1224,7 +1229,7 @@ Future<void> _runWebLongRunningTests() async {
1224
1229
() => _runWebDebugTest ('lib/framework_stack_trace.dart' ),
1225
1230
() => _runWebDebugTest ('lib/web_directory_loading.dart' ),
1226
1231
() => _runWebDebugTest ('test/test.dart' ),
1227
- () => _runWebDebugTest ('lib/null_safe_main.dart' ),
1232
+ () => _runWebDebugTest ('lib/null_safe_main.dart' , enableNullSafety : true ),
1228
1233
() => _runWebDebugTest ('lib/web_define_loading.dart' ,
1229
1234
additionalArguments: < String > [
1230
1235
'--dart-define=test.valueA=Example,A' ,
@@ -1237,8 +1242,12 @@ Future<void> _runWebLongRunningTests() async {
1237
1242
'--dart-define=test.valueB=Value' ,
1238
1243
]
1239
1244
),
1240
- () => _runWebDebugTest ('lib/sound_mode.dart' ),
1241
- () => _runWebReleaseTest ('lib/sound_mode.dart' ),
1245
+ () => _runWebDebugTest ('lib/sound_mode.dart' , additionalArguments: < String > [
1246
+ '--sound-null-safety' ,
1247
+ ]),
1248
+ () => _runWebReleaseTest ('lib/sound_mode.dart' , additionalArguments: < String > [
1249
+ '--sound-null-safety' ,
1250
+ ]),
1242
1251
() => _runFlutterWebTest (
1243
1252
'html' ,
1244
1253
path.join (flutterRoot, 'packages' , 'integration_test' ),
@@ -1297,6 +1306,7 @@ Future<void> _runFlutterDriverWebTest({
1297
1306
if (driver != null ) '--driver=$driver ' ,
1298
1307
'--target=$target ' ,
1299
1308
'--browser-name=chrome' ,
1309
+ '--no-sound-null-safety' ,
1300
1310
'-d' ,
1301
1311
'web-server' ,
1302
1312
'--$buildMode ' ,
@@ -1338,6 +1348,7 @@ Future<void> _runWebTreeshakeTest() async {
1338
1348
'build' ,
1339
1349
'web' ,
1340
1350
'--target=$target ' ,
1351
+ '--no-sound-null-safety' ,
1341
1352
'--profile' ,
1342
1353
],
1343
1354
workingDirectory: testAppDirectory,
@@ -1563,6 +1574,7 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
1563
1574
'--driver=test_driver/transitions_perf_e2e_test.dart' ,
1564
1575
'--target=test_driver/transitions_perf_e2e.dart' ,
1565
1576
'--browser-name=chrome' ,
1577
+ '--no-sound-null-safety' ,
1566
1578
'-d' ,
1567
1579
'web-server' ,
1568
1580
'--$buildMode ' ,
@@ -1669,6 +1681,7 @@ Future<void> _runWebReleaseTest(String target, {
1669
1681
///
1670
1682
/// Instead, we use `flutter run --debug` and sniff out the standard output.
1671
1683
Future <void > _runWebDebugTest (String target, {
1684
+ bool enableNullSafety = false ,
1672
1685
List <String > additionalArguments = const < String > [],
1673
1686
}) async {
1674
1687
final String testAppDirectory = path.join (flutterRoot, 'dev' , 'integration_tests' , 'web' );
@@ -1682,6 +1695,11 @@ Future<void> _runWebDebugTest(String target, {
1682
1695
< String > [
1683
1696
'run' ,
1684
1697
'--debug' ,
1698
+ if (enableNullSafety)
1699
+ ...< String > [
1700
+ '--no-sound-null-safety' ,
1701
+ '--null-assertions' ,
1702
+ ],
1685
1703
'-d' ,
1686
1704
'chrome' ,
1687
1705
'--web-run-headless' ,
@@ -1724,6 +1742,7 @@ Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, Lis
1724
1742
'--platform=chrome' ,
1725
1743
'--web-renderer=$webRenderer ' ,
1726
1744
'--dart-define=DART_HHH_BOT=$_runningInDartHHHBot ' ,
1745
+ '--sound-null-safety' ,
1727
1746
...flutterTestArgs,
1728
1747
...tests,
1729
1748
],
0 commit comments