Skip to content

Commit

Permalink
test: Small compatibility tweaks and improvements to wasi-fyi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theduke committed Feb 25, 2024
1 parent b163e35 commit 3afe1e7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
toolchain: ${{ env.MSRV }}
targets: "wasm32-wasi"
- name: Install wasm-pack
run: |
Expand Down
9 changes: 7 additions & 2 deletions tests/wasi-fyi/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash

set -ueo pipefail

for input in *.rs; do
output="$(basename $input .rs).wasm"

echo "Compiling $input"
rustc +nightly --target=wasm32-wasi -o "$output" "$input"
# Some of the tests require unstable Rust features.
# RUSTC_BOOTSTRAP=1 is a trick that allows unstable features to work on stable
# compilers. This is done so the builds don't rely on a rustup installation
# and a separate nightly toolchain.
RUSTC_BOOTSTRAP=1 rustc --target=wasm32-wasi -o "$output" "$input"
done
12 changes: 10 additions & 2 deletions tests/wasi-fyi/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/bash
#!/usr/bin/env bash

set -ueo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# get absolute path of the root dir
ROOT_DIR="$( cd "${DIR}/.." && pwd )"

cd "$DIR"

bash build.sh

status=0

# Define skip list as an array
SKIP_LIST=("ported_readlink.wasm" "fs_create_dir-existing-directory.wasm" "fs_rename-directory.wasm" "fs_rename-file.wasm")

cd $DIR

# List and process .foo files
for file in *.wasm; do
if [[ " ${SKIP_LIST[@]} " =~ " ${file} " ]]; then
Expand All @@ -19,4 +28,3 @@ for file in *.wasm; do
done

exit $status

12 changes: 11 additions & 1 deletion tests/wasi-fyi/wasm-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# get absolute path of the root dir
ROOT_DIR="$( cd "${DIR}/../../" && pwd )"
TEST_RUNNER="${TEST_RUNNER:-$ROOT_DIR/target/release/wasmer}"

if [ ! -e "$TEST_RUNNER" ]; then
echo "Test runner not found at '$TEST_RUNNER' - set TEST_RUNNER env var to the correct path."
exit 1
fi

input=$1

input_dir=$(dirname $input)
Expand Down Expand Up @@ -40,7 +50,7 @@ fi

status=0

"../../target/release/wasmer" --mapdir /hamlet:./test_fs/hamlet --mapdir /fyi:./test_fs/fyi "$input_base.wasm" $dir $env -- $arg \
$TEST_RUNNER --mapdir /hamlet:./test_fs/hamlet --mapdir /fyi:./test_fs/fyi "$input_base.wasm" $dir $env -- $arg \
< "$stdin" \
> "$stdout_actual" \
2> "$stderr_actual" \
Expand Down

0 comments on commit 3afe1e7

Please sign in to comment.