"""Regression tests for the pacman hook ordering safety invariant.""" import os import unittest REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) ARCHSETUP = os.path.join(REPO_ROOT, "archsetup") class PacmanHookOrderTests(unittest.TestCase): def test_safety_hooks_precede_mkinitcpio_removal(self): with open(ARCHSETUP, encoding="utf-8") as source: text = source.read() self.assertIn( "cat << 'EOF' > /etc/pacman.d/hooks/05-zfs-snapshot.hook", text) self.assertIn( "cat > /etc/pacman.d/hooks/10-hypr-live-update-guard.hook", text) self.assertLess("05-zfs-snapshot.hook", "60-mkinitcpio-remove.hook") self.assertLess("10-hypr-live-update-guard.hook", "60-mkinitcpio-remove.hook") self.assertIn("rm -f /etc/pacman.d/hooks/zfs-snapshot.hook", text) self.assertIn("rm -f /etc/pacman.d/hooks/hypr-live-update-guard.hook", text) if __name__ == "__main__": unittest.main()