Skip to content

Experimental wasm support #1777

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 23 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c91b8ae
Jake's commit
joshualitt Sep 27, 2022
866ab57
one commit
joshualitt Oct 3, 2022
fd8ff13
add mono_pkg.yaml file and regenerate
jakemac53 Oct 20, 2022
c37fec3
add a warning message to the wasm platform, and give a more informati…
jakemac53 Oct 20, 2022
e90b99d
support wasm boolean selector, add isWasm to Runtime
jakemac53 Oct 20, 2022
bf9ed3d
more cleanup, move injected variables to data attributes and drop unu…
jakemac53 Oct 20, 2022
c8dcef1
dont pollute global scope in run_wasm_chrome.js, invoke anonymous fun…
jakemac53 Oct 20, 2022
c0f7258
update copyright
jakemac53 Oct 20, 2022
e8555a0
update pubspecs/changelogs
jakemac53 Oct 20, 2022
380e879
fix analysis error
jakemac53 Oct 20, 2022
cf931e0
update expected help text
jakemac53 Oct 20, 2022
d023ce7
revert copyright date for compiler_pool.dart
jakemac53 Oct 20, 2022
5b24bea
fix typo
jakemac53 Oct 20, 2022
b956673
remove some irrelevant todos
jakemac53 Oct 20, 2022
38078a3
load the platform dill from the sdk
jakemac53 Oct 20, 2022
87f7757
load the dart_precompiled_runtim from the bin dir of the sdk
jakemac53 Oct 20, 2022
742bcab
try installing google chrome beta with apt-get
jakemac53 Oct 20, 2022
8a5f223
try installing from direct download
jakemac53 Oct 20, 2022
22a2e52
add which command to verify installation
jakemac53 Oct 20, 2022
b49df61
Merge branch 'master' into wasm
jakemac53 Oct 27, 2022
8a60de5
update snapshot path
jakemac53 Oct 27, 2022
46ebfab
use the dartaotruntime
jakemac53 Oct 27, 2022
e296261
do dev versions for now - will land internally and in SDK before rele…
jakemac53 Oct 27, 2022
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
208 changes: 157 additions & 51 deletions .github/workflows/dart.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions integration_tests/wasm/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platforms: [experimental-chrome-wasm]
23 changes: 23 additions & 0 deletions integration_tests/wasm/mono_pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://pub.dev/packages/mono_repo

sdk:
- main

stages:
- analyze_and_format:
- group:
- format
- analyze: --fatal-infos
- unit_test:
- group:
- command:
- pushd /tmp
- wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb
- sudo dpkg -i google-chrome-beta_current_amd64.deb
- popd
- which google-chrome-beta
os:
- linux
- test:
os:
- linux
12 changes: 12 additions & 0 deletions integration_tests/wasm/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: wasm_tests
environment:
sdk: ">=2.18.0 <3.0.0"
dev_dependencies:
test: any
dependency_overrides:
test:
path: ../../pkgs/test
test_api:
path: ../../pkgs/test_api
test_core:
path: ../../pkgs/test_core
11 changes: 11 additions & 0 deletions integration_tests/wasm/test/hello_world_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@TestOn('wasm')
import 'package:test/test.dart';

void main() {
test('1 == 1', () {
expect(1, equals(1));
});
}
7 changes: 7 additions & 0 deletions pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.22.0

* Add the `experimental-chrome-wasm` platform. This is very unstable and will
eventually be deleted, to be replaced by a `--compiler` flag. See
https://github.com/dart-lang/test/issues/1776 for more information on future
plans.

## 1.21.7

* Support `package:matcher` version `0.12.13`.
Expand Down
4 changes: 4 additions & 0 deletions pkgs/test/lib/src/executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:test_core/src/runner/hack_register_platform.dart'; // ignore: im

import 'runner/browser/platform.dart';
import 'runner/node/platform.dart';
import 'runner/wasm/platform.dart';

