Skip to content

Commit 11a9fa8

Browse files
authored
[ci] Run web tests in wasm (unit + integration). (flutter#8111)
Adds CI configuration to run web integration tests (in the master channel) compiled to Wasm. It also removes the `build-examples` step from web integration tests, in some isolated testing: | platform tests shard | With build-examples | Without build-examples | |---|-----|-----| | 1 | 30m | 21m | | 2 | 13m | 11m | | 3 | 17m | 10m | ## Issues * Fixes flutter/flutter#151664
1 parent 34d5039 commit 11a9fa8

File tree

26 files changed

+282
-72
lines changed

26 files changed

+282
-72
lines changed

.ci.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,38 @@ targets:
245245
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 2"
246246
}
247247
248+
# Wasm unit tests in master
249+
- name: Linux_web web_dart_unit_test_wasm_shard_1 master
250+
bringup: true
251+
recipe: packages/packages
252+
timeout: 60
253+
properties:
254+
add_recipes_cq: "true"
255+
target_file: web_dart_unit_tests_wasm.yaml
256+
channel: master
257+
version_file: flutter_master.version
258+
package_sharding: "--shardIndex 0 --shardCount 2"
259+
env_variables: >-
260+
{
261+
"CHANNEL": "master",
262+
"PACKAGE_SHARDING": "--shardIndex 0 --shardCount 2"
263+
}
264+
265+
- name: Linux_web web_dart_unit_test_wasm_shard_2 master
266+
bringup: true
267+
recipe: packages/packages
268+
timeout: 60
269+
properties:
270+
target_file: web_dart_unit_tests_wasm.yaml
271+
channel: master
272+
version_file: flutter_master.version
273+
package_sharding: "--shardIndex 1 --shardCount 2"
274+
env_variables: >-
275+
{
276+
"CHANNEL": "master",
277+
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 2"
278+
}
279+
248280
- name: Linux analyze master
249281
recipe: packages/packages
250282
timeout: 30
@@ -846,6 +878,7 @@ targets:
846878
"CHANNEL": "stable"
847879
}
848880
881+
# JS integration tests in master
849882
- name: Linux_web web_platform_tests_shard_1 master
850883
recipe: packages/packages
851884
timeout: 60
@@ -888,6 +921,53 @@ targets:
888921
"PACKAGE_SHARDING": "--shardIndex 2 --shardCount 3"
889922
}
890923
924+
# Wasm integration tests in master
925+
- name: Linux_web web_platform_tests_wasm_shard_1 master
926+
bringup: true
927+
recipe: packages/packages
928+
timeout: 60
929+
properties:
930+
target_file: web_platform_tests_wasm.yaml
931+
version_file: flutter_master.version
932+
channel: master
933+
package_sharding: "--shardIndex 0 --shardCount 3"
934+
env_variables: >-
935+
{
936+
"CHANNEL": "master",
937+
"PACKAGE_SHARDING": "--shardIndex 0 --shardCount 3"
938+
}
939+
940+
- name: Linux_web web_platform_tests_wasm_shard_2 master
941+
bringup: true
942+
recipe: packages/packages
943+
timeout: 60
944+
properties:
945+
target_file: web_platform_tests_wasm.yaml
946+
version_file: flutter_master.version
947+
channel: master
948+
package_sharding: "--shardIndex 1 --shardCount 3"
949+
env_variables: >-
950+
{
951+
"CHANNEL": "master",
952+
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 3"
953+
}
954+
955+
- name: Linux_web web_platform_tests_wasm_shard_3 master
956+
bringup: true
957+
recipe: packages/packages
958+
timeout: 60
959+
properties:
960+
target_file: web_platform_tests_wasm.yaml
961+
version_file: flutter_master.version
962+
channel: master
963+
package_sharding: "--shardIndex 2 --shardCount 3"
964+
env_variables: >-
965+
{
966+
"CHANNEL": "master",
967+
"PACKAGE_SHARDING": "--shardIndex 2 --shardCount 3"
968+
}
969+
970+
# JS integration tests in stable
891971
- name: Linux_web web_platform_tests_shard_1 stable
892972
recipe: packages/packages
893973
timeout: 60

