From 25ee245435dc2c1118e6a027f7720cf6f04e7450 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Mon, 9 Nov 2026 06:53:57 +0100 Subject: [PATCH] chore: alert before install.py outgrows the cap install.sh and install.ps1 refuse an installer above 2 MiB. The test fails once install.py passes 95 % of the cap both bootstraps read, so the cap is raised or the installer made smaller before a release stops every one-liner. Raising the cap raises the alert with it. --- tests/test_installer_size.py | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/test_installer_size.py diff --git a/tests/test_installer_size.py b/tests/test_installer_size.py new file mode 100644 index 000000000..257be1652 --- /dev/null +++ b/tests/test_installer_size.py @@ -0,0 +1,53 @@ +"""install.py stays under the size the one-liners accept. + +install.sh refuses an installer above MAX_INSTALLER_BYTES and install.ps1 +above $maximumInstallerBytes: past them every curl | sh and irm | iex +stops before the first file. This test fails while there is still room, +so the cap is raised, or the installer made smaller, before a release. +""" + +from __future__ import annotations + +import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache + +import re +import unittest +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parent.parent + +# The share of the cap install.py may use: 1.9 MiB of 2 MiB. Raising the +# cap in both bootstraps raises the alert with it. +ALERT_SHARE = 0.95 + +_UNITS = {"": 1, "KB": 1024, "MB": 1024 ** 2, "GB": 1024 ** 3} + + +def shell_cap() -> int: + text = (REPO_ROOT / "install.sh").read_text(encoding="utf-8") + return int(re.search(r"^MAX_INSTALLER_BYTES=(\d+)$", text, re.MULTILINE).group(1)) + + +def powershell_cap() -> int: + text = (REPO_ROOT / "install.ps1").read_text(encoding="utf-8") + found = re.search(r"\$maximumInstallerBytes\s*=\s*(\d+)\s*(KB|MB|GB)?\b", text) + return int(found.group(1)) * _UNITS[found.group(2) or ""] + + +class InstallerFitsTheOneLiners(unittest.TestCase): + def test_both_bootstraps_accept_the_same_size(self): + self.assertEqual(shell_cap(), powershell_cap()) + + def test_install_py_stays_below_the_alert(self): + cap = shell_cap() + size = (REPO_ROOT / "install.py").stat().st_size + alert = int(cap * ALERT_SHARE) + self.assertLess( + size, alert, + f"install.py is {size} bytes, past {alert} of the {cap} the one-liners " + "accept: raise MAX_INSTALLER_BYTES in install.sh and $maximumInstallerBytes " + "in install.ps1, or make the installer smaller") + + +if __name__ == "__main__": + unittest.main()