void main(List<String> args) async {
registerPlatformPlugin([Runtime.nodeJS], () => NodePlatform());
Expand All @@ -18,6 +19,9 @@ void main(List<String> args) async {
Runtime.safari,
Runtime.internetExplorer
], () => BrowserPlatform.start());
registerPlatformPlugin([
Runtime.experimentalChromeWasm,
], () => BrowserWasmPlatform.start());

await executable.main(args);
}
1 change: 1 addition & 0 deletions pkgs/test/lib/src/runner/browser/browser_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class BrowserManager {
ExecutableSettings settings, Configuration configuration) {
switch (browser.root) {
case Runtime.chrome:
case Runtime.experimentalChromeWasm:
return Chrome(url, configuration, settings: settings);
case Runtime.firefox:
return Firefox(url, settings: settings);
Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/lib/src/runner/browser/dom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension WindowExtension on Window {
void postMessage(Object message, String targetOrigin,
[List<MessagePort>? messagePorts]) =>
js_util.callMethod(this, 'postMessage', <Object?>[
message,
js_util.jsify(message),
targetOrigin,
if (messagePorts != null) js_util.jsify(messagePorts)
]);
Expand Down
6 changes: 3 additions & 3 deletions pkgs/test/lib/src/runner/browser/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import 'package:shelf_web_socket/shelf_web_socket.dart';
// ignore: deprecated_member_use
import 'package:test_api/backend.dart'
show Runtime, StackTraceMapper, SuitePlatform;
import 'package:test_core/src/runner/compiler_pool.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/configuration.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/dart2js_compiler_pool.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/load_exception.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/package_version.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/platform.dart'; // ignore: implementation_imports
Expand Down Expand Up @@ -85,8 +85,8 @@ class BrowserPlatform extends PlatformPlugin
/// A [PathHandler] used to serve compiled JS.
final _jsHandler = PathHandler();

/// The [CompilerPool] managing active instances of `dart2js`.
final _compilers = CompilerPool();
/// The [Dart2JsCompilerPool] managing active instances of `dart2js`.
final _compilers = Dart2JsCompilerPool();

/// The temporary directory in which compiled JS is emitted.
final String? _compiledDir;
Expand Down
6 changes: 3 additions & 3 deletions pkgs/test/lib/src/runner/node/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import 'package:stream_channel/stream_channel.dart';
import 'package:test_api/backend.dart'
show Runtime, StackTraceMapper, SuitePlatform;
import 'package:test_core/src/runner/application_exception.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/compiler_pool.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/configuration.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/dart2js_compiler_pool.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/load_exception.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/package_version.dart'; // ignore: implementation_imports
import 'package:test_core/src/runner/platform.dart'; // ignore: implementation_imports
Expand All @@ -41,8 +41,8 @@ class NodePlatform extends PlatformPlugin
/// The test runner configuration.
final Configuration _config;

/// The [CompilerPool] managing active instances of `dart2js`.
final _compilers = CompilerPool(['-Dnode=true', '--server-mode']);
/// The [Dart2JsCompilerPool] managing active instances of `dart2js`.
final _compilers = Dart2JsCompilerPool(['-Dnode=true', '--server-mode']);

/// The temporary directory in which compiled JS is emitted.
final _compiledDir = createTempDir();
Expand Down
21 changes: 21 additions & 0 deletions pkgs/test/lib/src/runner/wasm/default_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:collection';

import 'package:test_api/src/backend/runtime.dart'; // ignore: implementation_imports
import '../executable_settings.dart';

/// Default settings for starting browser executables with the wasm runtime.
final defaultSettings = UnmodifiableMapView({
Runtime.experimentalChromeWasm: ExecutableSettings(
linuxExecutable: 'google-chrome-beta',
macOSExecutable: null,
windowsExecutable: null,
arguments: [
'--js-flags=--experimental-wasm-gc --wasm-gc-js-interop '
'--experimental-wasm-stack-switching '
'--experimental-wasm-type-reflection'
]),
});
Loading