From dfcc4ce1cae69a6e881717b9c409eade2fb75f0f Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 15 Feb 2024 11:34:05 -0800 Subject: [PATCH 1/3] Explicitly pass the web renderer into the tests. --- script/tool/lib/src/dart_test_command.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/tool/lib/src/dart_test_command.dart b/script/tool/lib/src/dart_test_command.dart index df0ee71400b..b64f36fcae0 100644 --- a/script/tool/lib/src/dart_test_command.dart +++ b/script/tool/lib/src/dart_test_command.dart @@ -70,6 +70,7 @@ class DartTestCommand extends PackageLoopingCommand { platformWeb, package, requiredMode: PlatformSupport.inline) && package.directory.basename.endsWith('_web'); + final String? webRenderer; if (webPlatform) { if (isFlutterPlugin(package) && !pluginSupportsPlatform(platformWeb, package)) { @@ -98,6 +99,11 @@ class DartTestCommand extends PackageLoopingCommand { platform = 'chrome'; } + if (platform == 'chrome') { + // All the web tests assume the html renderer currently. + webRenderer = 'html'; + } + bool passed; if (package.requiresFlutter()) { passed = await _runFlutterTests(package, platform: platform); @@ -129,7 +135,7 @@ class DartTestCommand extends PackageLoopingCommand { /// Runs the Dart tests for a non-Flutter package, returning true on success. Future _runDartTests(RepositoryPackage package, - {String? platform}) async { + {String? platform, String? webRenderer}) async { // Unlike `flutter test`, `dart run test` does not automatically get // packages if (!await runPubGet(package, processRunner, super.platform)) { @@ -146,6 +152,7 @@ class DartTestCommand extends PackageLoopingCommand { if (experiment.isNotEmpty) '--enable-experiment=$experiment', 'test', if (platform != null) '--platform=$platform', + if (webRenderer != null) '--web-renderer=$webRenderer', ], workingDir: package.directory, ); From 7fbd44922a928eacfdc166c1a927ae6fd80b3b5c Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 15 Feb 2024 12:40:55 -0800 Subject: [PATCH 2/3] Fix unit tests. --- script/tool/lib/src/dart_test_command.dart | 16 ++++++---------- script/tool/test/dart_test_command_test.dart | 10 +++++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/script/tool/lib/src/dart_test_command.dart b/script/tool/lib/src/dart_test_command.dart index b64f36fcae0..1c188ff38ad 100644 --- a/script/tool/lib/src/dart_test_command.dart +++ b/script/tool/lib/src/dart_test_command.dart @@ -70,7 +70,6 @@ class DartTestCommand extends PackageLoopingCommand { platformWeb, package, requiredMode: PlatformSupport.inline) && package.directory.basename.endsWith('_web'); - final String? webRenderer; if (webPlatform) { if (isFlutterPlugin(package) && !pluginSupportsPlatform(platformWeb, package)) { @@ -99,14 +98,11 @@ class DartTestCommand extends PackageLoopingCommand { platform = 'chrome'; } - if (platform == 'chrome') { - // All the web tests assume the html renderer currently. - webRenderer = 'html'; - } - + // 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); } @@ -115,7 +111,7 @@ class DartTestCommand extends PackageLoopingCommand { /// Runs the Dart tests for a Flutter package, returning true on success. Future _runFlutterTests(RepositoryPackage package, - {String? platform}) async { + {String? platform, String? webRenderer}) async { final String experiment = getStringArg(kEnableExperiment); final int exitCode = await processRunner.runAndStream( @@ -127,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, ); @@ -135,7 +132,7 @@ class DartTestCommand extends PackageLoopingCommand { /// Runs the Dart tests for a non-Flutter package, returning true on success. Future _runDartTests(RepositoryPackage package, - {String? platform, String? webRenderer}) async { + {String? platform}) async { // Unlike `flutter test`, `dart run test` does not automatically get // packages if (!await runPubGet(package, processRunner, super.platform)) { @@ -152,7 +149,6 @@ class DartTestCommand extends PackageLoopingCommand { if (experiment.isNotEmpty) '--enable-experiment=$experiment', 'test', if (platform != null) '--platform=$platform', - if (webRenderer != null) '--web-renderer=$webRenderer', ], workingDir: package.directory, ); diff --git a/script/tool/test/dart_test_command_test.dart b/script/tool/test/dart_test_command_test.dart index 5752d7439eb..d56bb44b0fb 100644 --- a/script/tool/test/dart_test_command_test.dart +++ b/script/tool/test/dart_test_command_test.dart @@ -265,7 +265,7 @@ void main() { orderedEquals([ ProcessCall( getFlutterCommand(mockPlatform), - const ['test', '--color', '--platform=chrome'], + const ['test', '--color', '--platform=chrome', '--web-renderer=html'], package.path), ]), ); @@ -289,7 +289,7 @@ void main() { orderedEquals([ ProcessCall( getFlutterCommand(mockPlatform), - const ['test', '--color', '--platform=chrome'], + const ['test', '--color', '--platform=chrome', '--web-renderer=html'], plugin.path), ]), ); @@ -314,7 +314,7 @@ void main() { orderedEquals([ ProcessCall( getFlutterCommand(mockPlatform), - const ['test', '--color', '--platform=chrome'], + const ['test', '--color', '--platform=chrome', '--web-renderer=html'], plugin.path), ]), ); @@ -339,7 +339,7 @@ void main() { orderedEquals([ ProcessCall( getFlutterCommand(mockPlatform), - const ['test', '--color', '--platform=chrome'], + const ['test', '--color', '--platform=chrome', '--web-renderer=html'], plugin.path), ]), ); @@ -409,7 +409,7 @@ void main() { orderedEquals([ ProcessCall( getFlutterCommand(mockPlatform), - const ['test', '--color', '--platform=chrome'], + const ['test', '--color', '--platform=chrome', '--web-renderer=html'], plugin.path), ]), ); From 771c1d21c1188127de0b227c02cf1c3f2e6523e5 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 15 Feb 2024 13:35:00 -0800 Subject: [PATCH 3/3] Also explicitly pass renderer for `flutter drive`. --- script/tool/lib/src/drive_examples_command.dart | 1 + script/tool/test/drive_examples_command_test.dart | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index ff73044f6c1..f3baa5c7cee 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -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']}', ], diff --git a/script/tool/test/drive_examples_command_test.dart b/script/tool/test/drive_examples_command_test.dart index 60df1b70ae3..92d4921a0b3 100644 --- a/script/tool/test/drive_examples_command_test.dart +++ b/script/tool/test/drive_examples_command_test.dart @@ -678,6 +678,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target', @@ -726,6 +727,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target', @@ -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', @@ -1223,6 +1226,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target', @@ -1237,6 +1241,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target', @@ -1334,6 +1339,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target', @@ -1413,6 +1419,7 @@ void main() { 'web-server', '--web-port=7357', '--browser-name=chrome', + '--web-renderer=html', '--driver', 'test_driver/integration_test.dart', '--target',