From f4298f94292b99e7f384f8048e695b8263d495f2 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Tue, 23 Jul 2024 18:55:18 +0100 Subject: [PATCH 1/4] tests: Fix `/status' endpoint to cater for lists We can now get list objects from the /status endpoint in the case of having different versions of the same language module. That led to this error > return d1 - d2 E TypeError: unsupported operand type(s) for -: 'list' and 'list' We already cover a similar case for when we have simple strings so add this to that. Signed-off-by: Andrew Clayton --- test/unit/status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/status.py b/test/unit/status.py index d8bb4e41e..679008d01 100644 --- a/test/unit/status.py +++ b/test/unit/status.py @@ -31,7 +31,7 @@ def find_diffs(d1, d2): if k in d2 } - if isinstance(d1, str): + if isinstance(d1, str) or isinstance(d1, list): return d1 == d2 return d1 - d2 From 264f4af44c1d054b6d676877c53ae163a7da7055 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Tue, 27 Aug 2024 06:47:53 +0100 Subject: [PATCH 2/4] test/wasm-wc: Target wasm32-wasip1 Changes are afoot... wasm32-wasi has been renamed wasm32-wasip1, there is also a wasm32-wasip2 (seems not yet fully realised) and wasm32-wasi is being kept clear for an eventual WASI 1.0 release. cargo-component targets wasm32-wasip1 by default and adapts the module to the preview2 version of WASI supported by the component model. This means that the component is now found under target/wasm32-wasip1/... Link: Link: Signed-off-by: Andrew Clayton --- test/unit/applications/lang/wasm_component.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/applications/lang/wasm_component.py b/test/unit/applications/lang/wasm_component.py index 6f7b55187..1d58afd6a 100644 --- a/test/unit/applications/lang/wasm_component.py +++ b/test/unit/applications/lang/wasm_component.py @@ -41,7 +41,7 @@ def prepare_env(script): def load(self, script, **kwargs): self.prepare_env(script) - component_path = f'{option.temp_dir}/wasm_component/{script}/target/wasm32-wasi/release/test_wasi_component.wasm' + component_path = f'{option.temp_dir}/wasm_component/{script}/target/wasm32-wasip1/release/test_wasi_component.wasm' self._load_conf( { From 19cd88ef907a3a9248d58a987070f18749ff874b Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 26 Aug 2024 15:53:13 +0100 Subject: [PATCH 3/4] test/wasm-wc: Rename test_wasm_component.py Rename this to 'test_wasm-wasi-component.py' to match the language module name and the name as used in the CI. Signed-off-by: Andrew Clayton --- test/{test_wasm_component.py => test_wasm-wasi-component.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test_wasm_component.py => test_wasm-wasi-component.py} (100%) diff --git a/test/test_wasm_component.py b/test/test_wasm-wasi-component.py similarity index 100% rename from test/test_wasm_component.py rename to test/test_wasm-wasi-component.py From 337cba43a5b74922bb38992ed09d3ddfe673e5e7 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 26 Aug 2024 15:35:48 +0100 Subject: [PATCH 4/4] ci: Enable the wasm-wasi-component tests We now have tests for this module via commit cad6aed52 ("Tests: initial "wasm-wasi-component" test"). We need to install cargo-component for this test target. Also the only way I found I could get this test to run was by running as non-root. The issue I was seeing was that despite cargo being installed into /home/runner/.cargo/bin *and* that being in the path, it kept claiming it couldn't find cargo. E.g. $ sudo -E echo $PATH Showed /home/runner/.cargo/bin in there. $ sudo -E /home/runner/.cargo/bin/cargo -V Worked. $ sudo -E cargo -V cargo command not found. (Also other oddities, despite claiming to be using bash, it couldn't find shell builtins like 'hash' and 'export', perhaps some Ubuntu weirdness...) However, no problem, there is *no* need for it run as root anyway so result! Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 541b72015..47dd0af3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -318,6 +318,7 @@ jobs: - name: Setup rust run: | curl https://sh.rustup.rs | sh -s -- -y + cargo install cargo-component if: steps.metadata.outputs.module == 'wasm-wasi-component' - name: Configure wasm-wasi-component @@ -347,18 +348,22 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3' - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if: steps.metadata.outputs.module != 'wasm' - name: Install pytest run: | - sudo -H pip install pytest - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if [ "${{ matrix.build }}" == "wasm-wasi-component" ]; then + pip install pytest + else + sudo -H pip install pytest + fi + if: steps.metadata.outputs.module != 'wasm' - name: Run ${{ steps.metadata.outputs.module }} tests run: | - sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} - # Skip pytest if wasm build, as there are no tests yet - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if [ "${{ matrix.build }}" == "wasm-wasi-component" ]; then + pytest --print-log ${{ steps.metadata.outputs.testpath }} + else + sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} + fi + if: steps.metadata.outputs.module != 'wasm'