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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:04:40 +01:00
1 parent ec50bf6b41
commit fbbb941e38
127 files changed
+665 -826

No files matched your search

+4 -4
View File
@@ -160,7 +160,7 @@ class ParsingTests(unittest.TestCase):
def test_elf_comment(self) -> None:
self.assertIsInstance(core_probe.elf_comment(Path(sys.executable).resolve()), list)
with tempfile.NamedTemporaryFile(dir=REPO_ROOT / "tmp" / "tests") as handle:
with tempfile.NamedTemporaryFile() as handle:
handle.write(b"not an elf")
handle.flush()
self.assertEqual(core_probe.elf_comment(Path(handle.name)), [])
@@ -178,7 +178,7 @@ class ParsingTests(unittest.TestCase):
self.assertFalse(core_probe.uniform_frame(b"\x00\x00\x00\x00\x00\x00\x00\x01", 4))
def test_cue_tracks(self) -> None:
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as tmp:
with tempfile.TemporaryDirectory() as tmp:
cue = Path(tmp, "d.cue")
cue.write_text('FILE "a b.bin" BINARY\n TRACK 01 MODE2/2352\nFILE c.bin BINARY\n',
encoding="utf-8")
@@ -477,7 +477,7 @@ class FakeCoreTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
cls.tmp = Path(tempfile.mkdtemp())
source = cls.tmp / "fake.c"
source.write_text(FAKE_CORE, encoding="utf-8")
cls.core = cls.tmp / "fake_libretro.so"
@@ -739,7 +739,7 @@ class Sandbox(unittest.TestCase):
def setUp(self) -> None:
if not core_probe.sandbox_argv([])[0]:
self.skipTest("no working bwrap on this host")
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
self.tmp = Path(tempfile.mkdtemp())
self.addCleanup(shutil.rmtree, self.tmp, True)
self.out = self.tmp / "out"
self.inputs = self.tmp / "inputs"