Skip to content

[ci] Run web tests in wasm (unit + integration). #8111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a1d0b38
Add a --wasm test shard in master.
ditman Nov 16, 2024
9f4cd1f
Add web_platform_tests_wasm config. Copy that config to non-wasm vers…
ditman Dec 17, 2024
b518877
Remove extra comma
ditman Dec 17, 2024
0f80fcb
url_launcher_web tests now pass with --wasm
ditman Dec 19, 2024
1542405
video_player tests now pass with --wasm
ditman Dec 19, 2024
1685463
pointer_interceptor_web wasm tests now pass.
ditman Dec 19, 2024
b56ac8d
Exclude file_selector, since it does not have integration tests.
ditman Dec 19, 2024
c510654
Attempt to pass multiple exclusion files, similarly to how we exclude…
ditman Dec 20, 2024
bcd7f6f
google_maps_flutter_web tests now pass in wasm
ditman Dec 20, 2024
01a9321
dart format .
ditman Dec 20, 2024
6b01a26
Remove unnecessary import.
ditman Dec 20, 2024
be17b43
Clarify note
ditman Dec 20, 2024
9c10258
Shard wasm tests in 3 shards.
ditman Dec 20, 2024
8bb9e64
Try prebuilding the examples.
ditman Dec 20, 2024
18674b3
Do not prebuild apps. Integration tests on the web work by building a…
ditman Dec 20, 2024
598ed80
Update animations/example gitignore file.
ditman Dec 20, 2024
630bfe6
Merge branch 'main' into run-web-integration-wasm
ditman Dec 24, 2024
dc40e4d
Merge branch 'flutter:main' into run-web-integration-wasm
ditman Jan 2, 2025
67d7897
google_adsense Fix experimental test so it passes in wasm.
ditman Jan 2, 2025
b579c4e
Test if we need to prebuild the examples or not on the web.
ditman Jan 2, 2025
9afe55e
Restore JS test yaml
ditman Jan 2, 2025
54606d0
Stop prebuilding web examples
ditman Jan 2, 2025
00a67f7
Merge branch 'main' into run-web-integration-wasm
ditman Jan 2, 2025
6bd249e
Run web unit tests with Wasm as well.
ditman Jan 3, 2025
13ca07c
Adds support for --wasm to dart_test_command.
ditman Jan 3, 2025
c04f01b
[image_picker] Migrate internal PickedFile to Wasm.
ditman Jan 3, 2025
6324f8d
[vector_graphics_codec] Tests now pass in wasm.
ditman Jan 3, 2025
d9a8aa3
[rfw] Make RFW tests pass in wasm.
ditman Jan 4, 2025
70d4de8
Try unit_tests_wasm exceptions file.
ditman Jan 4, 2025
5ade435
Revert non-wasm unit test ci target
ditman Jan 6, 2025
6660cfb
Remove unneeded comment from gitignore
ditman Jan 7, 2025
fcaff2a
Merge branch 'main' into run-web-integration-wasm
ditman Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,38 @@ targets:
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 2"
}

# Wasm unit tests in master
- name: Linux_web web_dart_unit_test_wasm_shard_1 master
bringup: true
recipe: packages/packages
timeout: 60
properties:
add_recipes_cq: "true"
target_file: web_dart_unit_tests_wasm.yaml
channel: master
version_file: flutter_master.version
package_sharding: "--shardIndex 0 --shardCount 2"
env_variables: >-
{
"CHANNEL": "master",
"PACKAGE_SHARDING": "--shardIndex 0 --shardCount 2"
}

- name: Linux_web web_dart_unit_test_wasm_shard_2 master
bringup: true
recipe: packages/packages
timeout: 60
properties:
target_file: web_dart_unit_tests_wasm.yaml
channel: master
version_file: flutter_master.version
package_sharding: "--shardIndex 1 --shardCount 2"
env_variables: >-
{
"CHANNEL": "master",
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 2"
}

- name: Linux analyze master
recipe: packages/packages
timeout: 30
Expand Down Expand Up @@ -846,6 +878,7 @@ targets:
"CHANNEL": "stable"
}

# JS integration tests in master
- name: Linux_web web_platform_tests_shard_1 master
recipe: packages/packages
timeout: 60
Expand Down Expand Up @@ -888,6 +921,53 @@ targets:
"PACKAGE_SHARDING": "--shardIndex 2 --shardCount 3"
}

