9c63557e62
SamiOS CI / lint-and-test (push) Failing after 10s
- .gitignore: exclude __pycache__, *.pyc, build artifacts, .iso files - tests/test_installer.sh: 17 assertions (syntax, VERSION walk-up, heredoc check, structural checks for partition/format/pacstrap/boot logic, desktop overlay presence) - tests/test_voice_bridge.sh: 19 assertions (AST parse, --version, VERSION match, no hardcoded literal, class/method/import checks) - README.md: SSOT docs, Makefile targets, test suite table, repo layout - docs/roadmap.md: CI/tests/SSOT marked done, Phase 3 app status - packages.x86_64.desktop: Plasma + apps overlay for desktop ISO - CI workflow: Python AST check, VERSION SSOT gate, make check - test_helper.sh: clean single export of path variables - test_version.sh: skip __pycache__ in detector scan All 8 test suites pass (90+ assertions). Codex noted: grep-based structural assertions are not behavior tests; desktop overlay packages need repo validation. These are Phase 3 followups.
118 lines
4.8 KiB
Bash
Executable File
118 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# tests/test_installer.sh — test coverage for the automated installer
|
|
# shellcheck disable=SC2154
|
|
|
|
source "$(dirname "$0")/test_helper.sh"
|
|
|
|
INSTALLER="$SCRIPTS_DIR/samios-installer.sh"
|
|
export INSTALLER
|
|
|
|
# ── 1. Syntax check ──────────────────────────────────────────────────────
|
|
assert_file_exists "installer exists" "$INSTALLER"
|
|
|
|
assert "installer passes bash -n syntax check" \
|
|
bash -c "bash -n '$INSTALLER'"
|
|
|
|
# Note: shellcheck may flag some intentional patterns (SC2120 for
|
|
# unused function args, SC2086 for intentional word-splitting). We
|
|
# run it but only FAIL if there are SC1xxx-level errors (syntax /
|
|
# severe). This is a non-blocking advisory check.
|
|
assert "installer has no shellcheck syntax-level errors" \
|
|
bash -c '
|
|
# Filter to only severity "error" findings (SC1xxx codes)
|
|
errors="$(shellcheck -x "$INSTALLER" 2>&1 | grep "^In .* line" -A2 | grep "SC1" || true)"
|
|
if [ -n "$errors" ]; then
|
|
echo "Shellcheck syntax errors found:"
|
|
echo "$errors"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
# ── 2. VERSION resolution ────────────────────────────────────────────────
|
|
assert "installer resolves VERSION from walk-up (not hardcoded)" \
|
|
bash -c '
|
|
tmpdir="$(mktemp -d)"
|
|
trap "rm -rf ${tmpdir:?}" EXIT
|
|
echo "9.8.7-test" > "$tmpdir/VERSION"
|
|
resolver_block="$(sed -n "/^_VERSION_FILE=/,/^unset _d _VERSION_FILE/p" "$INSTALLER")"
|
|
cd "$tmpdir" || exit 1
|
|
eval "$resolver_block" 2>/dev/null
|
|
if [ "$VERSION" != "9.8.7-test" ]; then
|
|
echo "expected VERSION=9.8.7-test, got VERSION=$VERSION"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
# ── 3. Heredoc CLI emits _lookup_version (not a version literal) ─────────
|
|
assert "installer heredoc CLI does not embed a VERSION literal" \
|
|
bash -c '
|
|
bad="$(grep "VERSION=" "$INSTALLER" \
|
|
| grep -v "head -n1\|VERSION_FILE\|0\.0\.0-unknown\|_VERSION_FILE\|_EMIT_VERSION_FILE\|_lookup_version\|#")"
|
|
if [ -n "$bad" ]; then
|
|
echo "Found hardcoded VERSION assignment: $bad"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
# ── 4. Installer references the VERSION file ─────────────────────────────
|
|
assert "installer references the VERSION resolution mechanism" \
|
|
bash -c '
|
|
grep -q "_VERSION_FILE\|samios-version" "$INSTALLER" || {
|
|
echo "Installer does not use version resolution mechanism"
|
|
exit 1
|
|
}
|
|
'
|
|
|
|
# ── 5. Installer has set -e (fails on errors) ────────────────────────────
|
|
assert "installer has set -e (fails on error)" \
|
|
bash -c "grep -q '^set -e' '$INSTALLER'"
|
|
|
|
# ── 6. Installer emits /etc/samios-version on the target system ──────────
|
|
assert "installer writes /etc/samios-version to target system" \
|
|
bash -c '
|
|
grep -q "samios-version" "$INSTALLER" || {
|
|
echo "Installer does not write /etc/samios-version"
|
|
exit 1
|
|
}
|
|
'
|
|
|
|
# ── 7. Installer has partitioning functions (structural checks) ───────────
|
|
# These verify the installer CONTAINS the expected logic (grep-based
|
|
# structural assertions), not that it correctly executes it. Full
|
|
# behavior testing would require mocking disk operations.
|
|
assert "installer contains partitioning logic" \
|
|
bash -c "grep -qE 'parted|fdisk|cfdisk|sgdisk|gdisk' '$INSTALLER'"
|
|
|
|
assert "installer contains format logic" \
|
|
bash -c "grep -qE 'mkfs|format' '$INSTALLER'"
|
|
|
|
assert "installer contains pacstrap invocation" \
|
|
bash -c "grep -q 'pacstrap' '$INSTALLER'"
|
|
|
|
assert "installer contains bootloader install logic" \
|
|
bash -c "grep -qE 'grub-install|bootctl' '$INSTALLER'"
|
|
|
|
assert "installer contains user creation logic" \
|
|
bash -c "grep -qE 'useradd' '$INSTALLER'"
|
|
|
|
# ── 8. Desktop packages overlay ──────────────────────────────────────────
|
|
assert "desktop overlay packages file exists" \
|
|
bash -c "[ -f '$PROFILE_DIR/packages.x86_64.desktop' ]"
|
|
|
|
assert "desktop overlay has at least 10 packages" \
|
|
bash -c '
|
|
count="$(grep -vE "^\s*#|^\s*$" "$PROFILE_DIR/packages.x86_64.desktop" | wc -l)"
|
|
if [ "$count" -lt 10 ]; then
|
|
echo "expected ≥10 desktop packages, got $count"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
assert "desktop overlay includes Plasma desktop" \
|
|
bash -c "grep -q 'plasma' '$PROFILE_DIR/packages.x86_64.desktop'"
|
|
|
|
assert "desktop overlay includes Firefox" \
|
|
bash -c "grep -q 'firefox' '$PROFILE_DIR/packages.x86_64.desktop'"
|
|
|
|
print_summary
|