Skip to content

Commit 2068cce

Browse files
Enable web integration tests in CI (flutter#3738)
1 parent 67bdfcb commit 2068cce

File tree

4 files changed

+134
-80
lines changed

4 files changed

+134
-80
lines changed

.ci/Dockerfile-LegacyChrome

Lines changed: 0 additions & 29 deletions
This file was deleted.

.cirrus.yml

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ task:
9393
CHANNEL: "stable"
9494
script:
9595
- ./script/build_all_plugins_app.sh web
96-
- name: build-web-examples
97-
env:
98-
matrix:
99-
CHANNEL: "master"
100-
build_script:
101-
- ./script/incremental_build.sh build-examples --web
102-
# TODO: Add driving examples (and move to heavy-workload group).
10396
### Linux desktop tasks ###
10497
- name: build_all_plugins_linux
10598
env:
@@ -117,35 +110,8 @@ task:
117110
build_script:
118111
- flutter config --enable-linux-desktop
119112
- ./script/incremental_build.sh build-examples --linux
120-
- xvfb-run ./script/incremental_build.sh drive-examples --linux
121-
122-
# Legacy Dockerfile configuration for web integration tests.
123-
# https://github.com/flutter/web_installers doesn't yet support the current
124-
# stable version of Chrome, so newly-generated Docker images don't work.
125-
# TODO: Merge this task into the "Web tasks" section of the "Light-workload
126-
# tasks" block above once web_installers has been updated to support Chrome 89
127-
# (which is what the current image generated from .ci/Dockerfile has).
128-
task:
129-
<< : *FLUTTER_UPGRADE_TEMPLATE
130-
container:
131-
dockerfile: .ci/Dockerfile-LegacyChrome
132-
matrix:
133-
- name: integration_web_smoke_test
134-
env:
135-
matrix:
136-
CHANNEL: "master"
137-
CHANNEL: "stable"
138-
# Tests integration example test in web.
139-
only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''"
140-
install_script:
141-
- git clone https://github.com/flutter/web_installers.git
142-
- cd web_installers/packages/web_drivers/
143-
- pub get
144-
- dart lib/web_driver_installer.dart chromedriver --install-only
145-
- ./chromedriver/chromedriver --port=4444 &
146113
test_script:
147-
- cd $INTEGRATION_TEST_PATH/example/
148-
- flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome
114+
- xvfb-run ./script/incremental_build.sh drive-examples --linux
149115

150116
# Heavy-workload Linux tasks.
151117
# These use machines with more CPUs and memory, so will reduce parallelization
@@ -191,6 +157,27 @@ task:
191157
- fi
192158
- export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt`
193159
- export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt`
160+
### Web tasks ###
161+
- name: build-web+drive-examples
162+
env:
163+
matrix:
164+
CHANNEL: "master"
165+
CHANNEL: "stable"
166+
install_script:
167+
- git clone https://github.com/flutter/web_installers.git
168+
- cd web_installers/packages/web_drivers/
169+
- pub get
170+
- dart lib/web_driver_installer.dart chromedriver --install-only
171+
- ./chromedriver/chromedriver --port=4444 &
172+
build_script:
173+
- ./script/incremental_build.sh build-examples --web
174+
test_script:
175+
# TODO(stuartmorgan): Eliminate this check once 2.1 reaches stable.
176+
- if [[ "$CHANNEL" == "master" ]]; then
177+
- ./script/incremental_build.sh drive-examples --web
178+
- else
179+
- echo "Requires null-safe integration_test; skipping."
180+
- fi
194181

195182
# macOS tasks.
196183
task:
@@ -223,6 +210,7 @@ task:
223210
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot
224211
build_script:
225212
- ./script/incremental_build.sh build-examples --ipa
213+
test_script:
226214
- ./script/incremental_build.sh xctest --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
227215
# `drive-examples` contains integration tests, which changes the UI of the application.
228216
# This UI change sometimes affects `xctest`.
@@ -246,6 +234,7 @@ task:
246234
build_script:
247235
- flutter config --enable-macos-desktop
248236
- ./script/incremental_build.sh build-examples --macos --no-ipa
237+
test_script:
249238
- ./script/incremental_build.sh drive-examples --macos
250239

251240
task:

script/tool/lib/src/drive_examples_command.dart

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ class DriveExamplesCommand extends PluginCommand {
1414
FileSystem fileSystem, {
1515
ProcessRunner processRunner = const ProcessRunner(),
1616
}) : super(packagesDir, fileSystem, processRunner: processRunner) {
17+
argParser.addFlag(kAndroid,
18+
help: 'Runs the Android implementation of the examples');
19+
argParser.addFlag(kIos,
20+
help: 'Runs the iOS implementation of the examples');
1721
argParser.addFlag(kLinux,
1822
help: 'Runs the Linux implementation of the examples');
1923
argParser.addFlag(kMacos,
2024
help: 'Runs the macOS implementation of the examples');
25+
argParser.addFlag(kWeb,
26+
help: 'Runs the web implementation of the examples');
2127
argParser.addFlag(kWindows,
2228
help: 'Runs the Windows implementation of the examples');
23-
argParser.addFlag(kIos,
24-
help: 'Runs the iOS implementation of the examples');
25-
argParser.addFlag(kAndroid,
26-
help: 'Runs the Android implementation of the examples');
2729
argParser.addOption(
2830
kEnableExperiment,
2931
defaultsTo: '',
@@ -51,6 +53,7 @@ class DriveExamplesCommand extends PluginCommand {
5153
final List<String> failingTests = <String>[];
5254
final bool isLinux = argResults[kLinux];
5355
final bool isMacos = argResults[kMacos];
56+
final bool isWeb = argResults[kWeb];
5457
final bool isWindows = argResults[kWindows];
5558
await for (Directory plugin in getPlugins()) {
5659
final String flutterCommand =
@@ -139,6 +142,13 @@ Tried searching for the following:
139142
'macos',
140143
]);
141144
}
145+
if (isWeb && isWebPlugin(plugin, fileSystem)) {
146+
driveArgs.addAll(<String>[
147+
'-d',
148+
'web-server',
149+
'--browser-name=chrome',
150+
]);
151+
}
142152
if (isWindows && isWindowsPlugin(plugin, fileSystem)) {
143153
driveArgs.addAll(<String>[
144154
'-d',
@@ -180,26 +190,30 @@ Tried searching for the following:
180190

181191
Future<bool> pluginSupportedOnCurrentPlatform(
182192
FileSystemEntity plugin, FileSystem fileSystem) async {
193+
final bool isAndroid = argResults[kAndroid];
194+
final bool isIOS = argResults[kIos];
183195
final bool isLinux = argResults[kLinux];
184196
final bool isMacos = argResults[kMacos];
197+
final bool isWeb = argResults[kWeb];
185198
final bool isWindows = argResults[kWindows];
186-
final bool isIOS = argResults[kIos];
187-
final bool isAndroid = argResults[kAndroid];
199+
if (isAndroid) {
200+
return (isAndroidPlugin(plugin, fileSystem));
201+
}
202+
if (isIOS) {
203+
return isIosPlugin(plugin, fileSystem);
204+
}
188205
if (isLinux) {
189206
return isLinuxPlugin(plugin, fileSystem);
190207
}
191208
if (isMacos) {
192209
return isMacOsPlugin(plugin, fileSystem);
193210
}
211+
if (isWeb) {
212+
return isWebPlugin(plugin, fileSystem);
213+
}
194214
if (isWindows) {
195215
return isWindowsPlugin(plugin, fileSystem);
196216
}
197-
if (isIOS) {
198-
return isIosPlugin(plugin, fileSystem);
199-
}
200-
if (isAndroid) {
201-
return (isAndroidPlugin(plugin, fileSystem));
202-
}
203217
// When we are here, no flags are specified. Only return true if the plugin
204218
// supports Android for legacy command support. TODO(cyanglaz): Make Android
205219
// flag also required like other platforms (breaking change).

script/tool/test/drive_examples_command_test.dart

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ void main() {
357357
]));
358358
});
359359

360-
test('driving when plugin does not suppport windows is a no-op', () async {
360+
test('driving when plugin does not suppport web is a no-op', () async {
361361
createFakePlugin('plugin',
362362
withExtraFiles: <List<String>>[
363363
<String>['example', 'test_driver', 'plugin_test.dart'],
364364
<String>['example', 'test_driver', 'plugin.dart'],
365365
],
366-
isMacOsPlugin: false);
366+
isWebPlugin: false);
367367

368368
final Directory pluginExampleDirectory =
369369
mockPackagesDir.childDirectory('plugin').childDirectory('example');
@@ -372,7 +372,7 @@ void main() {
372372

373373
final List<String> output = await runCapturingPrint(runner, <String>[
374374
'drive-examples',
375-
'--windows',
375+
'--web',
376376
]);
377377

378378
expect(
@@ -384,11 +384,91 @@ void main() {
384384
);
385385

386386
print(processRunner.recordedCalls);
387-
// Output should be empty since running drive-examples --windows on a non-windows
387+
// Output should be empty since running drive-examples --web on a non-web
388388
// plugin is a no-op.
389389
expect(processRunner.recordedCalls, <ProcessCall>[]);
390390
});
391391

392+
test('driving a web plugin', () async {
393+
createFakePlugin('plugin',
394+
withExtraFiles: <List<String>>[
395+
<String>['example', 'test_driver', 'plugin_test.dart'],
396+
<String>['example', 'test_driver', 'plugin.dart'],
397+
],
398+
isWebPlugin: true);
399+
400+
final Directory pluginExampleDirectory =
401+
mockPackagesDir.childDirectory('plugin').childDirectory('example');
402+
403+
createFakePubspec(pluginExampleDirectory, isFlutter: true);
404+
405+
final List<String> output = await runCapturingPrint(runner, <String>[
406+
'drive-examples',
407+
'--web',
408+
]);
409+
410+
expect(
411+
output,
412+
orderedEquals(<String>[
413+
'\n\n',
414+
'All driver tests successful!',
415+
]),
416+
);
417+
418+
String deviceTestPath = p.join('test_driver', 'plugin.dart');
419+
String driverTestPath = p.join('test_driver', 'plugin_test.dart');
420+
print(processRunner.recordedCalls);
421+
expect(
422+
processRunner.recordedCalls,
423+
orderedEquals(<ProcessCall>[
424+
ProcessCall(
425+
flutterCommand,
426+
<String>[
427+
'drive',
428+
'-d',
429+
'web-server',
430+
'--browser-name=chrome',
431+
'--driver',
432+
driverTestPath,
433+
'--target',
434+
deviceTestPath
435+
],
436+
pluginExampleDirectory.path),
437+
]));
438+
});
439+
440+
test('driving when plugin does not suppport Windows is a no-op', () async {
441+
createFakePlugin('plugin',
442+
withExtraFiles: <List<String>>[
443+
<String>['example', 'test_driver', 'plugin_test.dart'],
444+
<String>['example', 'test_driver', 'plugin.dart'],
445+
],
446+
isWindowsPlugin: false);
447+
448+
final Directory pluginExampleDirectory =
449+
mockPackagesDir.childDirectory('plugin').childDirectory('example');
450+
451+
createFakePubspec(pluginExampleDirectory, isFlutter: true);
452+
453+
final List<String> output = await runCapturingPrint(runner, <String>[
454+
'drive-examples',
455+
'--windows',
456+
]);
457+
458+
expect(
459+
output,
460+
orderedEquals(<String>[
461+
'\n\n',
462+
'All driver tests successful!',
463+
]),
464+
);
465+
466+
print(processRunner.recordedCalls);
467+
// Output should be empty since running drive-examples --windows on a
468+
// non-Windows plugin is a no-op.
469+
expect(processRunner.recordedCalls, <ProcessCall>[]);
470+
});
471+
392472
test('driving on a Windows plugin', () async {
393473
createFakePlugin('plugin',
394474
withExtraFiles: <List<String>>[

0 commit comments

Comments
 (0)