From 8cf4d96f474f49e31739887dd61bf2cfd09fcbea Mon Sep 17 00:00:00 2001 From: David Iglesias Date: Wed, 17 Jul 2024 14:52:24 -0700 Subject: [PATCH] [ci] Drive tests with html renderer if CHANNEL is stable. (#7146) Introduces a small fork in the `drive_examples_command` to run integration tests with `--web-renderer=html` in the `stable` channel (and `--web-renderer=canvaskit` in `master`). This is supposed to be removed, once the current `master` rolls into `stable` (see clean-up issue referenced below). ## Issues * Part of: https://github.com/flutter/flutter/issues/143543 * Prevents flakes: https://github.com/flutter/packages/pull/7115#issuecomment-2226661488 * Clean-up issue: https://github.com/flutter/flutter/issues/151869 --- .../tool/lib/src/drive_examples_command.dart | 6 +- .../test/drive_examples_command_test.dart | 57 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index d30e1835fe..984bff7c8b 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -119,7 +119,11 @@ class DriveExamplesCommand extends PackageLoopingCommand { 'web-server', '--web-port=7357', '--browser-name=chrome', - '--web-renderer=canvaskit', + // TODO(dit): Clean this up, https://github.com/flutter/flutter/issues/151869 + if (platform.environment['CHANNEL']?.toLowerCase() == 'master') + '--web-renderer=canvaskit', + if (platform.environment['CHANNEL']?.toLowerCase() != 'master') + '--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 486bc2eada..4484b7099a 100644 --- a/script/tool/test/drive_examples_command_test.dart +++ b/script/tool/test/drive_examples_command_test.dart @@ -38,6 +38,9 @@ void main() { runner = CommandRunner( 'drive_examples_command', 'Test for drive_example_command'); runner.addCommand(command); + + // TODO(dit): Clean this up, https://github.com/flutter/flutter/issues/151869 + mockPlatform.environment['CHANNEL'] = 'master'; }); void setMockFlutterDevicesOutput({ @@ -688,6 +691,60 @@ void main() { ])); }); + // TODO(dit): Clean this up, https://github.com/flutter/flutter/issues/151869 + test('drives a web plugin (html renderer in stable)', () async { + // Override the platform to simulate CHANNEL: stable + mockPlatform.environment['CHANNEL'] = 'stable'; + + final RepositoryPackage plugin = createFakePlugin( + 'plugin', + packagesDir, + extraFiles: [ + 'example/integration_test/plugin_test.dart', + 'example/test_driver/integration_test.dart', + 'example/web/index.html', + ], + platformSupport: { + platformWeb: const PlatformDetails(PlatformSupport.inline), + }, + ); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + final List output = await runCapturingPrint(runner, [ + 'drive-examples', + '--web', + ]); + + expect( + output, + containsAllInOrder([ + contains('Running for plugin'), + contains('No issues found!'), + ]), + ); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + getFlutterCommand(mockPlatform), + const [ + 'drive', + '-d', + 'web-server', + '--web-port=7357', + '--browser-name=chrome', + '--web-renderer=html', + '--driver', + 'test_driver/integration_test.dart', + '--target', + 'integration_test/plugin_test.dart', + ], + pluginExampleDirectory.path), + ])); + }); + test('runs chromedriver when requested', () async { final RepositoryPackage plugin = createFakePlugin( 'plugin',