@@ -74,13 +74,66 @@ const String kSubshardKey = 'SUBSHARD';
74
74
int get webShardCount => Platform .environment.containsKey ('WEB_SHARD_COUNT' )
75
75
? int .parse (Platform .environment['WEB_SHARD_COUNT' ]! )
76
76
: 8 ;
77
- /// Tests that we don't run on Web for compilation reasons.
77
+
78
+ /// Tests that we don't run on Web.
79
+ ///
80
+ /// In general avoid adding new tests here. If a test cannot run on the web
81
+ /// because it fails at runtime, such as when a piece of functionality is not
82
+ /// implemented or not implementable on the web, prefer using `skip` in the
83
+ /// test code. Only add tests here that cannot be skipped using `skip` . For
84
+ /// example:
85
+ ///
86
+ /// * Test code cannot be compiled because it uses Dart VM-specific
87
+ /// functionality. In this case `skip` doesn't help because the code cannot
88
+ /// reach the point where it can even run the skipping logic.
89
+ /// * Migrations. It is OK to put tests here that need to be temporarily
90
+ /// disabled in certain modes because of some migration or initial bringup.
91
+ ///
92
+ /// The key in the map is the renderer type that the list applies to. The value
93
+ /// is the list of tests known to fail for that renderer.
78
94
//
79
95
// TODO(yjbanov): we're getting rid of this as part of https://github.com/flutter/flutter/projects/60
80
- const List <String > kWebTestFileKnownFailures = < String > [
81
- 'test/services/message_codecs_vm_test.dart' ,
82
- 'test/examples/sector_layout_test.dart' ,
83
- ];
96
+ const Map <String , List <String >> kWebTestFileKnownFailures = < String , List <String >> {
97
+ 'html' : < String > [
98
+ // These tests are not compilable on the web due to dependencies on
99
+ // VM-specific functionality.
100
+ 'test/services/message_codecs_vm_test.dart' ,
101
+ 'test/examples/sector_layout_test.dart' ,
102
+ ],
103
+ 'canvaskit' : < String > [
104
+ // These tests are not compilable on the web due to dependencies on
105
+ // VM-specific functionality.
106
+ 'test/services/message_codecs_vm_test.dart' ,
107
+ 'test/examples/sector_layout_test.dart' ,
108
+
109
+ // These tests are broken and need to be fixed.
110
+ // TODO(yjbanov): https://github.com/flutter/flutter/issues/71604
111
+ 'test/painting/decoration_test.dart' ,
112
+ 'test/material/text_selection_theme_test.dart' ,
113
+ 'test/material/date_picker_test.dart' ,
114
+ 'test/rendering/layers_test.dart' ,
115
+ 'test/painting/text_style_test.dart' ,
116
+ 'test/widgets/image_test.dart' ,
117
+ 'test/cupertino/colors_test.dart' ,
118
+ 'test/cupertino/slider_test.dart' ,
119
+ 'test/material/text_field_test.dart' ,
120
+ 'test/rendering/proxy_box_test.dart' ,
121
+ 'test/widgets/app_overrides_test.dart' ,
122
+ 'test/material/calendar_date_picker_test.dart' ,
123
+ 'test/material/ink_paint_test.dart' ,
124
+ 'test/rendering/editable_test.dart' ,
125
+ 'test/cupertino/dialog_test.dart' ,
126
+ 'test/widgets/shape_decoration_test.dart' ,
127
+ 'test/material/time_picker_theme_test.dart' ,
128
+ 'test/cupertino/picker_test.dart' ,
129
+ 'test/material/chip_theme_test.dart' ,
130
+ 'test/cupertino/nav_bar_test.dart' ,
131
+ 'test/widgets/performance_overlay_test.dart' ,
132
+ 'test/widgets/html_element_view_test.dart' ,
133
+ 'test/cupertino/scaffold_test.dart' ,
134
+ 'test/rendering/platform_view_test.dart' ,
135
+ ],
136
+ };
84
137
85
138
const String kSmokeTestShardName = 'smoke_tests' ;
86
139
const List <String > _kAllBuildModes = < String > ['debug' , 'profile' , 'release' ];
@@ -143,8 +196,10 @@ Future<void> main(List<String> args) async {
143
196
// web_tool_tests is also used by HHH: https://dart.googlesource.com/recipes/+/refs/heads/master/recipes/dart/flutter_engine.py
144
197
'web_tool_tests' : _runWebToolTests,
145
198
'tool_integration_tests' : _runIntegrationToolTests,
146
- // All the unit/widget tests run using `flutter test --platform=chrome`
147
- 'web_tests' : _runWebUnitTests,
199
+ // All the unit/widget tests run using `flutter test --platform=chrome --web-renderer=html`
200
+ 'web_tests' : _runWebHtmlUnitTests,
201
+ // All the unit/widget tests run using `flutter test --platform=chrome --web-renderer=canvaskit`
202
+ 'web_canvaskit_tests' : _runWebCanvasKitUnitTests,
148
203
// All web integration tests
149
204
'web_long_running_tests' : _runWebLongRunningTests,
150
205
'flutter_plugins' : _runFlutterPluginsTests,
@@ -802,7 +857,15 @@ Future<void> _runFrameworkCoverage() async {
802
857
}
803
858
}
804
859
805
- Future <void > _runWebUnitTests () async {
860
+ Future <void > _runWebHtmlUnitTests () {
861
+ return _runWebUnitTests ('html' );
862
+ }
863
+
864
+ Future <void > _runWebCanvasKitUnitTests () {
865
+ return _runWebUnitTests ('canvaskit' );
866
+ }
867
+
868
+ Future <void > _runWebUnitTests (String webRenderer) async {
806
869
final Map <String , ShardRunner > subshards = < String , ShardRunner > {};
807
870
808
871
final Directory flutterPackageDirectory = Directory (path.join (flutterRoot, 'packages' , 'flutter' ));
@@ -817,7 +880,7 @@ Future<void> _runWebUnitTests() async {
817
880
)
818
881
.whereType <File >()
819
882
.map <String >((File file) => path.relative (file.path, from: flutterPackageDirectory.path))
820
- .where ((String filePath) => ! kWebTestFileKnownFailures.contains (path.split (filePath).join ('/' )))
883
+ .where ((String filePath) => ! kWebTestFileKnownFailures[webRenderer] ! .contains (path.split (filePath).join ('/' )))
821
884
.toList ()
822
885
// Finally we shuffle the list because we want the average cost per file to be uniformly
823
886
// distributed. If the list is not sorted then different shards and batches may have
@@ -832,6 +895,7 @@ Future<void> _runWebUnitTests() async {
832
895
// This for loop computes all but the last shard.
833
896
for (int index = 0 ; index < webShardCount - 1 ; index += 1 ) {
834
897
subshards['$index ' ] = () => _runFlutterWebTest (
898
+ webRenderer,
835
899
flutterPackageDirectory.path,
836
900
allTests.sublist (
837
901
index * testsPerShard,
@@ -846,19 +910,22 @@ Future<void> _runWebUnitTests() async {
846
910
// between `.cirrus.yml` and `test.dart`.
847
911
subshards['${webShardCount - 1 }_last' ] = () async {
848
912
await _runFlutterWebTest (
913
+ webRenderer,
849
914
flutterPackageDirectory.path,
850
915
allTests.sublist (
851
916
(webShardCount - 1 ) * testsPerShard,
852
917
allTests.length,
853
918
),
854
919
);
855
920
await _runFlutterWebTest (
921
+ webRenderer,
856
922
path.join (flutterRoot, 'packages' , 'flutter_web_plugins' ),
857
923
< String > ['test' ],
858
924
);
859
925
await _runFlutterWebTest (
860
- path.join (flutterRoot, 'packages' , 'flutter_driver' ),
861
- < String > [path.join ('test' , 'src' , 'web_tests' , 'web_extension_test.dart' )],
926
+ webRenderer,
927
+ path.join (flutterRoot, 'packages' , 'flutter_driver' ),
928
+ < String > [path.join ('test' , 'src' , 'web_tests' , 'web_extension_test.dart' )],
862
929
);
863
930
};
864
931
@@ -1421,7 +1488,7 @@ Future<void> _runWebDebugTest(String target, {
1421
1488
}
1422
1489
}
1423
1490
1424
- Future <void > _runFlutterWebTest (String workingDirectory, List <String > tests) async {
1491
+ Future <void > _runFlutterWebTest (String webRenderer, String workingDirectory, List <String > tests) async {
1425
1492
await runCommand (
1426
1493
flutter,
1427
1494
< String > [
@@ -1430,9 +1497,8 @@ Future<void> _runFlutterWebTest(String workingDirectory, List<String> tests) asy
1430
1497
'--concurrency=1' , // do not parallelize on Cirrus, to reduce flakiness
1431
1498
'-v' ,
1432
1499
'--platform=chrome' ,
1433
- // TODO(ferhatb): Run web tests with both rendering backends.
1434
- '--web-renderer=html' , // use html backend for web tests.
1435
- '--sound-null-safety' , // web tests do not autodetect yet.
1500
+ '--web-renderer=$webRenderer ' ,
1501
+ '--sound-null-safety' ,
1436
1502
...flutterTestArgs,
1437
1503
...tests,
1438
1504
],
0 commit comments