Answer stability round 1: 0 🔴, 5 🟡 (0 misread); test the two-subcommand cap, an unparsed command, an uneven token sum and a zero-second call, assert each progress line's facts in order, and say in ci.sh why it is sh; the branch endpoint landed with product-owner's answer, and the help now says the highest tag

This commit is contained in:
2026-11-09 03:09:41 +01:00
parent d62857f20e
commit 6e95eb146d
3 changed files with 30 additions and 18 deletions
+19 -6
View File
@@ -37,17 +37,23 @@ class Pattern(unittest.TestCase):
self.assertEqual(pattern("git -C /x status"), "git")
self.assertEqual(pattern("~/.claude/bin/run-heavy ./ci.sh"), "run-heavy")
def test_keeps_two_subcommands_at_most(self):
self.assertEqual(pattern("git remote add origin x"), "git remote add")
def test_names_a_command_it_cannot_parse_unparsed(self):
self.assertEqual(pattern('echo "unclosed'), "(unparsed)")
def test_takes_a_lone_cd_as_cd(self):
self.assertEqual(pattern("cd /x"), "cd")
class Tally(unittest.TestCase):
def test_counts_each_patterns_chunks_calls_tokens_and_tool_time(self):
first = [thread(call("a", "tea pr create --title t", "2026-11-01T10:00:00Z"), result("a", "x" * 400, "2026-11-01T10:00:03Z"), call("b", "git status", "2026-11-01T10:01:00Z"), result("b", "", "2026-11-01T10:01:01Z"))]
first = [thread(call("a", "tea pr create --title t", "2026-11-01T10:00:00Z"), result("a", "x" * 401, "2026-11-01T10:00:03Z"), call("b", "git status", "2026-11-01T10:01:00Z"), result("b", "", "2026-11-01T10:01:00Z"))]
second = [thread(call("c", "tea pr create --title u", "2026-11-02T10:00:00Z"), result("c", "y" * 40, "2026-11-02T10:00:02Z")), thread(call("d", "tea pr create", "2026-11-02T11:00:00Z"))]
rows = tally([first, second])
self.assertEqual(rows[0], Row("tea pr create", chunks=2, calls=3, command_tokens=(23 + 23 + 13) // 4, result_tokens=(400 + 40) // 4, seconds=5))
self.assertEqual(rows[1], Row("git status", chunks=1, calls=1, command_tokens=10 // 4, result_tokens=0, seconds=1))
self.assertEqual(rows[0], Row("tea pr create", chunks=2, calls=3, command_tokens=(23 + 23 + 13) // 4, result_tokens=(401 + 40) // 4, seconds=5))
self.assertEqual(rows[1], Row("git status", chunks=1, calls=1, command_tokens=10 // 4, result_tokens=0, seconds=0))
def test_counts_a_result_logged_twice_once(self):
rows = tally([[thread(call("a", "ls", "2026-11-01T10:00:00Z"), result("a", "abcd", "2026-11-01T10:00:01Z"), result("a", "abcd", "2026-11-01T10:00:09Z"))]])
@@ -55,7 +61,7 @@ class Tally(unittest.TestCase):
class Main(unittest.TestCase):
"""A checkout tagged v0.1.0 at 2026-11-01 and v0.2.0 at 2026-11-05, and one archived chunk finished before, between and after them."""
"""A checkout tagged v0.1.0 at 2026-11-01 and v0.2.0 at 2026-11-05, and three archived chunks, finished before, between and after them."""
def setUp(self):
self.home = pathlib.Path(os.path.realpath(tempfile.mkdtemp()))
@@ -107,8 +113,15 @@ class Main(unittest.TestCase):
self.assertEqual(ran.returncode, 1)
self.assertIn("v0.9.0", ran.stderr)
def test_refuses_more_than_one_argument(self):
self.assertEqual(self.run_tool("0.1.0", "0.2.0").returncode, 1)
def test_refuses_more_than_one_version(self):
ran = self.run_tool("0.1.0", "0.2.0")
self.assertEqual(ran.returncode, 1)
self.assertIn("one version at most", ran.stderr)
def test_refuses_an_unknown_option(self):
ran = self.run_tool("--all")
self.assertEqual(ran.returncode, 1)
self.assertIn("unknown option", ran.stderr)
if __name__ == "__main__":
+9 -11
View File
@@ -1,9 +1,9 @@
import itertools
import json
import os
import pathlib
import subprocess
import sys
import itertools
import tempfile
import typing
import unittest
@@ -365,16 +365,14 @@ class Cut(unittest.TestCase):
ran = self.cut()
self.assert_cut(ran)
merged = self.origin_git("rev-parse", "main").strip()
self.assertEqual(ran.stderr.splitlines(), [
"deploy-release: pushed the branch release-0.2.0",
"deploy-release: opened pull request 1",
"deploy-release: waiting for the checks of pull request 1; main requires CI / tests (pull_request)",
"deploy-release: the checks of pull request 1 passed",
"deploy-release: merged pull request 1",
f"deploy-release: tagged {merged[:12]} v0.2.0",
"deploy-release: pushed the tag v0.2.0",
"deploy-release: deleted the branch release-0.2.0 on origin",
])
# Each step's line, in order, with the facts it must name.
steps = [("pushed", "release-0.2.0"), ("opened", "1"), ("waiting", "1", "CI / tests (pull_request)"), ("passed", "1"), ("merged", "1"), ("tagged", merged[:12], "v0.2.0"), ("pushed", "v0.2.0"), ("deleted", "release-0.2.0")]
lines = ran.stderr.splitlines()
self.assertEqual(len(lines), len(steps), ran.stderr)
for line, facts in zip(lines, steps):
self.assertTrue(line.startswith("deploy-release: "), line)
for fact in facts:
self.assertIn(fact, line)
self.assertEqual(ran.stdout.splitlines()[-1], f"Done: v0.2.0 is cut and pushed, and {self.target} is on it.")
def test_deletes_the_merged_release_branch_on_origin(self):
+2 -1
View File
@@ -1,5 +1,6 @@
#!/bin/sh
# Runs the test suite on the committed HEAD as CI does: in a pinned Python container, as the caller's uid, so the tests root skips run too.
# Runs the test suite on the committed HEAD as CI does: in a pinned Python container, as the caller's uid, so the tests that skip under root still run.
# It is sh, not Python, since it runs on the CI runner's host, which needs only git and docker.
# The repo goes in as a git bundle rather than a bind mount, so the script works whether the CI runner shares the docker daemon's filesystem or not.
set -eu
cd "$(dirname "$0")"