Answer stability round 2: 0 🔴, 2 🟡; take the next release as the earliest todo.md has named since the last cut, so an emptied patch or a major jump stops the loop too, count work landed by the Unreleased entries before commits, read the default branch once, and test the emptied release and the stalled origin through real git

This commit is contained in:
2026-10-17 02:34:15 +02:00
parent 4cf3c2bd8c
commit 5ba8920dbf
13 changed files with 224 additions and 142 deletions
+27 -13
View File
@@ -1,27 +1,41 @@
import contextlib
import pathlib
import subprocess
import sys
import tempfile
import time
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from failure import Failure
from git_repo import git
import git_repo
class Git(unittest.TestCase):
# Each command is a shell alias, so it touches no repository, whatever GIT_DIR the test runs under.
class StalledOrigin(unittest.TestCase):
"""A checkout whose origin, run through git's ext transport, answers nothing for 10 s, and which records no default branch for it."""
def test_stops_git_still_running_after_the_timeout_and_says_so(self):
done = git("-c", "alias.hang=!sleep 5", "hang", timeout=0.2)
self.assertIsInstance(done, Failure)
self.assertIn("hang", done.reason)
self.assertIn("0.2 s", done.reason)
def setUp(self):
temp = tempfile.TemporaryDirectory()
self.addCleanup(temp.cleanup)
self.root = temp.name
for args in (("init", "--quiet"), ("config", "protocol.ext.allow", "always"), ("remote", "add", "origin", "ext::sleep 10")):
subprocess.run(["git", *args], capture_output=True, check=True, cwd=self.root)
def test_says_git_printed_text_that_is_not_utf_8(self):
done = git("-c", "alias.latin=!printf 'caf\\351'", "latin")
self.assertIsInstance(done, Failure)
self.assertIn("latin", done.reason)
self.assertIn("UTF-8", done.reason)
def test_reading_the_default_branch_fails_after_the_timeout(self):
started = time.monotonic()
ref = git_repo.default_ref(self.root, 0.5)
self.assertLess(time.monotonic() - started, 5)
self.assertIsInstance(ref, Failure)
self.assertIn("stopped after 0.5 s", ref.reason)
def test_fetching_the_default_branch_fails_after_the_timeout(self):
started = time.monotonic()
with contextlib.chdir(self.root):
found = git_repo.default_branch(stale_ok=True, timeout=0.5)
self.assertLess(time.monotonic() - started, 5)
self.assertIsInstance(found, Failure)
self.assertIn("stopped after 0.5 s", found.reason)
if __name__ == "__main__":