fix: let two generators purge the coverage cache

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 03:34:17 +01:00
1 parent 96f100ac22
commit 286e39d199
2 files changed
+22 -2

No files matched your search

+17
View File
@@ -95,6 +95,23 @@ class CoverageCache(unittest.TestCase):
self._run()
self.assertEqual(len(list((self.work / "cache").glob("*.pickle"))), 1)
def test_a_purge_racing_another_generator_does_not_fail(self):
"""generate_site and generate_readme purge the same directory: one
unlinking a pickle the other had listed ended on FileNotFoundError."""
cache_dir = self.work / "cache"
cache_dir.mkdir()
ghost = cache_dir / "gone.pickle"
real_glob = Path.glob
def listing_a_vanished_file(path, pattern):
found = list(real_glob(path, pattern))
return [*found, ghost] if path == cache_dir else found
with mock.patch.object(Path, "glob", listing_a_vanished_file):
coverages = self._run()
self.assertEqual(sorted(coverages), ["alpha", "beta"])
self.assertEqual(len(list(cache_dir.glob("*.pickle"))), 1)
def test_a_missing_input_directory_stops_the_run(self):
"""A missing --emulators-dir skipped every platform as if it had no
YAML, then replaced the cache with the empty result."""