From 1b44bd9c3d4c885fb5ce4338422f72b740a9dde4 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 16:59:01 +0100 Subject: [PATCH 1/6] test(store) Restore store test case with multiple engines and compilers. --- tests/test_store.py | 93 +++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/tests/test_store.py b/tests/test_store.py index 0dfbfd5f..03a2fe7e 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -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 @@ -13,39 +13,58 @@ 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) +def test_store_with_various_engines_and_compilers(): + is_aarch64 = target.Triple.host().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) From 9cfa8904272871a8c07418bf6b81dd41b25511d5 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 17:00:48 +0100 Subject: [PATCH 2/6] test(target) Restore cross-compilation test, new LLVM built fixes it. --- tests/test_target.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_target.py b/tests/test_target.py index e8fd94bf..388b1933 100644 --- a/tests/test_target.py +++ b/tests/test_target.py @@ -43,7 +43,6 @@ 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.') def test_cross_compilation_roundtrip(): triple = target.Triple('x86_64-linux-musl') cpu_features = target.CpuFeatures() From 58a56759655edd60d5e8fbec44ee6873fcbd16db Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 17:14:08 +0100 Subject: [PATCH 3/6] chore(ci) Install LLVM even on Windows to get `clang`. --- .github/workflows/release.yml | 1 - .github/workflows/test.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eeeec5fd..71453aab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69a64bb9..681ee949 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 From 6f94f3256bf85ed96841e799cde81b4f5beb5b8f Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 17:14:41 +0100 Subject: [PATCH 4/6] doc(memory) Fix a link. --- packages/api/src/memory/buffer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/memory/buffer.rs b/packages/api/src/memory/buffer.rs index 30517e65..91d3e84e 100644 --- a/packages/api/src/memory/buffer.rs +++ b/packages/api/src/memory/buffer.rs @@ -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 /// From 27e395a4cd4572ac81ba9caf9f50eaf87c1cc933 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 17:15:08 +0100 Subject: [PATCH 5/6] test(store) Exclude the native engine when OS is Windows. --- tests/test_store.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_store.py b/tests/test_store.py index 03a2fe7e..63401eb3 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -14,8 +14,10 @@ def test_store_defaults(): assert store.compiler_name == 'cranelift' def test_store_with_various_engines_and_compilers(): - is_aarch64 = target.Triple.host().architecture == 'aarch64' - exclude_native = is_aarch64 + host_triple = target.Triple.host() + is_aarch64 = host_triple.architecture == 'aarch64' + is_windows = host_triple.operating_system == 'windows' + exclude_native = is_aarch64 or is_windows compilers = [None] engines = [ From 456f2ea0f289022876e57ff70e5c79009991ea9b Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Jan 2021 17:25:59 +0100 Subject: [PATCH 6/6] chore(ci) Debug. --- tests/test_store.py | 4 ++-- tests/test_target.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_store.py b/tests/test_store.py index 63401eb3..4124e2b6 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -13,11 +13,11 @@ def test_store_defaults(): assert store.engine_name == 'jit' assert store.compiler_name == 'cranelift' +@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' - is_windows = host_triple.operating_system == 'windows' - exclude_native = is_aarch64 or is_windows + exclude_native = is_aarch64 compilers = [None] engines = [ diff --git a/tests/test_target.py b/tests/test_target.py index 388b1933..855d79d6 100644 --- a/tests/test_target.py +++ b/tests/test_target.py @@ -43,6 +43,7 @@ def test_target_with_default_cpu_features(): triple = target.Triple.host() target_ = target.Target(triple) +@pytest.mark.skipif(platform.system() == 'Windows', reason = '`clang` is not found on the CI for the moment') def test_cross_compilation_roundtrip(): triple = target.Triple('x86_64-linux-musl') cpu_features = target.CpuFeatures()