61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||
FAILED=0
|
||
|
||
report() {
|
||
if [ "$2" -eq 0 ]; then
|
||
echo " ✅ $1"
|
||
else
|
||
echo " ❌ $1"
|
||
FAILED=1
|
||
fi
|
||
}
|
||
|
||
ensure_npm_deps() {
|
||
local dir="$1"
|
||
if [ ! -f "$dir/package.json" ]; then
|
||
return 1
|
||
fi
|
||
if [ ! -d "$dir/node_modules" ]; then
|
||
echo " 📦 node_modules missing — installing..."
|
||
if [ -f "$dir/package-lock.json" ]; then
|
||
(cd "$dir" && npm ci --no-audit --no-fund)
|
||
else
|
||
(cd "$dir" && npm install --no-audit --no-fund)
|
||
fi
|
||
report "npm install in $(basename "$dir")" $?
|
||
fi
|
||
return 0
|
||
}
|
||
|
||
echo "=== verstak-desktop test ==="
|
||
|
||
# ── Go tests ──
|
||
(cd "$ROOT" && go mod download)
|
||
OUTPUT=$(cd "$ROOT" && go test -count=1 -v ./... 2>&1) || true
|
||
echo "$OUTPUT" | grep -E '(FAIL|PASS|---)' || true
|
||
report "go test" $?
|
||
|
||
# ── Frontend tests ──
|
||
echo "[frontend]"
|
||
if ensure_npm_deps "$ROOT/frontend"; then
|
||
if grep -q '"test"' "$ROOT/frontend/package.json" 2>/dev/null; then
|
||
(cd "$ROOT/frontend" && npm test 2>&1 || true)
|
||
report "frontend test" $?
|
||
else
|
||
echo " ℹ️ no test script in frontend/package.json"
|
||
fi
|
||
else
|
||
echo " ℹ️ no frontend/package.json"
|
||
fi
|
||
|
||
echo ""
|
||
if [ "$FAILED" -eq 0 ]; then
|
||
echo "✅ all tests passed"
|
||
else
|
||
echo "❌ some tests failed"
|
||
fi
|
||
exit "$FAILED"
|