From 9c79aa8bd34b6ed2f9f92f85c7724261ff9ef1fd Mon Sep 17 00:00:00 2001 From: SUaDtL Date: Mon, 20 Jul 2026 05:09:28 -0400 Subject: [PATCH] test(gitlib): decouple semantics from UI deadline The real-repository dirty-state check should prove tracked and untracked semantics without inheriting the statusline's 100 ms response budget. Keep that budget covered by its dedicated mocked test while giving the integration test a contention-tolerant deadline. Closes #352 --- plugins/ca/hooks/tests/test_gitlib.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/ca/hooks/tests/test_gitlib.py b/plugins/ca/hooks/tests/test_gitlib.py index e9957c5f..30ca61d7 100644 --- a/plugins/ca/hooks/tests/test_gitlib.py +++ b/plugins/ca/hooks/tests/test_gitlib.py @@ -172,14 +172,22 @@ def test_tracked_and_untracked_changes_remain_dirty(self): "user.email=test@example.invalid", "commit", "-qm", "initial"], check=True) - with open(tracked, "a", encoding="utf-8") as f: - f.write("changed\n") - self.assertTrue(_gitlib.git_dirty(root)) - - subprocess.run(["git", "-C", root, "restore", "tracked.txt"], check=True) - with open(os.path.join(root, "untracked.txt"), "w", encoding="utf-8") as f: - f.write("new\n") - self.assertTrue(_gitlib.git_dirty(root)) + # This test exercises dirty-state semantics with a real repository. + # The production budget is covered separately above and is too tight + # to serve as an integration-test deadline on a contended CI runner. + with mock.patch.object( + _gitlib, "DIRTY_CHECK_TIMEOUT_SECONDS", 5.0): + with open(tracked, "a", encoding="utf-8") as f: + f.write("changed\n") + self.assertTrue(_gitlib.git_dirty(root)) + + subprocess.run( + ["git", "-C", root, "restore", "tracked.txt"], check=True) + with open( + os.path.join(root, "untracked.txt"), + "w", encoding="utf-8") as f: + f.write("new\n") + self.assertTrue(_gitlib.git_dirty(root)) class StatuslineLinkedWorktreeTests(unittest.TestCase):