.ci/targets/web_dart_unit_tests.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ tasks:
44
infra_step: true # Note infra steps failing prevents "always" from running.
55
- name: Dart unit tests - web
66
script: .ci/scripts/tool_runner.sh
7-
args: ["dart-test", "--exclude=script/configs/dart_unit_tests_exceptions.yaml", "--platform=chrome"]
7+
args: [
8+
"dart-test",
9+
"--platform=chrome",
10+
"--exclude=script/configs/dart_unit_tests_exceptions.yaml"
11+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tasks:
2+
- name: prepare tool
3+
script: .ci/scripts/prepare_tool.sh
4+
infra_step: true # Note infra steps failing prevents "always" from running.
5+
- name: Dart unit tests - web (wasm)
6+
script: .ci/scripts/tool_runner.sh
7+
args: [
8+
"dart-test",
9+
"--platform=chrome",
10+
"--wasm",
11+
"--exclude=script/configs/dart_unit_tests_exceptions.yaml",
12+
"--exclude=script/configs/dart_unit_tests_wasm_exceptions.yaml"
13+
]

.ci/targets/web_platform_tests.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ tasks:
66
script: .ci/scripts/tool_runner.sh
77
args: ["fetch-deps", "--web", "--supporting-target-platforms-only"]
88
infra_step: true
9-
- name: build examples
10-
script: .ci/scripts/tool_runner.sh
11-
args: ["build-examples", "--web"]
129
- name: drive examples
1310
script: .ci/scripts/tool_runner.sh
14-
args: ["drive-examples", "--web", "--run-chromedriver", "--exclude=script/configs/exclude_integration_web.yaml"]
11+
args: [
12+
"drive-examples",
13+
"--web",
14+
"--run-chromedriver",
15+
"--exclude=script/configs/exclude_integration_web.yaml",
16+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
tasks:
2+
- name: prepare tool
3+
script: .ci/scripts/prepare_tool.sh
4+
infra_step: true # Note infra steps failing prevents "always" from running.
5+
- name: download Dart deps
6+
script: .ci/scripts/tool_runner.sh
7+
args: ["fetch-deps", "--web", "--supporting-target-platforms-only"]
8+
infra_step: true
9+
- name: drive examples
10+
script: .ci/scripts/tool_runner.sh
11+
args: [
12+
"drive-examples",
13+
"--web",
14+
"--wasm",
15+
"--run-chromedriver",
16+
"--exclude=script/configs/exclude_integration_web.yaml",
17+
"--exclude=script/configs/exclude_integration_web_wasm.yaml"
18+
]

packages/animations/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
.pub/
3232
/build/
3333

34-
# Web related
35-
lib/generated_plugin_registrant.dart
36-
3734
# Symbolication related
3835
app.*.symbols
3936

packages/animations/example/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,5 @@
3030
.pub/
3131
/build/
3232

33-
# Web related
34-
lib/generated_plugin_registrant.dart
35-
3633
# Exceptions to above rules.
3734
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

packages/google_adsense/example/integration_test/experimental_ad_unit_widget_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ Future<void> pumpAdWidget(Widget adUnit, WidgetTester tester) async {
205205

206206
// This extra pump is needed for the platform view to actually render in the DOM.
207207
await tester.pump();
208-
208+
// One more for skwasm.
209+
await tester.pump();
209210
// This extra pump is needed to simulate the async behavior of the adsense JS mock.
210211
await tester.pumpAndSettle();
211212
}

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ void main() {
232232
visualization.HeatmapLayerOptions()
233233
..data = <gmaps.LatLng>[gmaps.LatLng(0, 0)].toJS;
234234

235-
expect(heatmap.data, hasLength(0));
235+
expect(heatmap.data.array.toDart, hasLength(0));
236236

237237
controller.update(options);
238238

239-
expect(heatmap.data, hasLength(1));
239+
expect(heatmap.data.array.toDart, hasLength(1));
240240
});
241241

242242
group('remove', () {

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ void main() {
435435
controller.addHeatmaps(heatmaps);
436436

437437
expect(
438-
controller.heatmaps[const HeatmapId('1')]?.heatmap?.data,
438+
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
439439
hasLength(0),
440440
);
441441

@@ -450,7 +450,7 @@ void main() {
450450

451451
expect(controller.heatmaps.length, 1);
452452
expect(
453-
controller.heatmaps[const HeatmapId('1')]?.heatmap?.data,
453+
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
454454
hasLength(1),
455455
);
456456
});
@@ -510,7 +510,9 @@ void main() {
510510
controller.heatmaps.values.first.heatmap!;
511511

512512
expect(
513-
heatmap.get('gradient'),
513+
(heatmap.get('gradient')! as JSArray<JSString>)
514+
.toDart
515+
.map((JSString? value) => value!.toDart),
514516
<String>['rgba(250, 186, 218, 0.00)', 'rgba(250, 186, 218, 1.00)'],
515517
);
516518
});

packages/image_picker/image_picker_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 2.10.1
22

33
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
4+
* Fixes Wasm tests in internal PickedFile implementation.
45

56
## 2.10.0
67

packages/image_picker/image_picker_platform_interface/lib/src/types/picked_file/picked_file.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// TODO(dit): Remove this, https://github.com/flutter/flutter/issues/144286
6+
57
export 'lost_data.dart';
68
export 'unsupported.dart'
7-
if (dart.library.html) 'html.dart'
9+
if (dart.library.js_interop) 'html.dart'
810
if (dart.library.io) 'io.dart';

packages/image_picker/image_picker_platform_interface/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/image_picker/
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.10.0
7+
version: 2.10.1
88

99
environment:
1010
sdk: ^3.4.0
@@ -20,6 +20,7 @@ dependencies:
2020
dev_dependencies:
2121
flutter_test:
2222
sdk: flutter
23+
web: ^1.1.0
2324

2425
topics:
2526
- image-picker

packages/image_picker/image_picker_platform_interface/test/picked_file_html_test.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
library;
77

88
import 'dart:convert';
9-
import 'dart:html' as html;
9+
import 'dart:js_interop';
10+
import 'dart:typed_data';
1011

1112
import 'package:flutter_test/flutter_test.dart';
1213
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
14+
import 'package:web/web.dart' as web;
1315

1416
const String expectedStringContents = 'Hello, world!';
15-
final List<int> bytes = utf8.encode(expectedStringContents);
16-
final html.File textFile = html.File(<List<int>>[bytes], 'hello.txt');
17-
final String textFileUrl = html.Url.createObjectUrl(textFile);
17+
final Uint8List bytes = utf8.encode(expectedStringContents);
18+
final web.File textFile =
19+
web.File(<JSUint8Array>[bytes.toJS].toJS, 'hello.txt');
20+
final String textFileUrl = web.URL.createObjectURL(textFile);
1821

1922
void main() {
2023
group('Create with an objectUrl', () {

packages/pointer_interceptor/pointer_interceptor_web/example/integration_test/widget_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ Future<void> _fullyRenderApp(WidgetTester tester) async {
7070
await tester.pumpWidget(const app.MyApp());
7171
// Pump 2 frames so the framework injects the platform view into the DOM.
7272
await tester.pump();
73-
await tester.pump();
73+
// Give the browser some time to perform DOM operations (for Wasm code)
74+
await tester.pump(const Duration(milliseconds: 500));
7475
}
7576

7677
// Calls [_getHtmlElementAt] passing it the center of the widget identified by

packages/rfw/test/material_widgets_test.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import 'tolerant_comparator.dart'
1313
if (dart.library.js_interop) 'tolerant_comparator_web.dart';
1414
import 'utils.dart';
1515

16+
/// A const to tell apart Wasm from JS web.
17+
///
18+
/// This is used below to do comparisons of numbers, where in JS a whole double
19+
/// is serialized as "2", in Wasm (and non-web platforms) it's "2.0".
20+
const bool kIsJS = kIsWeb && !kIsWasm;
21+
1622
void main() {
1723
const LibraryName coreName = LibraryName(<String>['core']);
1824
const LibraryName materialName = LibraryName(<String>['material']);
@@ -229,7 +235,7 @@ void main() {
229235
await tester.pumpAndSettle();
230236
expect(eventLog, contains('menu_item {args: second}'));
231237
expect(eventLog,
232-
contains(kIsWeb ? 'dropdown {value: 2}' : 'dropdown {value: 2.0}'));
238+
contains(kIsJS ? 'dropdown {value: 2}' : 'dropdown {value: 2.0}'));
233239

234240
await tester.tapAt(const Offset(20.0, 20.0));
235241
await tester.pump();
@@ -682,15 +688,15 @@ void main() {
682688
await _slideToValue(tester, sliderFinder, 20.0);
683689
await tester.pumpAndSettle();
684690
expect(eventLog,
685-
contains(kIsWeb ? 'slider {value: 20}' : 'slider {value: 20.0}'));
691+
contains(kIsJS ? 'slider {value: 20}' : 'slider {value: 20.0}'));
686692
expect(
687693
eventLog,
688694
contains(
689-
kIsWeb ? 'slider.start {value: 0}' : 'slider.start {value: 0.0}'));
695+
kIsJS ? 'slider.start {value: 0}' : 'slider.start {value: 0.0}'));
690696
expect(
691697
eventLog,
692698
contains(
693-
kIsWeb ? 'slider.end {value: 20}' : 'slider.end {value: 20.0}'));
699+
kIsJS ? 'slider.end {value: 20}' : 'slider.end {value: 20.0}'));
694700
});
695701
}
696702

0 commit comments

Comments
 (0)