aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/updates/test_updatesctl.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-15 12:14:22 +0200
committerDanilo M. <danix@danix.xyz>2026-10-15 12:14:27 +0200
commitb43eb174cf64d8362a8f59e8b9d74675eed05ca4 (patch)
tree5ad2303c047d275e900ec55e28e3c89cd5ba2d59 /desktop/modules/updates/test_updatesctl.py
parent8e951468ab0a26844d02f179a15d778591a68a21 (diff)
downloadquickshell-b43eb174cf64d8362a8f59e8b9d74675eed05ca4.tar.gz
quickshell-b43eb174cf64d8362a8f59e8b9d74675eed05ca4.zip
feat(updates): version order for updatesctl
nvtable compares versions for equality, which cannot tell an installed 2.1.278 from an SBo recipe of 2.1.267 that is older than it. vercmp orders numeric chunks as numbers and treats a trailing alphabetic chunk as a pre-release, so a kernel suffix or git hash orders as newer than its base and never reads as behind. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/updates/test_updatesctl.py')
-rw-r--r--desktop/modules/updates/test_updatesctl.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/desktop/modules/updates/test_updatesctl.py b/desktop/modules/updates/test_updatesctl.py
new file mode 100644
index 0000000..09c3676
--- /dev/null
+++ b/desktop/modules/updates/test_updatesctl.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python3
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+"""Run: /usr/bin/python3 desktop/modules/updates/test_updatesctl.py
+
+Imports updatesctl for vercmp, then drives it as a CLI against a fixture tree
+under a temp dir (UPDATESCTL_ROOT for system paths, HOME for the user's),
+never the live system. Plain asserts, no framework.
+"""
+
+import importlib.machinery
+import importlib.util
+from pathlib import Path
+
+SCRIPT = Path(__file__).resolve().parent / "updatesctl"
+
+loader = importlib.machinery.SourceFileLoader("updatesctl", str(SCRIPT))
+spec = importlib.util.spec_from_loader("updatesctl", loader)
+u = importlib.util.module_from_spec(spec)
+loader.exec_module(u)
+
+# --- vercmp ---
+assert u.vercmp("1.14.10", "1.14.9") > 0
+assert u.vercmp("2.1.278", "2.1.267") > 0
+assert u.vercmp("2026_10_02", "2026_09_12") > 0
+assert u.vercmp("v1.2", "1.2") == 0
+assert u.vercmp("1.0", "1.0") == 0
+# A pre-release is older than the release, a suffix is never behind.
+assert u.vercmp("0.12.3_beta.4", "0.12.3") < 0
+assert u.vercmp("9.018.00_6.18.41", "9.018.00") > 0
+assert u.vercmp("3.1-659215d", "3.1") > 0
+assert u.vercmp("1.0.1", "1.0rc1") > 0
+
+print("ok")