Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adds support for --wasm to dart_test_command.
  • Loading branch information
ditman committed Jan 3, 2025
commit 13ca07cd80970b4349da9c9000420ab33708e231
15 changes: 11 additions & 4 deletions script/tool/lib/src/dart_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class DartTestCommand extends PackageLoopingCommand {
help: 'Runs tests on the given platform instead of the default platform '
'("vm" in most cases, "chrome" for web plugin implementations).',
);
argParser.addFlag(kWebWasmFlag,
help: 'Compile to WebAssembly rather than JavaScript');
}

static const String _platformFlag = 'platform';
Expand Down Expand Up @@ -108,18 +110,21 @@ class DartTestCommand extends PackageLoopingCommand {
platform = 'chrome';
}

// Whether to run web tests compiled to wasm.
final bool wasm = platform != 'vm' && getBoolArg(kWebWasmFlag);

bool passed;
if (package.requiresFlutter()) {
passed = await _runFlutterTests(package, platform: platform);
passed = await _runFlutterTests(package, platform: platform, wasm: wasm);
} else {
passed = await _runDartTests(package, platform: platform);
passed = await _runDartTests(package, platform: platform, wasm: wasm);
}
return passed ? PackageResult.success() : PackageResult.fail();
}

/// Runs the Dart tests for a Flutter package, returning true on success.
Future<bool> _runFlutterTests(RepositoryPackage package,
{String? platform}) async {
{String? platform, bool wasm = false}) async {
final String experiment = getStringArg(kEnableExperiment);

final int exitCode = await processRunner.runAndStream(
Expand All @@ -131,6 +136,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 (wasm) '--wasm',
],
workingDir: package.directory,
);
Expand All @@ -139,7 +145,7 @@ class DartTestCommand extends PackageLoopingCommand {

/// Runs the Dart tests for a non-Flutter package, returning true on success.
Future<bool> _runDartTests(RepositoryPackage package,
{String? platform}) async {
{String? platform, bool wasm = false}) async {
// Unlike `flutter test`, `dart run test` does not automatically get
// packages
if (!await runPubGet(package, processRunner, super.platform)) {
Expand All @@ -156,6 +162,7 @@ class DartTestCommand extends PackageLoopingCommand {
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
'test',
if (platform != null) '--platform=$platform',
if (wasm) '--compiler=dart2wasm',
],
workingDir: package.directory,
);
Expand Down
54 changes: 54 additions & 0 deletions script/tool/test/dart_test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,33 @@ test_on: vm && browser
);
});

test('runs in Chrome (wasm) when requested for Flutter package', () async {
final RepositoryPackage package = createFakePackage(
'a_package',
packagesDir,
isFlutter: true,
extraFiles: <String>['test/empty_test.dart'],
);

await runCapturingPrint(
runner, <String>['dart-test', '--platform=chrome', '--wasm']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'--color',
'--platform=chrome',
'--wasm',
],
package.path),
]),
);
});

test('runs in Chrome by default for Flutter plugins that implement web',
() async {
final RepositoryPackage plugin = createFakePlugin(
Expand Down Expand Up @@ -517,6 +544,33 @@ test_on: vm && browser
);
});

test('runs in Chrome (wasm) when requested for Dart package', () async {
final RepositoryPackage package = createFakePackage(
'package',
packagesDir,
extraFiles: <String>['test/empty_test.dart'],
);

await runCapturingPrint(
runner, <String>['dart-test', '--platform=chrome', '--wasm']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall('dart', const <String>['pub', 'get'], package.path),
ProcessCall(
'dart',
const <String>[
'run',
'test',
'--platform=chrome',
'--compiler=dart2wasm',
],
package.path),
]),
);
});

test('skips running in browser mode if package opts out', () async {
final RepositoryPackage package = createFakePackage(
'a_package',
Expand Down
Loading