smoke-install-test.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Smoke test: install @tobilu/qmd from tarball and verify it runs under node and bun.
  3. # Both runtimes need node on PATH (the bin uses #!/usr/bin/env node shebang).
  4. set -uo pipefail
  5. TARBALL=$(ls /tmp/tobilu-qmd-*.tgz | head -1)
  6. PASS=0
  7. FAIL=0
  8. TMP=$(mktemp)
  9. ok() { printf " %-44s OK\n" "$1"; PASS=$((PASS + 1)); }
  10. fail() { printf " %-44s FAIL\n" "$1"; FAIL=$((FAIL + 1)); cat "$TMP" | sed 's/^/ /'; }
  11. NODE_BIN="$(mise where node@latest)/bin"
  12. BUN_BIN="$(mise where bun@latest)/bin"
  13. BASE_PATH="/root/.local/bin:/usr/local/bin:/usr/bin:/bin"
  14. # ---------------------------------------------------------------------------
  15. # Node: install via npm, runs with node (via shebang)
  16. # ---------------------------------------------------------------------------
  17. echo "=== Node $($NODE_BIN/node --version) ==="
  18. export PATH="$NODE_BIN:$BASE_PATH"
  19. if npm install -g "$TARBALL" >"$TMP" 2>&1; then ok "npm install -g"
  20. else fail "npm install -g"; fi
  21. timeout 10 qmd >"$TMP" 2>&1 || true
  22. if grep -q "Usage:" "$TMP"; then ok "qmd shows help"
  23. else fail "qmd shows help"; fi
  24. if timeout 10 qmd collection list >"$TMP" 2>&1; then ok "qmd collection list"
  25. else fail "qmd collection list"; fi
  26. # ---------------------------------------------------------------------------
  27. # Bun: install via bun, still runs with node (shebang)
  28. # ---------------------------------------------------------------------------
  29. echo ""
  30. echo "=== Bun $($BUN_BIN/bun --version) ==="
  31. export PATH="$BUN_BIN:$HOME/.bun/bin:$NODE_BIN:$BASE_PATH"
  32. if bun install -g "$TARBALL" >"$TMP" 2>&1; then ok "bun install -g"
  33. else fail "bun install -g"; fi
  34. timeout 10 "$HOME/.bun/bin/qmd" >"$TMP" 2>&1 || true
  35. if grep -q "Usage:" "$TMP"; then ok "qmd shows help (bun-installed)"
  36. else fail "qmd shows help (bun-installed)"; fi
  37. if timeout 10 "$HOME/.bun/bin/qmd" collection list >"$TMP" 2>&1; then ok "qmd collection list (bun-installed)"
  38. else fail "qmd collection list (bun-installed)"; fi
  39. rm -f "$TMP"
  40. # ---------------------------------------------------------------------------
  41. # Summary
  42. # ---------------------------------------------------------------------------
  43. echo ""
  44. echo "=== Results: $PASS passed, $FAIL failed ==="
  45. [[ $FAIL -eq 0 ]]