Skip to content

test(store) Restore store test case with multiple engines and compilers #467

New issue

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

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

Already on GitHub? # to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ jobs:
pyenv install --skip-existing "$(cat .python-version)"

- name: Set up LLVM for `wasmer_compiler_llvm`
if: matrix.target.id != 'windows-amd64' # This is disabled in the `just` file, skip it to save data.
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSfL ${{ matrix.target.llvm-archive-url }} -o llvm.tar.gz
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ jobs:
pyenv install --skip-existing "$(cat .python-version)"

- name: Set up LLVM for `wasmer_compiler_llvm`
if: matrix.target.id != 'windows-amd64' # This is disabled in the `just` file, skip it to save data.
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSfL ${{ matrix.target.llvm-archive-url }} -o llvm.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/memory/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{
/// [buffer-protocol]: https://docs.python.org/3/c-api/buffer.html
/// [bytes]: https://docs.python.org/3/library/stdtypes.html#bytes
/// [bytearray]: https://docs.python.org/3/library/stdtypes.html#bytearray
/// [memoryview]: https://docs.python.org/3/library/stdtypes.html?#memoryview
/// [memoryview]: https://docs.python.org/3/library/stdtypes.html#memoryview
///
/// ## Example
///
Expand Down
95 changes: 58 additions & 37 deletions tests/test_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wasmer import engine, Store, Module, Instance
from wasmer import engine, target, Store, Module, Instance
import itertools
import os
import platform
Expand All @@ -13,39 +13,60 @@ def test_store_defaults():
assert store.engine_name == 'jit'
assert store.compiler_name == 'cranelift'

#@pytest.mark.skipif(platform.system() == 'Windows', reason='Wasmer (`master`) has some troubles with JIT on Windows for the moment.')
#def test_store_with_various_engines_and_compilers():
# import wasmer_compiler_llvm
#
# engines = [
# engine.JIT,
# engine.Native
# ]
# compilers = [
# None,
# wasmer_compiler_cranelift.Compiler,
# wasmer_compiler_llvm.Compiler,
# wasmer_compiler_singlepass.Compiler
# ]
# results = [
# ('jit', None),
# ('jit', 'cranelift'),
# ('jit', 'llvm'),
# ('jit', 'singlepass'),
# ('native', None),
# ('native', 'cranelift'),
# ('native', 'llvm'),
# ('native', 'singlepass'),
# ]
#
# for ((engine_, compiler), expected) in itertools.zip_longest(itertools.product(engines, compilers), results):
# store = Store(engine_(compiler))
#
# assert store.engine_name == expected[0]
# assert store.compiler_name == expected[1]
#
# if compiler != None:
# module = Module(store, TEST_BYTES)
# instance = Instance(module)
#
# assert instance.exports.sum(1, 2)
@pytest.mark.skipif(platform.system() == 'Windows', reason = 'temp')
def test_store_with_various_engines_and_compilers():
host_triple = target.Triple.host()
is_aarch64 = host_triple.architecture == 'aarch64'
exclude_native = is_aarch64

compilers = [None]
engines = [
engine.JIT,
engine.Native
]
results = [
(None, 'jit'),
(None, 'native'),
]

try:
import wasmer_compiler_cranelift

compilers.append(wasmer_compiler_cranelift.Compiler)
results.append(('cranelift', 'jit'))
results.append(('cranelift', 'native'))
except ImportError:
pass

try:
import wasmer_compiler_llvm

compilers.append(wasmer_compiler_llvm.Compiler)
results.append(('llvm', 'jit'))
results.append(('llvm', 'native'))
except ImportError:
pass

try:
import wasmer_compiler_singlepass

compilers.append(wasmer_compiler_singlepass.Compiler)
results.append(('singlepass', 'jit'))
results.append(('singlepass', 'native'))
except ImportError:
pass

for ((compiler, engine_), expected) in itertools.zip_longest(itertools.product(compilers, engines), results):
if exclude_native and engine_ == engine.Native:
continue

store = Store(engine_(compiler))

assert store.compiler_name == expected[0]
assert store.engine_name == expected[1]

if compiler != None:
module = Module(store, TEST_BYTES)
instance = Instance(module)

assert instance.exports.sum(1, 2)
2 changes: 1 addition & 1 deletion tests/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_target_with_default_cpu_features():
triple = target.Triple.host()
target_ = target.Target(triple)

@pytest.mark.skip(reason = 'CI does not have `gcc` or `clang` installed for the moment. It will be resolved once LLVM is installed.')
@pytest.mark.skipif(platform.system() == 'Windows', reason = '`clang` is not found on the CI for the moment')
Copy link
Contributor

Choose a reason for hiding this comment

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

clang is available with our custom builds. Can't we use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, exactly what I tried in 58a5675, but we are looking for clang, not clang.exe… We should fix that Wasmer itself, or we can symlink temporarily in our CI. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should fix that Wasmer itself

👍 for this: can you open an issue there please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup sure

def test_cross_compilation_roundtrip():
triple = target.Triple('x86_64-linux-musl')
cpu_features = target.CpuFeatures()
Expand Down