mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-30 15:47:20 -05:00
fix: claim the pack output before refreshing data
generate_pack refreshed the data directories before probing its output lock. The refresh waits for every run holding a tree, and a pipeline holds them all: a second build sat silent for hours instead of being refused. The output lock is now taken first, and a refresh that has to wait for a tree names it.
This commit is contained in:
1 parent
bca76e8ace
commit
0061041466
4 files changed
+123
-36
No files matched your search
@@ -110,6 +110,36 @@ class PackLockCliTest(unittest.TestCase):
|
||||
self.assertEqual(proc.returncode, 1, proc.stdout + proc.stderr)
|
||||
self.assertIn("is in use by another run", proc.stdout)
|
||||
|
||||
def test_a_held_output_is_refused_before_the_data_refresh(self):
|
||||
"""The refresh waits for every run holding a data tree, and a
|
||||
pipeline holds them all for its whole run: probed after the refresh,
|
||||
a second build sat silent for hours instead of being refused."""
|
||||
from refresh_data_dirs import cache_lock # noqa: PLC0415
|
||||
|
||||
platforms = Path(self.dir) / "platforms"
|
||||
platforms.mkdir()
|
||||
for name in ("_registry.yml", "_shared.yml", "misterfpga.yml"):
|
||||
shutil.copyfile(REPO_ROOT / "platforms" / name, platforms / name)
|
||||
cache = Path(self.dir) / "cache" / "probe"
|
||||
cache.mkdir(parents=True)
|
||||
(platforms / "_data_dirs.yml").write_text(
|
||||
"data_directories:\n probe:\n source_type: zip\n"
|
||||
f" source_url: https://example.invalid/probe.zip\n"
|
||||
f" local_cache: {cache}\n"
|
||||
)
|
||||
output = Path(self.dir) / "out"
|
||||
with artifact_lock(str(output)), cache_lock(cache):
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--platform", "misterfpga",
|
||||
"--platforms-dir", str(platforms), "--output-dir", str(output)],
|
||||
capture_output=True, text=True, cwd=str(REPO_ROOT), timeout=120,
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
self.fail("generate_pack waited on the data tree instead of refusing")
|
||||
self.assertEqual(proc.returncode, 1, proc.stdout + proc.stderr)
|
||||
self.assertIn("is in use by another run", proc.stdout)
|
||||
|
||||
def test_every_writing_mode_refuses_a_locked_output(self):
|
||||
"""Two of seven modes took the lock, and five wrote straight into it.
|
||||
|
||||
|
||||
@@ -166,6 +166,33 @@ class EmulatorPackHoldsTheCache(unittest.TestCase):
|
||||
self.assertEqual(held, [True])
|
||||
|
||||
|
||||
class AWaitIsAnnounced(unittest.TestCase):
|
||||
def test_a_held_tree_is_named_before_the_wait(self):
|
||||
"""A pipeline holds every tree for its run: the refresh beside it
|
||||
waited with nothing on screen."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "probe"
|
||||
taken = threading.Event()
|
||||
|
||||
def second_run() -> None:
|
||||
with rdd.cache_lock(cache):
|
||||
taken.set()
|
||||
|
||||
with self.assertLogs(rdd.log, "WARNING") as logs:
|
||||
with rdd.cache_lock(cache):
|
||||
worker = threading.Thread(target=second_run)
|
||||
worker.start()
|
||||
for _ in range(100):
|
||||
if logs.output:
|
||||
break
|
||||
threading.Event().wait(0.05)
|
||||
self.assertFalse(taken.is_set())
|
||||
worker.join(10)
|
||||
self.assertTrue(taken.is_set())
|
||||
self.assertIn("waiting for", logs.output[0])
|
||||
self.assertIn("probe", logs.output[0])
|
||||
|
||||
|
||||
class DryRunReport(unittest.TestCase):
|
||||
"""What a dry run says: why each entry would be fetched, and how many."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user