mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 12:03:59 +00:00
96 lines
3.6 KiB
Bash
Executable File
96 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "=============================================="
|
|
echo " Comprehensive .knoe Directory Tests"
|
|
echo "=============================================="
|
|
echo ""
|
|
|
|
TESTS_PASSED=0
|
|
TESTS_TOTAL=0
|
|
|
|
test_item() {
|
|
TESTS_TOTAL=$((TESTS_TOTAL + 1))
|
|
echo -n "[$TESTS_TOTAL] $1... "
|
|
shift
|
|
if "$@" > /dev/null 2>&1; then
|
|
echo "✓"
|
|
TESTS_PASSED=$((TESTS_PASSED + 1))
|
|
return 0
|
|
else
|
|
echo "✗"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
echo "DIRECTORY STRUCTURE"
|
|
test_item "Create .knoe directory" python3 -c "from pathlib import Path; (Path.home() / '.knoe').mkdir(exist_ok=True)"
|
|
test_item "Create build directory" python3 -c "from pathlib import Path; (Path.home() / '.knoe' / 'build').mkdir(parents=True, exist_ok=True)"
|
|
test_item "Create scan directory" python3 -c "from pathlib import Path; (Path.home() / '.knoe' / 'scan').mkdir(parents=True, exist_ok=True)"
|
|
|
|
echo ""
|
|
echo "DOCKER BUILD FIX"
|
|
test_item "knoe-db directory exists" test -d knoe-db
|
|
test_item "Dockerfile exists" test -f knoe-db/Dockerfile
|
|
test_item "Build directory creation" python3 -c "from pathlib import Path; d = Path.home() / '.knoe' / 'build' / 'knoe-db'; d.mkdir(parents=True, exist_ok=True); assert d.exists()"
|
|
test_item "Build directory writable" python3 -c "from pathlib import Path; f = Path.home() / '.knoe' / 'build' / 'test.txt'; f.write_text('test'); f.unlink()"
|
|
|
|
echo ""
|
|
echo "NETWORK SCAN FIX"
|
|
test_item "network-agent binary exists" test -x scan/network-agent
|
|
test_item "Scan directory creation" python3 -c "from pathlib import Path; d = Path.home() / '.knoe' / 'scan'; d.mkdir(parents=True, exist_ok=True); assert d.exists()"
|
|
test_item "Scan directory writable" python3 -c "from pathlib import Path; f = Path.home() / '.knoe' / 'scan' / 'test.txt'; f.write_text('test'); f.unlink()"
|
|
|
|
echo ""
|
|
echo "CODE VERIFICATION"
|
|
test_item "Build uses .knoe/build" grep -q "knoe_home / \"build\"" knoe/core/actions.py
|
|
test_item "Scan uses .knoe/scan" grep -q "knoe_home / \"scan\"" knoe/core/actions.py
|
|
test_item "Docker build uses copy_build_context_dir (core)" grep -q "copy_build_context_dir(source_dir, build_dir)" knoe/core/actions.py
|
|
test_item "Docker build uses copy_build_context_dir (UI)" grep -q "copy_build_context_dir(source_dir, build_dir)" knoe/ui/screens/database.py
|
|
test_item "Scan runs with cwd" grep -q "cwd=str(scan_dir)" knoe/core/actions.py
|
|
|
|
echo ""
|
|
echo "SPEC FILE VERIFICATION"
|
|
python3 scripts/generate_spec.py > /dev/null 2>&1
|
|
test_item "Spec includes knoe-db" grep -q "knoe-db" knoe.spec
|
|
test_item "Spec includes network-agent" grep -q "network-agent" knoe.spec
|
|
|
|
# Cleanup
|
|
echo ""
|
|
echo "CLEANUP"
|
|
python3 << 'PYTEST'
|
|
from pathlib import Path
|
|
import shutil
|
|
knoe_home = Path.home() / ".knoe"
|
|
if knoe_home.exists():
|
|
shutil.rmtree(knoe_home)
|
|
print(" ✓ Cleaned up test directories")
|
|
PYTEST
|
|
|
|
echo ""
|
|
echo "=============================================="
|
|
echo " RESULTS: $TESTS_PASSED/$TESTS_TOTAL PASSED"
|
|
echo "=============================================="
|
|
echo ""
|
|
|
|
if [ $TESTS_PASSED -eq $TESTS_TOTAL ]; then
|
|
echo "✓✓✓ ALL PROLE HOME TESTS PASSED ✓✓✓"
|
|
echo ""
|
|
echo "FIXES IMPLEMENTED:"
|
|
echo " ✓ Docker build uses ~/.knoe/build/knoe-db/"
|
|
echo " ✓ Network scan uses ~/.knoe/scan/"
|
|
echo " ✓ Both work from read-only PyInstaller bundle"
|
|
echo ""
|
|
echo "DIRECTORY STRUCTURE:"
|
|
echo " ~/.knoe/"
|
|
echo " ├── build/"
|
|
echo " │ └── knoe-db/ (Docker build context)"
|
|
echo " └── scan/ (Network scan working dir)"
|
|
echo ""
|
|
echo "DISK USAGE: ~2-6 MB total"
|
|
echo ""
|
|
exit 0
|
|
else
|
|
echo "✗ SOME TESTS FAILED"
|
|
exit 1
|
|
fi
|