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 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
81f160d400
commit
ab3f5633fc
@@ -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 -- "
|
||||
|
||||
Reference in New Issue
Block a user