# Wasm integration tests in master
- name: Linux_web web_platform_tests_wasm_shard_1 master
bringup: true
recipe: packages/packages
timeout: 60
properties:
target_file: web_platform_tests_wasm.yaml
version_file: flutter_master.version
channel: master
package_sharding: "--shardIndex 0 --shardCount 3"
env_variables: >-
{
"CHANNEL": "master",
"PACKAGE_SHARDING": "--shardIndex 0 --shardCount 3"
}

- name: Linux_web web_platform_tests_wasm_shard_2 master
bringup: true
recipe: packages/packages
timeout: 60
properties:
target_file: web_platform_tests_wasm.yaml
version_file: flutter_master.version
channel: master
package_sharding: "--shardIndex 1 --shardCount 3"
env_variables: >-
{
"CHANNEL": "master",
"PACKAGE_SHARDING": "--shardIndex 1 --shardCount 3"
}

- name: Linux_web web_platform_tests_wasm_shard_3 master
bringup: true
recipe: packages/packages
timeout: 60
properties:
target_file: web_platform_tests_wasm.yaml
version_file: flutter_master.version
channel: master
package_sharding: "--shardIndex 2 --shardCount 3"
env_variables: >-
{
"CHANNEL": "master",
"PACKAGE_SHARDING": "--shardIndex 2 --shardCount 3"
}

# JS integration tests in stable
- name: Linux_web web_platform_tests_shard_1 stable
recipe: packages/packages
timeout: 60
Expand Down
6 changes: 5 additions & 1 deletion .ci/targets/web_dart_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ tasks:
infra_step: true # Note infra steps failing prevents "always" from running.
- name: Dart unit tests - web
script: .ci/scripts/tool_runner.sh
args: ["dart-test", "--exclude=script/configs/dart_unit_tests_exceptions.yaml", "--platform=chrome"]
args: [
"dart-test",
"--platform=chrome",
"--exclude=script/configs/dart_unit_tests_exceptions.yaml"
]
13 changes: 13 additions & 0 deletions .ci/targets/web_dart_unit_tests_wasm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tasks:
- name: prepare tool
script: .ci/scripts/prepare_tool.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: Dart unit tests - web (wasm)
script: .ci/scripts/tool_runner.sh
args: [
"dart-test",
"--platform=chrome",
"--wasm",
"--exclude=script/configs/dart_unit_tests_exceptions.yaml",
"--exclude=script/configs/dart_unit_tests_wasm_exceptions.yaml"
]
10 changes: 6 additions & 4 deletions .ci/targets/web_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ tasks:
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps", "--web", "--supporting-target-platforms-only"]
infra_step: true
- name: build examples
script: .ci/scripts/tool_runner.sh
args: ["build-examples", "--web"]
- name: drive examples
script: .ci/scripts/tool_runner.sh
args: ["drive-examples", "--web", "--run-chromedriver", "--exclude=script/configs/exclude_integration_web.yaml"]
args: [
"drive-examples",
"--web",
"--run-chromedriver",
"--exclude=script/configs/exclude_integration_web.yaml",
]
18 changes: 18 additions & 0 deletions .ci/targets/web_platform_tests_wasm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tasks:
- name: prepare tool
script: .ci/scripts/prepare_tool.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: download Dart deps
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps", "--web", "--supporting-target-platforms-only"]
infra_step: true
- name: drive examples
script: .ci/scripts/tool_runner.sh
args: [
"drive-examples",
"--web",
"--wasm",
"--run-chromedriver",
"--exclude=script/configs/exclude_integration_web.yaml",
"--exclude=script/configs/exclude_integration_web_wasm.yaml"
]
3 changes: 0 additions & 3 deletions packages/animations/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

Expand Down
3 changes: 0 additions & 3 deletions packages/animations/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ Future<void> pumpAdWidget(Widget adUnit, WidgetTester tester) async {

// This extra pump is needed for the platform view to actually render in the DOM.
await tester.pump();

// One more for skwasm.
await tester.pump();
// This extra pump is needed to simulate the async behavior of the adsense JS mock.
await tester.pumpAndSettle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ void main() {
visualization.HeatmapLayerOptions()
..data = <gmaps.LatLng>[gmaps.LatLng(0, 0)].toJS;

expect(heatmap.data, hasLength(0));
expect(heatmap.data.array.toDart, hasLength(0));

controller.update(options);

expect(heatmap.data, hasLength(1));
expect(heatmap.data.array.toDart, hasLength(1));
});

