Skip to content

Commit 29c544f

Browse files
luisleo526CORE-TOPclaude
authored
test_check_doc_reverts: do not inherit the caller's PINEFORGE_DOC_REVERT_BASE (#516)
The lab queue ships PINEFORGE_DOC_REVERT_BASE (the engine tree's merge base) in the environment of the whole preflight step. The tests in MustFail and MustPass build throwaway repositories and call the checker with no --base, so they read that value from the environment, and a sha of the engine history does not exist in a fixture repository: the checker exits 2 "cannot resolve '<sha>'". Three rows failed on every lab preflight of an engine tree (the queue-run preflights of 10-26 04:33-05:10); GitHub CI never sets the variable and did not see it. - setUpModule / tearDownModule remove the variable for this module's tests and restore the previous value (set, empty or unset) afterwards, so every present and future class is independent of the host; DefaultBase.setUp still sets its own empty value on top. - MustPass.test_explicit_base_precedes_environment_base: with the variable set to a sha the fixture does not have, an explicit --base wins and the check passes, judging from the given base. Only this test file changes; the checker is untouched. Co-authored-by: CORE-TOP <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 180630f commit 29c544f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎scripts/test_check_doc_reverts.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@
4040
"""
4141
KEEP_HANDLE = "A replacement that keeps its handle keeps its lineage and its dependents too."
4242

43+
_inherited_doc_revert_base: str | None = None
44+
45+
46+
def setUpModule() -> None:
47+
"""Fixture repositories cannot resolve the caller's engine base."""
48+
global _inherited_doc_revert_base
49+
_inherited_doc_revert_base = os.environ.pop('PINEFORGE_DOC_REVERT_BASE', None)
50+
51+
52+
def tearDownModule() -> None:
53+
if _inherited_doc_revert_base is None:
54+
os.environ.pop('PINEFORGE_DOC_REVERT_BASE', None)
55+
else:
56+
os.environ['PINEFORGE_DOC_REVERT_BASE'] = _inherited_doc_revert_base
57+
4358

4459
class Repo:
4560
"""A git repository with the gate script in every commit."""
@@ -261,6 +276,15 @@ def test_a_fresh_rewrite_and_a_reanchor_need_no_name(self) -> None:
261276
code, out = r.run('--base', base)
262277
self.assertEqual(code, 0, out)
263278

279+
def test_explicit_base_precedes_environment_base(self) -> None:
280+
with repo() as r:
281+
base = r.commit(BASE_PAGE, 'docs: the guide')
282+
r.commit(with_keep_handle(), 'docs: the next lane adds a sentence')
283+
with mock.patch.dict(os.environ, {'PINEFORGE_DOC_REVERT_BASE': '0' * 40}):
284+
code, out = r.run('--base', base)
285+
self.assertEqual(code, 0, out)
286+
self.assertIn('1 commits since ' + base[:guard.SHA_CHARS], out)
287+
264288
def test_a_merged_pull_request_is_the_base_without_a_main_ref(self) -> None:
265289
"""A squash merge on main carries a whole branch's deletions under the pull
266290
request's title; its branch was judged commit by commit before it merged, so

0 commit comments

Comments
 (0)