项目文件夹

文件
wehub-resource-sync 9e8f1bbeed
Dashboard / frontend (push) Failing after 0s
Dashboard / api (push) Failing after 0s
Lint PowerShell / powershell-lint (ubuntu-latest) (push) Failing after 1s
Python Lint / Lint Python with Ruff (push) Failing after 1s
ShellCheck / Lint shell scripts (push) Failing after 1s
Matrix Smoke / linux-smoke (push) Failing after 1s
Matrix Smoke / distro: cachyos (push) Failing after 15s
Matrix Smoke / distro: linux-mint-21.3 (push) Failing after 15s
Matrix Smoke / distro: debian-12 (push) Failing after 5m21s
Matrix Smoke / distro: fedora-41 (push) Failing after 4m56s
Matrix Smoke / distro: ubuntu-24.04 (push) Failing after 2m13s
Matrix Smoke / distro: rocky-9 (push) Failing after 10m39s
Matrix Smoke / distro: manjaro (push) Failing after 12m11s
Matrix Smoke / distro: opensuse-tw (push) Failing after 11m53s
Matrix Smoke / distro: archlinux (push) Failing after 20m3s
Matrix Smoke / distro: ubuntu-22.04 (push) Failing after 13m49s
Validate .env Schema / tier-1-env-validation (push) Successful in 52s
Validate .env Schema / tier-2-env-validation (push) Successful in 44s
Validate .env Schema / tier-3-env-validation (push) Successful in 52s
Validate .env Schema / tier-4-env-validation (push) Successful in 51s
Validate Extensions Catalog / Check catalog is up-to-date (push) Failing after 9m47s
Secret Scan / Scan for secrets (push) Failing after 21m4s
Validate Docker Compose / Validate Docker Compose files (push) Has been cancelled
Python Type Check / Type check with mypy (push) Has been cancelled
Validate .env Schema / tier-0-env-validation (push) Has been cancelled
Test Linux / integration-smoke (push) Has been cancelled
Lint PowerShell / powershell-lint (windows-latest) (push) Has been cancelled
Matrix Smoke / macos-smoke (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:33 +08:00

147 行
5.4 KiB
Bash
可执行文件

#!/bin/bash
# ============================================================================
# ODS Temporary File Cleanup Test Suite
# ============================================================================
# Tests that temporary files are properly cleaned up with trap handlers
#
# Usage: ./tests/test-tmpfile-cleanup.sh
# ============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
PASSED=0
FAILED=0
echo ""
echo "╔═══════════════════════════════════════════╗"
echo "║ Temporary File Cleanup Test Suite ║"
echo "╚═══════════════════════════════════════════╝"
echo ""
echo "1. Trap Override Safety Tests"
echo "───────────────────────────────"
# These phase scripts are sourced by install-core.sh, which already installs a
# deliberate SIGINT handler (double-tap Ctrl+C). We must not override that trap
# from a sourced phase.
# Test 1: Phase 05 does NOT set INT/TERM trap for tmpfile cleanup
printf " %-50s " "Phase 05 does not override INT/TERM traps..."
if ! grep -A 3 'mktemp /tmp/install-docker' "$ROOT_DIR/installers/phases/05-docker.sh" | grep -q "trap .*INT"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
# Test 2: Phase 07 does NOT set INT/TERM trap for NodeSource tmpfile
printf " %-50s " "Phase 07 NodeSource does not override INT/TERM..."
if ! grep -A 3 'mktemp /tmp/nodesource-setup' "$ROOT_DIR/installers/phases/07-devtools.sh" | grep -q "trap .*INT"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
# Test 3: Phase 07 does NOT set INT/TERM trap for OpenCode tmpfile
printf " %-50s " "Phase 07 OpenCode does not override INT/TERM..."
if ! grep -A 3 'mktemp /tmp/opencode-install' "$ROOT_DIR/installers/phases/07-devtools.sh" | grep -q "trap .*INT"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
echo ""
echo "2. Explicit Cleanup Tests"
echo "─────────────────────────"
# Test 7: Phase 05 has explicit cleanup after success
printf " %-50s " "Phase 05 has explicit cleanup after success..."
if grep -A 10 'mktemp /tmp/install-docker' "$ROOT_DIR/installers/phases/05-docker.sh" | grep -q "rm -f.*tmpfile"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
# Test 8: Phase 05 has explicit cleanup in error path
printf " %-50s " "Phase 05 has explicit cleanup in error path..."
if grep -B 2 'error "Docker installation failed' "$ROOT_DIR/installers/phases/05-docker.sh" | grep -q "rm -f.*tmpfile"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
# Test 9: Phase 07 NodeSource has explicit cleanup
printf " %-50s " "Phase 07 NodeSource has explicit cleanup..."
if grep -A 10 'mktemp /tmp/nodesource-setup' "$ROOT_DIR/installers/phases/07-devtools.sh" | grep -q "rm -f.*tmpfile"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
# Test 10: Phase 07 OpenCode has explicit cleanup
printf " %-50s " "Phase 07 OpenCode has explicit cleanup..."
if grep -A 10 'mktemp /tmp/opencode-install' "$ROOT_DIR/installers/phases/07-devtools.sh" | grep -q "rm -f.*tmpfile"; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
echo ""
echo "3. Trap Strategy Tests"
echo "──────────────────────"
# Test 11: No trap-based tmpfile cleanup (avoid overriding parent INT handler)
printf " %-50s " "No tmpfile cleanup traps in phases..."
trap_count=$(grep -h "trap.*rm -f.*tmpfile" "$ROOT_DIR/installers/phases/05-docker.sh" "$ROOT_DIR/installers/phases/07-devtools.sh" 2>/dev/null | wc -l | tr -d ' ' || true)
if [[ "${trap_count:-0}" -eq 0 ]]; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC} (found $trap_count trap(s), expected 0)"
FAILED=$((FAILED + 1))
fi
# Test 12: No EXIT traps for tmpfile cleanup
printf " %-50s " "No EXIT traps for tmpfile cleanup..."
if ! grep -h "trap.*rm -f.*tmpfile.*EXIT" "$ROOT_DIR/installers/phases/05-docker.sh" "$ROOT_DIR/installers/phases/07-devtools.sh" 2>/dev/null; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED=$((PASSED + 1))
else
echo -e "${RED}✗ FAIL${NC}"
FAILED=$((FAILED + 1))
fi
echo ""
echo "═══════════════════════════════════════════"
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}✓ All tests passed${NC} ($PASSED/$((PASSED + FAILED)))"
echo ""
exit 0
else
echo -e "${RED}✗ Some tests failed${NC} ($PASSED passed, $FAILED failed)"
echo ""
exit 1
fi