Skip to content

Commit

Permalink
chore(util) always install SDK example test cases
Browse files Browse the repository at this point in the history
Add a new `--install` mode to sdk.sh for copying the compiled .wasm
filters, if any. Now test.sh always installs SDK test filters, if any.

This allows `make cleanup` to properly clean the work/lib/wasm directory
and subsequently run `make test` again.
  • Loading branch information
thibaultcha committed Dec 22, 2023
1 parent 2ef6fb2 commit 2f3d0c3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions util/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if [[ "$1" == "--all" || "$1" == "--more" ]]; then
$DIR_PREFIX \
$DIR_DIST_OUT \
$DIR_DIST_WORK \
$DIR_TESTS_LIB_WASM
remove_luarocks
cargo clean --manifest-path lib/Cargo.toml
cargo clean --manifest-path t/lib/Cargo.toml
Expand Down
6 changes: 6 additions & 0 deletions util/sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Options:
--build Build a Proxy-Wasm SDK and example filters.
--install Copy all compiled Proxy-Wasm SDK example filters
to work/lib/wasm for test suites.
-V, --sdk-ver <ver> Proxy-Wasm SDK version to build (e.g. '0.2.1')
-f, --force, --clean Force a clean build with --build,
Expand Down Expand Up @@ -72,6 +75,9 @@ while [[ "$1" ]]; do
--build)
MODE="build"
;;
--install)
MODE="install"
;;
--clean|--force|-f)
CLEAN="clean"
;;
Expand Down
7 changes: 6 additions & 1 deletion util/sdks/assemblyscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ clean="$3"
if [ "$mode" = "download" ]; then
download_assemblyscript_sdk "$version" "$clean"

else
elif [ "$mode" = "build" ]; then
build_assemblyscript_sdk "$version" "$clean"

elif [ "$mode" = "install" ]; then
install_assemblyscript_sdk_examples

else
fatal "Unknown mode."
fi
7 changes: 6 additions & 1 deletion util/sdks/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ clean="$3"
if [ "$mode" = "download" ]; then
download_go_sdk "$version" "$clean"

else
elif [ "$mode" = "build" ]; then
build_go_sdk "$version" "$clean"

elif [ "$mode" = "install" ]; then
install_go_sdk_examples

else
fatal "Unknown mode."
fi
2 changes: 1 addition & 1 deletion util/setup_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source $NGX_WASM_DIR/util/_lib.sh

###############################################################################

mkdir -p $DIR_CPANM $DIR_BIN $DIR_TESTS_LIB_WASM
mkdir -p $DIR_CPANM $DIR_BIN

# OpenSSL

Expand Down
15 changes: 8 additions & 7 deletions util/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ if [[ "$CI" == 'true' ]]; then
export NGX_BUILD_FORCE=1
fi

mkdir -p $DIR_TESTS_LIB_WASM

args=()

if [ "$TEST_NGINX_CARGO_PROFILE" = release ]; then
Expand All @@ -104,15 +106,14 @@ export RUSTFLAGS="$TEST_NGINX_CARGO_RUSTFLAGS"
eval cargo build \
--manifest-path t/lib/Cargo.toml \
--lib \
"${args[@]}" \
--target wasm32-wasi
--target wasm32-wasi \
"${args[@]}"

if [ "$TEST_NGINX_CARGO_PROFILE" = release ]; then
cp target/wasm32-wasi/release/*.wasm $DIR_TESTS_LIB_WASM
eval cp t/lib/target/wasm32-wasi/$TEST_NGINX_CARGO_PROFILE/*.wasm \
$DIR_TESTS_LIB_WASM

else
cp target/wasm32-wasi/debug/*.wasm $DIR_TESTS_LIB_WASM
fi
$NGX_WASM_DIR/util/sdk.sh -S go --install
$NGX_WASM_DIR/util/sdk.sh -S assemblyscript --install

if [ $(uname -s) = Linux ]; then
export TEST_NGINX_EVENT_TYPE=epoll
Expand Down

0 comments on commit 2f3d0c3

Please sign in to comment.