build: add server-rs test scripts
This commit is contained in:
40
server-rs/scripts/test.sh
Normal file
40
server-rs/scripts/test.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./server-rs/scripts/test.sh
|
||||
SERVER_RS_TEST_PACKAGE=api-server ./server-rs/scripts/test.sh
|
||||
|
||||
Notes:
|
||||
1. Run cargo test for the server-rs workspace by default
|
||||
2. Use SERVER_RS_TEST_PACKAGE to target one workspace package only
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVER_RS_DIR="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
|
||||
MANIFEST_PATH="${SERVER_RS_DIR}/Cargo.toml"
|
||||
|
||||
if [[ ! -f "${MANIFEST_PATH}" ]]; then
|
||||
echo "[server-rs:test] Missing ${MANIFEST_PATH}, cannot start test script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[server-rs:test] working dir: ${SERVER_RS_DIR}"
|
||||
|
||||
cd "${SERVER_RS_DIR}"
|
||||
|
||||
if [[ -n "${SERVER_RS_TEST_PACKAGE:-}" ]]; then
|
||||
echo "[server-rs:test] target package: ${SERVER_RS_TEST_PACKAGE}"
|
||||
cargo test -p "${SERVER_RS_TEST_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
|
||||
else
|
||||
cargo test --manifest-path "${MANIFEST_PATH}"
|
||||
fi
|
||||
Reference in New Issue
Block a user