From ab3f5633fcb8fa604fe5e4a0fa7f98e07a4610c3 Mon Sep 17 00:00:00 2001 From: alexpolo1 Date: Thu, 6 Aug 2026 19:08:43 +0200 Subject: [PATCH] fix(test): bat-file tests failed on the stable branch test_setup_bat_files.py asserted that run_asset_extractor.bat and run_quest_debug.bat exist in the repo root. Those are developer tools that the end-user `stable` branch deliberately strips, so a fresh clone of stable shipped 4 failing tests even though the bot was fine. Split the list into CORE_BATS (install/find_python/run_botty -- required on every branch) and OPTIONAL_BATS (dev tooling -- validated only when present). The username, absolute-path and find_python checks now iterate over the files that actually exist rather than a hardcoded list. Found by cloning stable from GitHub onto a clean machine and running the suite as a new user would. Co-Authored-By: Claude Opus 4.8 --- test/test_setup_bat_files.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/test/test_setup_bat_files.py b/test/test_setup_bat_files.py index b122211..2f83c7c 100644 --- a/test/test_setup_bat_files.py +++ b/test/test_setup_bat_files.py @@ -11,10 +11,16 @@ import re ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -EXPECTED_BATS = [ +# Required on every branch -- without these the bot cannot be installed or run. +CORE_BATS = [ "install.bat", "find_python.bat", "run_botty.bat", +] + +# Developer tooling. The end-user `stable` branch deliberately strips these, so +# they are validated only when present rather than asserted to exist. +OPTIONAL_BATS = [ "run_asset_extractor.bat", "run_quest_debug.bat", ] @@ -26,13 +32,22 @@ def _read(name): return open(os.path.join(ROOT, name)).read() +def _exists(name): + return os.path.isfile(os.path.join(ROOT, name)) + + +def _present(names): + """Only the given bats that actually exist in this checkout.""" + return [n for n in names if _exists(n)] + + def _bat_exists(name): assert os.path.isfile(os.path.join(ROOT, name)), f"{name} is missing from repo root" class TestBatFilesExist: def test_all_bats_present(self): - for name in EXPECTED_BATS: + for name in CORE_BATS: _bat_exists(name) @@ -42,12 +57,10 @@ class TestNoHardcodedUsernames: _CHECKED = [ "find_python.bat", "run_botty.bat", - "run_asset_extractor.bat", - "run_quest_debug.bat", - ] + ] + OPTIONAL_BATS def test_no_hardcoded_usernames(self): - for name in self._CHECKED: + for name in _present(self._CHECKED): content = _read(name).lower() for uname in USERNAMES_TO_BLOCK: for line in content.split("\n"): @@ -59,7 +72,7 @@ class TestNoHardcodedUsernames: ) def test_no_absolute_home_paths(self): - for name in self._CHECKED: + for name in _present(self._CHECKED): content = _read(name) # Find C:\Users\ followed by a literal username (not %USERNAME%) bad = re.findall(r"C:\\Users\\([^%\s]+)", content) @@ -70,14 +83,10 @@ class TestNoHardcodedUsernames: class TestFindPythonUsage: """All run_*.bat should source find_python.bat.""" - _RUN_BATS = [ - "run_botty.bat", - "run_asset_extractor.bat", - "run_quest_debug.bat", - ] + _RUN_BATS = ["run_botty.bat"] + OPTIONAL_BATS def test_run_bats_call_find_python(self): - for name in self._RUN_BATS: + for name in _present(self._RUN_BATS): content = _read(name) assert "find_python.bat" in content, ( f"{name} does not call find_python.bat -- "