Files
libretro/tests/test_required_only_archives.py
T
Abdessamad Derraz fbbb941e38 refactor: one owner for the test scratch folder
Test modules passed dir= the repository's tmp/ or a hard-coded tmp/tests by hand, and seven modules kept their own _tempdir copy. Under run_tests.py the literal tmp/tests did not exist in a fresh clone (FileNotFoundError in test_core_probe and scratch_checkout), and dir=tmp/ wrote beside the per-module scratch folders. Every temporary directory now lands in the folder tests/__init__ sets, and scratch_dir() replaces the copies. The X socket binds by a relative name, since a scratch path can exceed the 108-byte AF_UNIX limit. The journeys keep the short tmp/ root: their word budgets count the printed card path.
2026-11-21 06:04:40 +01:00

41 lines
1.3 KiB
Python

"""--required-only reaches archives in emulator packs.
geolith declares neocd.zip and irrmaze.zip optional, members included, and
its _Required pack held them anyway: the archive loop never read `required`.
"""
from __future__ import annotations
import tests
import subprocess
import sys
import tempfile
import unittest
import zipfile
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
class RequiredOnlyArchives(unittest.TestCase):
def test_optional_archives_stay_out(self):
if not (REPO_ROOT / "database.json").is_file():
self.skipTest("database.json not built")
with tempfile.TemporaryDirectory() as tmp:
result = subprocess.run(
[sys.executable, "scripts/generate_pack.py", "--emulator", "geolith",
"--required-only", "--offline", "--output-dir", tmp],
capture_output=True, check=False, text=True, cwd=REPO_ROOT, timeout=600,
)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
pack = next(Path(tmp).glob("*.zip"))
names = set(zipfile.ZipFile(pack).namelist())
self.assertNotIn("neocd.zip", names)
self.assertNotIn("irrmaze.zip", names)
self.assertIn("neogeo.zip", names)
if __name__ == "__main__":
unittest.main()