Answer stability round 3: 0 🔴, 4 🟡; test todo.md at the cut, before it and on a merged side branch through real git, count only the default branch's own commits since the cut, test a cut release named at the tag, restore the UTF-8 and timeout tests of git, and drop the wall-clock asserts

This commit is contained in:
2026-10-17 02:50:29 +02:00
parent c89dd87a18
commit 46ccea1322
6 changed files with 68 additions and 16 deletions
+16 -5
View File
@@ -3,7 +3,6 @@ import pathlib
import subprocess
import sys
import tempfile
import time
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
@@ -12,6 +11,22 @@ from failure import Failure
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.
def test_stops_git_still_running_after_the_timeout_and_says_so(self):
done = git_repo.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 test_says_git_printed_text_that_is_not_utf_8(self):
done = git_repo.git("-c", "alias.latin=!printf 'caf\\351'", "latin")
self.assertIsInstance(done, Failure)
self.assertIn("latin", done.reason)
self.assertIn("UTF-8", done.reason)
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."""
@@ -23,17 +38,13 @@ class StalledOrigin(unittest.TestCase):
subprocess.run(["git", *args], capture_output=True, check=True, cwd=self.root)
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)