Skip to content

Commit

Permalink
Try #2491:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Aug 30, 2021
2 parents d2caa60 + 768eb5c commit 86ee1e3
Show file tree
Hide file tree
Showing 44 changed files with 31,181 additions and 1,105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Documentation

on:
push:
branches:
- 'master'

name: Documentation

jobs:
documentation:
name: Documentation
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/js.yaml → .github/workflows/test-js.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
name: Runtime tests - JS

env:
RUST_BACKTRACE: 1

on:
push:
branches:
Expand All @@ -8,24 +13,29 @@ on:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'

name: wasmer-js tests

env:
RUST_BACKTRACE: 1

jobs:
wasmer-js:
name: wasmer-js
test:
name: Test on NodeJS

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Test wasmer-js
- name: Compile Wasmer to WebAssembly and test with a JavaScript host
run: make test-js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core tests
name: Runtime tests

env:
RUST_BACKTRACE: 1
Expand Down
102 changes: 98 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"lib/engine-dylib",
"lib/engine-staticlib",
"lib/object",
"lib/vfs",
"lib/vm",
"lib/wasi",
"lib/wasi-types",
Expand All @@ -55,6 +56,7 @@ members = [
"tests/integration/ios",
"fuzz",
]
resolver = "2"

[build-dependencies]
test-generator = { path = "tests/lib/test-generator" }
Expand All @@ -72,6 +74,10 @@ wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
compiler-test-derive = { path = "tests/lib/compiler-test-derive" }
tempfile = "3.1"
loupe = "0.1"
# For logging tests using the `RUST_LOG=debug` when testing
test-env-log = { version = "0.2", default-features = false, features = ["trace"] }
tracing = { version = "0.1", default-features = false, features = ["log"] }
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "fmt"] }

[features]
# Don't add the compiler features in default, please add them on the Makefile
Expand All @@ -80,7 +86,6 @@ default = [
"wat",
"wast",
"universal",
"dylib",
"staticlib",
"cache",
"wasi",
Expand Down Expand Up @@ -285,4 +290,4 @@ required-features = ["cranelift"]
[[example]]
name = "features"
path = "examples/features.rs"
required-features = ["cranelift"]
required-features = ["cranelift"]
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,12 @@ ifneq (, $(LIBC))
endif
$(info Enabled Compilers: $(bold)$(green)$(subst $(space),$(reset)$(comma)$(space)$(bold)$(green),$(compilers))$(reset).)
$(info Testing the following compilers & engines:)
$(info * API: $(bold)$(green)${compilers_engines}$(reset))
$(info * C-API: $(bold)$(green)${capi_compilers_engines}$(reset))
$(info   * API: $(bold)$(green)${compilers_engines}$(reset),)
$(info   * C-API: $(bold)$(green)${capi_compilers_engines}$(reset).)
$(info Cargo features:)
$(info * Compilers: `$(bold)$(green)${compiler_features}$(reset)`.)
$(info   * Compilers: `$(bold)$(green)${compiler_features}$(reset)`.)
$(info Rust version: $(bold)$(green)$(shell rustc --version)$(reset).)
$(info NodeJS version: $(bold)$(green)$(shell node --version)$(reset).)
$(info )
$(info )
$(info --------------)
Expand Down Expand Up @@ -358,7 +360,7 @@ build-wasmer:
cargo build --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer

build-wasmer-debug:
cargo build --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer
cargo build --manifest-path lib/cli/Cargo.toml $(compiler_features) --features "debug" --bin wasmer

bench:
cargo bench $(compiler_features)
Expand Down Expand Up @@ -505,9 +507,13 @@ test-packages:
cargo test --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std
cargo test --manifest-path lib/cli/Cargo.toml $(compiler_features) --release

test-js:
test-js: test-js-api test-js-wasi

test-js-api:
cd lib/api && wasm-pack test --node -- --no-default-features --features js-default,wat

test-js-wasi:
cd lib/wasi && wasm-pack test --node -- --no-default-features --features test-js

#####
#
Expand Down
5 changes: 4 additions & 1 deletion lib/api/src/js/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ impl Memory {
unimplemented!("The view function is not yet implemented in Wasmer Javascript");
}

/// example view
/// A theoretical alais to `Self::view::<u8>` but it returns a `js::Uint8Array` in this case.
///
/// This code is going to be refactored. Use it as your own risks.
#[doc(hidden)]
pub fn uint8view(&self) -> js_sys::Uint8Array {
js_sys::Uint8Array::new(&self.vm_memory.memory.buffer())
}
Expand Down
17 changes: 17 additions & 0 deletions lib/api/src/js/import_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ impl ImportObject {
}
}

impl Into<js_sys::Object> for ImportObject {
fn into(self) -> js_sys::Object {
let guard = self.map.lock().unwrap();
let map = guard.borrow();

let imports = js_sys::Object::new();
for (module, ns) in map.iter() {
let import_namespace = js_sys::Object::new();
for (name, exp) in ns.get_namespace_exports() {
js_sys::Reflect::set(&import_namespace, &name.into(), exp.as_jsvalue()).unwrap();
}
js_sys::Reflect::set(&imports, &module.into(), &import_namespace.into()).unwrap();
}
imports
}
}

impl NamedResolver for ImportObject {
fn resolve_by_name(&self, module: &str, name: &str) -> Option<Export> {
self.get_export(module, name)
Expand Down
Loading

0 comments on commit 86ee1e3

Please sign in to comment.