Skip to content

Commit dcbaee5

Browse files
Explicitly pass the web renderer into the tests. (flutter#6140)
The web tests currently all assume to be using the html renderer. `flutter test` previously erroneously was serving files for the HTML renderer by default (which is not the intended behavior). After this was fixed, the tests started running on the CanvasKit renderer and some of them broke. If we are relying on the html renderer, we should explicitly pass it when running `flutter test`
1 parent e650b10 commit dcbaee5

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

script/tool/lib/src/dart_test_command.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ class DartTestCommand extends PackageLoopingCommand {
9898
platform = 'chrome';
9999
}
100100

101+
// All the web tests assume the html renderer currently.
102+
final String? webRenderer = (platform == 'chrome') ? 'html' : null;
101103
bool passed;
102104
if (package.requiresFlutter()) {
103-
passed = await _runFlutterTests(package, platform: platform);
105+
passed = await _runFlutterTests(package, platform: platform, webRenderer: webRenderer);
104106
} else {
105107
passed = await _runDartTests(package, platform: platform);
106108
}
@@ -109,7 +111,7 @@ class DartTestCommand extends PackageLoopingCommand {
109111

110112
/// Runs the Dart tests for a Flutter package, returning true on success.
111113
Future<bool> _runFlutterTests(RepositoryPackage package,
112-
{String? platform}) async {
114+
{String? platform, String? webRenderer}) async {
113115
final String experiment = getStringArg(kEnableExperiment);
114116

115117
final int exitCode = await processRunner.runAndStream(
@@ -121,6 +123,7 @@ class DartTestCommand extends PackageLoopingCommand {
121123
// Flutter defaults to VM mode (under a different name) and explicitly
122124
// setting it is deprecated, so pass nothing in that case.
123125
if (platform != null && platform != 'vm') '--platform=$platform',
126+
if (webRenderer != null) '--web-renderer=$webRenderer',
124127
],
125128
workingDir: package.directory,
126129
);

script/tool/lib/src/drive_examples_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
119119
'web-server',
120120
'--web-port=7357',
121121
'--browser-name=chrome',
122+
'--web-renderer=html',
122123
if (platform.environment.containsKey('CHROME_EXECUTABLE'))
123124
'--chrome-binary=${platform.environment['CHROME_EXECUTABLE']}',
124125
],

script/tool/test/dart_test_command_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void main() {
265265
orderedEquals(<ProcessCall>[
266266
ProcessCall(
267267
getFlutterCommand(mockPlatform),
268-
const <String>['test', '--color', '--platform=chrome'],
268+
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
269269
package.path),
270270
]),
271271
);
@@ -289,7 +289,7 @@ void main() {
289289
orderedEquals(<ProcessCall>[
290290
ProcessCall(
291291
getFlutterCommand(mockPlatform),
292-
const <String>['test', '--color', '--platform=chrome'],
292+
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
293293
plugin.path),
294294
]),
295295
);
@@ -314,7 +314,7 @@ void main() {
314314
orderedEquals(<ProcessCall>[
315315
ProcessCall(
316316
getFlutterCommand(mockPlatform),
317-
const <String>['test', '--color', '--platform=chrome'],
317+
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
318318
plugin.path),
319319
]),
320320
);
@@ -339,7 +339,7 @@ void main() {
339339
orderedEquals(<ProcessCall>[
340340
ProcessCall(
341341
getFlutterCommand(mockPlatform),
342-
const <String>['test', '--color', '--platform=chrome'],
342+
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
343343
plugin.path),
344344
]),
345345
);
@@ -409,7 +409,7 @@ void main() {
409409
orderedEquals(<ProcessCall>[
410410
ProcessCall(
411411
getFlutterCommand(mockPlatform),
412-
const <String>['test', '--color', '--platform=chrome'],
412+
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
413413
plugin.path),
414414
]),
415415
);

script/tool/test/drive_examples_command_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ void main() {
678678
'web-server',
679679
'--web-port=7357',
680680
'--browser-name=chrome',
681+
'--web-renderer=html',
681682
'--driver',
682683
'test_driver/integration_test.dart',
683684
'--target',
@@ -726,6 +727,7 @@ void main() {
726727
'web-server',
727728
'--web-port=7357',
728729
'--browser-name=chrome',
730+
'--web-renderer=html',
729731
'--driver',
730732
'test_driver/integration_test.dart',
731733
'--target',
@@ -777,6 +779,7 @@ void main() {
777779
'web-server',
778780
'--web-port=7357',
779781
'--browser-name=chrome',
782+
'--web-renderer=html',
780783
'--chrome-binary=/path/to/chrome',
781784
'--driver',
782785
'test_driver/integration_test.dart',
@@ -1223,6 +1226,7 @@ void main() {
12231226
'web-server',
12241227
'--web-port=7357',
12251228
'--browser-name=chrome',
1229+
'--web-renderer=html',
12261230
'--driver',
12271231
'test_driver/integration_test.dart',
12281232
'--target',
@@ -1237,6 +1241,7 @@ void main() {
12371241
'web-server',
12381242
'--web-port=7357',
12391243
'--browser-name=chrome',
1244+
'--web-renderer=html',
12401245
'--driver',
12411246
'test_driver/integration_test.dart',
12421247
'--target',
@@ -1334,6 +1339,7 @@ void main() {
13341339
'web-server',
13351340
'--web-port=7357',
13361341
'--browser-name=chrome',
1342+
'--web-renderer=html',
13371343
'--driver',
13381344
'test_driver/integration_test.dart',
13391345
'--target',
@@ -1413,6 +1419,7 @@ void main() {
14131419
'web-server',
14141420
'--web-port=7357',
14151421
'--browser-name=chrome',
1422+
'--web-renderer=html',
14161423
'--driver',
14171424
'test_driver/integration_test.dart',
14181425
'--target',

0 commit comments

Comments
 (0)