fix: keep a write pass going on a cold cache

--rebase-refs or --bump-commit with --offline read the prose of a
profile whose cited files were never cached, and the NotCachedError
ended the whole pass on a traceback. The profile is named, counted
as failed and left as it was, and the pass goes on.
This commit is contained in:
Abdessamad Derraz committed 2026-11-18 12:50:24 +01:00
1 parent c2f8daf0f4
commit 2b3551dd22
2 files changed
+27

No files matched your search

+6
View File
@@ -334,6 +334,12 @@ def _read_one(
# The guard already left the file untouched, so keep going.
print(f"{name}: write refused: {exc}", file=sys.stderr)
failed.add(name)
except upstream.UpstreamError as exc:
# A prose read the writes need could not be made (offline with
# a cold cache, a forge down): the profile was put back, and one
# profile must not end the pass for the others.
print(f"{name}: not written: {exc}", file=sys.stderr)
failed.add(name)
# Profiles this run wrote. Their new pins name trees the site's record of
+21
View File
@@ -2718,6 +2718,27 @@ class TestWriteDryRun(unittest.TestCase):
self._run(self._args(rebase_refs=True, dry_run=False), self._shifted())
self.assertEqual(self.path.read_bytes(), before)
def test_a_write_pass_names_a_profile_the_cache_cannot_answer(self):
"""--rebase-refs --offline on a profile whose cited files were never
cached ended the whole pass on a NotCachedError traceback."""
from unittest import mock
before = self.path.read_bytes()
skipped = ProfileReport(name="p", entries=[], counts={}, skipped="offline: not cached")
cold = upstream.NotCachedError("o/n@pin:a.c is not in the offline cache")
reports: list[ProfileReport] = []
failed: set[str] = set()
with mock.patch.object(profiling_run, "_build_full_report", return_value=skipped), \
mock.patch.object(profiling_run, "realign_prose", side_effect=cold), \
contextlib.redirect_stderr(io.StringIO()) as err:
profiling_run._read_one(
self._args(rebase_refs=True), "p", yaml.safe_load(SAMPLE), reports, failed, True
)
self.assertEqual(reports, [skipped])
self.assertEqual(failed, {"p"})
self.assertIn("p: not written: o/n@pin:a.c is not in the offline cache", err.getvalue())
self.assertEqual(self.path.read_bytes(), before)
def test_rebase_states_the_move_and_leaves_the_file(self):
before = self.path.read_text()
output = self._run(self._args(rebase_refs=True), self._shifted())