#!/bin/bash # Test: pacman.conf validity # Validates INI structure, required sections, and key options. source "$(dirname "$0")/test_helper.sh" suite "pacman.conf tests" PACMANCONF="$PROFILE_DIR/pacman.conf" assert_file_exists "pacman.conf exists" "$PACMANCONF" assert "pacman.conf has valid structure (no unparseable lines)" \ bash -c ' while IFS= read -r line; do # skip blank lines and comments [[ -z "$line" || "$line" == \#* || "$line" == \;* ]] && continue # section header [name] if grep -qE "^\[.+\]$" <<< "$line"; then continue; fi # key = value pair if grep -qE "^[A-Za-z].*=.*$" <<< "$line"; then continue; fi # bare pacman options (e.g. CheckSpace, NoProgressBar, Color) if grep -qE "^[A-Z][A-Za-z]+$" <<< "$line"; then continue; fi echo "unparseable line: $line" exit 1 done < "'"$PACMANCONF"'" ' assert_contains "pacman.conf has [options] section" "$PACMANCONF" "^\[options\]" assert_contains "pacman.conf has [core] section" "$PACMANCONF" "^\[core\]" assert_contains "pacman.conf has [extra] section" "$PACMANCONF" "^\[extra\]" assert_contains "pacman.conf has Architecture setting" "$PACMANCONF" "^Architecture" assert_contains "pacman.conf has SigLevel setting" "$PACMANCONF" "^SigLevel" assert_contains "pacman.conf has HoldPkg setting" "$PACMANCONF" "^HoldPkg" # Validate all section headers are well-formed [name] assert "all section headers are well-formed" \ bash -c ' while IFS= read -r line; do # match [something] — non-empty, no spaces in name if [[ "$line" == \[* ]]; then if ! grep -qE "^\[[a-zA-Z0-9_-]+\]$" <<< "$line"; then echo "malformed section header: $line" exit 1 fi fi done < "'"$PACMANCONF"'" ' print_summary