Skip to content

Commit

Permalink
Explicitly pass the web renderer into the tests. (flutter#6140)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
eyebrowsoffire authored Feb 15, 2024
1 parent e650b10 commit dcbaee5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
7 changes: 5 additions & 2 deletions script/tool/lib/src/dart_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ class DartTestCommand extends PackageLoopingCommand {
platform = 'chrome';
}

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

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

final int exitCode = await processRunner.runAndStream(
Expand All @@ -121,6 +123,7 @@ class DartTestCommand extends PackageLoopingCommand {
// Flutter defaults to VM mode (under a different name) and explicitly
// setting it is deprecated, so pass nothing in that case.
if (platform != null && platform != 'vm') '--platform=$platform',
if (webRenderer != null) '--web-renderer=$webRenderer',
],
workingDir: package.directory,
);
Expand Down
1 change: 1 addition & 0 deletions script/tool/lib/src/drive_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
if (platform.environment.containsKey('CHROME_EXECUTABLE'))
'--chrome-binary=${platform.environment['CHROME_EXECUTABLE']}',
],
Expand Down
10 changes: 5 additions & 5 deletions script/tool/test/dart_test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void main() {
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
package.path),
]),
);
Expand All @@ -289,7 +289,7 @@ void main() {
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
plugin.path),
]),
);
Expand All @@ -314,7 +314,7 @@ void main() {
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
plugin.path),
]),
);
Expand All @@ -339,7 +339,7 @@ void main() {
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
plugin.path),
]),
);
Expand Down Expand Up @@ -409,7 +409,7 @@ void main() {
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
const <String>['test', '--color', '--platform=chrome', '--web-renderer=html'],
plugin.path),
]),
);
Expand Down
7 changes: 7 additions & 0 deletions script/tool/test/drive_examples_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand Down Expand Up @@ -726,6 +727,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand Down Expand Up @@ -777,6 +779,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--chrome-binary=/path/to/chrome',
'--driver',
'test_driver/integration_test.dart',
Expand Down Expand Up @@ -1223,6 +1226,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand All @@ -1237,6 +1241,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand Down Expand Up @@ -1334,6 +1339,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand Down Expand Up @@ -1413,6 +1419,7 @@ void main() {
'web-server',
'--web-port=7357',
'--browser-name=chrome',
'--web-renderer=html',
'--driver',
'test_driver/integration_test.dart',
'--target',
Expand Down

0 comments on commit dcbaee5

Please sign in to comment.