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 -- "