group('remove', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void main() {
controller.addHeatmaps(heatmaps);

expect(
controller.heatmaps[const HeatmapId('1')]?.heatmap?.data,
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
hasLength(0),
);

Expand All @@ -450,7 +450,7 @@ void main() {

expect(controller.heatmaps.length, 1);
expect(
controller.heatmaps[const HeatmapId('1')]?.heatmap?.data,
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
hasLength(1),
);
});
Expand Down Expand Up @@ -510,7 +510,9 @@ void main() {
controller.heatmaps.values.first.heatmap!;

expect(
heatmap.get('gradient'),
(heatmap.get('gradient')! as JSArray<JSString>)
.toDart
.map((JSString? value) => value!.toDart),
<String>['rgba(250, 186, 218, 0.00)', 'rgba(250, 186, 218, 1.00)'],
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 2.10.1

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

## 2.10.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(dit): Remove this, https://github.com/flutter/flutter/issues/144286

export 'lost_data.dart';
export 'unsupported.dart'
if (dart.library.html) 'html.dart'
if (dart.library.js_interop) 'html.dart'
if (dart.library.io) 'io.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/image_picker/
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.10.0
version: 2.10.1

environment:
sdk: ^3.4.0
Expand All @@ -20,6 +20,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
web: ^1.1.0

topics:
- image-picker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
library;

import 'dart:convert';
import 'dart:html' as html;
import 'dart:js_interop';
import 'dart:typed_data';

import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
import 'package:web/web.dart' as web;

const String expectedStringContents = 'Hello, world!';
final List<int> bytes = utf8.encode(expectedStringContents);
final html.File textFile = html.File(<List<int>>[bytes], 'hello.txt');
final String textFileUrl = html.Url.createObjectUrl(textFile);
final Uint8List bytes = utf8.encode(expectedStringContents);
final web.File textFile =
web.File(<JSUint8Array>[bytes.toJS].toJS, 'hello.txt');
final String textFileUrl = web.URL.createObjectURL(textFile);

void main() {
group('Create with an objectUrl', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Future<void> _fullyRenderApp(WidgetTester tester) async {
await tester.pumpWidget(const app.MyApp());
// Pump 2 frames so the framework injects the platform view into the DOM.
await tester.pump();
await tester.pump();
// Give the browser some time to perform DOM operations (for Wasm code)
await tester.pump(const Duration(milliseconds: 500));
Comment on lines +73 to +74
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talk to @eyebrowsoffire about this new delay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this, the skwasm renderer is now async, so it makes sense that there's some timing differences compared to the JS one. Needing this additional delay is probably caused by the tester not being aware of this asynchronicity, and declaring a frame "pumped" before it's really been fully rendered.

}

// Calls [_getHtmlElementAt] passing it the center of the widget identified by
Expand Down
14 changes: 10 additions & 4 deletions packages/rfw/test/material_widgets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import 'tolerant_comparator.dart'
if (dart.library.js_interop) 'tolerant_comparator_web.dart';
import 'utils.dart';

/// A const to tell apart Wasm from JS web.
///
/// This is used below to do comparisons of numbers, where in JS a whole double
/// is serialized as "2", in Wasm (and non-web platforms) it's "2.0".
const bool kIsJS = kIsWeb && !kIsWasm;

void main() {
const LibraryName coreName = LibraryName(<String>['core']);
const LibraryName materialName = LibraryName(<String>['material']);
Expand Down Expand Up @@ -229,7 +235,7 @@ void main() {
await tester.pumpAndSettle();
expect(eventLog, contains('menu_item {args: second}'));
expect(eventLog,
contains(kIsWeb ? 'dropdown {value: 2}' : 'dropdown {value: 2.0}'));
contains(kIsJS ? 'dropdown {value: 2}' : 'dropdown {value: 2.0}'));

await tester.tapAt(const Offset(20.0, 20.0));
await tester.pump();
Expand Down Expand Up @@ -682,15 +688,15 @@ void main() {
await _slideToValue(tester, sliderFinder, 20.0);
await tester.pumpAndSettle();
expect(eventLog,
contains(kIsWeb ? 'slider {value: 20}' : 'slider {value: 20.0}'));
contains(kIsJS ? 'slider {value: 20}' : 'slider {value: 20.0}'));
expect(
eventLog,
contains(
kIsWeb ? 'slider.start {value: 0}' : 'slider.start {value: 0.0}'));
kIsJS ? 'slider.start {value: 0}' : 'slider.start {value: 0.0}'));
expect(
eventLog,
contains(
kIsWeb ? 'slider.end {value: 20}' : 'slider.end {value: 20.0}'));
kIsJS ? 'slider.end {value: 20}' : 'slider.end {value: 20.0}'));
});
}

Expand Down
Loading
Loading