Answer stability round 1: 0 🔴, 17 🟡 (0 misread); read line ends as before, drop a stale copy, say why a read failed, and test each failure the round named
This commit is contained in:
@@ -5,6 +5,7 @@ from branch_chunks.cut import BranchChunk, cut_branch, LOG, NOT_WORK, plan_revis
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git, Git, text_at
|
||||
from project_config.main import located
|
||||
from project_config.settings import ProjectConfig
|
||||
from record_store.stores import store
|
||||
|
||||
|
||||
@@ -17,13 +18,20 @@ def unsupported(checkout: str | None, home: pathlib.Path, run: Git = git) -> str
|
||||
config = located(checkout, home, run)
|
||||
if isinstance(config, Failure):
|
||||
return None
|
||||
held = [(str(config.paths["plan"]), config.tracked("plan")), *((record.label, record.tracked) for record in (store(config, name) for name in READ_AT if name != "plan"))]
|
||||
elsewhere = [label for (label, tracked), path in zip(held, READ_AT.values()) if tracked != path]
|
||||
elsewhere = [label for name, path in READ_AT.items() for label, tracked in [held(config, name)] if tracked != path]
|
||||
if not elsewhere:
|
||||
return None
|
||||
return f"the project's config puts {', '.join(elsewhere)} elsewhere than {', '.join(READ_AT.values())} in the checkout, the only paths whose commits are read so far"
|
||||
|
||||
|
||||
def held(config: ProjectConfig, name: str) -> tuple[str, str | None]:
|
||||
"""What a message calls the plan or the record that setting name names in config, and its path from the checkout's top, None where it is kept elsewhere."""
|
||||
if name == "plan":
|
||||
return str(config.paths[name]), config.tracked(name)
|
||||
record = store(config, name)
|
||||
return record.label, record.tracked
|
||||
|
||||
|
||||
def branch_chunks(default: str, run: Git) -> list[BranchChunk] | Failure:
|
||||
"""Each chunk on the default branch's first-parent line, newest first, with the todo.md items it shipped and the later chunks that fixed code it shipped.
|
||||
|
||||
|
||||
@@ -811,6 +811,16 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertIn("already holds an entry on", again.stderr)
|
||||
self.assertEqual([entry.ruling for entry in entries((self.checkout / "docs" / "comprehension-history.md").read_text())], ["better"])
|
||||
|
||||
def test_leaves_a_history_it_cannot_read_as_it_is(self):
|
||||
history = self.checkout / "docs" / "comprehension-history.md"
|
||||
history.parent.mkdir(exist_ok=True)
|
||||
history.write_bytes(b"# Comprehension history\n\xff\n")
|
||||
votes_file = self.seats_file(f"PR #2 at {self.start}, against {self.start}\n\nMid A: {said('better')}\n\nInherited architect: {said('better')}\n", "votes.md")
|
||||
ran = self.run_tool("record-ruling", votes_file)
|
||||
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
||||
self.assertIn(f"cannot read {history}: not UTF-8 on line 2", ran.stderr)
|
||||
self.assertEqual(history.read_bytes(), b"# Comprehension history\n\xff\n")
|
||||
|
||||
def test_records_a_scoring_run_with_its_means(self):
|
||||
line = "Navigation 7, Locality 6.5, Shape 7, Self-sufficiency 6.5, Overall 7"
|
||||
seats = "".join(f"\n{seat}: {line}\n\n- `bin/a.py:3` `f`: long\n" for seat in ("Junior A", "Mid A", "Maintainability senior", "Inherited architect"))
|
||||
@@ -1191,6 +1201,14 @@ class LarvReviewTool(unittest.TestCase):
|
||||
ran = self.run_tool("reviewer-header", "prose")
|
||||
self.assertEqual(ran.stdout.splitlines()[-1], f"Principles: read {self.checkout}/AGENTS.md first, for the project principles and the decision titles.")
|
||||
|
||||
def test_reviewer_header_names_the_decision_log_where_the_project_keeps_no_agents_md(self):
|
||||
(self.checkout / "docs").mkdir(exist_ok=True)
|
||||
(self.checkout / "docs" / "decisions.md").write_text("1. A principle.\n\n# Decisions\n")
|
||||
(self.checkout / "CHANGELOG.md").write_text("# Changelog\n")
|
||||
self.bare("prose-reviewer")
|
||||
ran = self.run_tool("reviewer-header", "prose")
|
||||
self.assertEqual(ran.stdout.splitlines()[-1], f"Principles: read {self.checkout}/docs/decisions.md first, up to `# Decisions`, for the project principles and the decision titles.")
|
||||
|
||||
def bare(self, agent):
|
||||
(self.checkout.parent / ".claude" / "agents").mkdir(parents=True, exist_ok=True)
|
||||
(self.checkout.parent / ".claude" / "agents" / f"{agent}.md").write_text("---\nomitClaudeMd: true\n---\n")
|
||||
|
||||
@@ -1133,6 +1133,17 @@ class RouteSources(unittest.TestCase):
|
||||
chunk_start.fetched_todo(a_loop(FakeEffects(git=git).effects(), root=root, paths=paths.paths_from(home)))
|
||||
self.assertEqual(stderr.getvalue(), f"{STAMP} {said}" if said else "")
|
||||
|
||||
def test_reads_the_changelog_the_default_branch_holds_through_the_loops_git(self):
|
||||
def git(*args, **options):
|
||||
answers = {"remote": "origin\n", "symbolic-ref": "origin/main\n", "show": f"what {args[-1]} holds\n"}
|
||||
return answers.get(args[0], "1\n")
|
||||
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = configured(self, pathlib.Path(root))
|
||||
effects = dataclasses.replace(FakeEffects().effects(), git=git)
|
||||
held = chunk_start.fetched_plan(a_loop(effects, root=root, paths=paths.paths_from(folder.parents[1])))
|
||||
self.assertEqual(held.cut.changelog, "what origin/main:CHANGELOG.md holds\n")
|
||||
|
||||
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_stops_without_a_config(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = configured(self, pathlib.Path(root))
|
||||
@@ -1468,7 +1479,7 @@ class Records(unittest.TestCase):
|
||||
claude_md.mkdir(parents=True)
|
||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
|
||||
pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True)
|
||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"cannot read {root}/docs/decisions.md: [Errno 21] Is a directory: '{root}/docs/decisions.md' - the judge cannot read the records."))
|
||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"cannot read {root}/docs/decisions.md: Is a directory - the judge cannot read the records."))
|
||||
pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n")
|
||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the records."))
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ class Act(unittest.TestCase):
|
||||
|
||||
def test_a_record_that_fails_is_a_failure(self):
|
||||
self.assertEqual(main.act("open", MemoryStore(fails="the wiki is down"), self.copy), Failure("the wiki is down"))
|
||||
record = MemoryStore("# Decisions\n")
|
||||
main.act("open", record, self.copy)
|
||||
record.fails = "the wiki is down"
|
||||
self.assertEqual(main.act("save", record, self.copy), Failure("the wiki is down"))
|
||||
|
||||
|
||||
class BlackBox(unittest.TestCase):
|
||||
|
||||
@@ -19,6 +19,7 @@ from failure import Failure
|
||||
from reading_cost import figures, main, measure
|
||||
from transcript_archive.read import finished_chunks, FinishedChunk
|
||||
from test_env import isolated_env
|
||||
from record_store.fakes import MemoryStore
|
||||
from transcript_archive import outcomes
|
||||
from transcript_archive.location import project_archive
|
||||
from reading_cost.shell_reads import Reads, shell_reads
|
||||
@@ -216,5 +217,16 @@ class Located(unittest.TestCase):
|
||||
self.assertIsInstance(main.located(), Failure)
|
||||
|
||||
|
||||
class Update(unittest.TestCase):
|
||||
def test_fails_where_the_record_refuses_the_write(self):
|
||||
class Unwritable(MemoryStore):
|
||||
def write(self, text: str) -> Failure | None:
|
||||
return Failure("the wiki is down")
|
||||
|
||||
archive = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||
updated = main.update(Unwritable("# Reading cost\n"), archive, Checkout("/c/p", "/c/p", frozenset()), "/h", "2026-11-14T00:00:00Z")
|
||||
self.assertEqual(updated, Failure("the wiki is down"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""What every record backend must hold, as tests. A backend's test case inherits RecordStoreContract and unittest.TestCase, and builds its store in new_store."""
|
||||
import typing
|
||||
|
||||
from record_store.stores import held_at, RecordStore
|
||||
from record_store.stores import RecordStore
|
||||
|
||||
|
||||
class RecordStoreContract:
|
||||
@@ -30,13 +30,3 @@ class RecordStoreContract:
|
||||
|
||||
def test_names_itself_for_a_message(self) -> None:
|
||||
self.assertTrue(self.new_store().label.strip())
|
||||
|
||||
def test_reads_as_it_stands_at_any_revision_where_no_commit_holds_it(self) -> None:
|
||||
store = self.new_store()
|
||||
store.write("as it stands\n")
|
||||
if store.tracked is None:
|
||||
self.assertEqual(held_at("no-such-revision", store, "/nowhere", run=refuse), "as it stands\n")
|
||||
|
||||
|
||||
def refuse(*args: str, **options: object) -> str:
|
||||
raise AssertionError(f"git {' '.join(args)} ran for a record no commit holds")
|
||||
|
||||
@@ -44,18 +44,19 @@ class FileStore:
|
||||
|
||||
def read(self) -> str | Failure:
|
||||
try:
|
||||
# Decoded from bytes, so the text keeps the line ends the file holds.
|
||||
return self.path.read_bytes().decode("utf-8")
|
||||
return self.path.read_text(encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
return ""
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"cannot read {self.path}: {failure}")
|
||||
except UnicodeDecodeError as failure:
|
||||
return Failure(f"cannot read {self.path}: not UTF-8 on line {failure.object[: failure.start].count(b'\n') + 1}")
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot read {self.path}: {failure.strerror}")
|
||||
|
||||
def write(self, text: str) -> Failure | None:
|
||||
try:
|
||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot write {self.path}: {failure}")
|
||||
return Failure(f"cannot write {self.path}: {failure.strerror}")
|
||||
unwritten = replace_file(self.path, text.encode("utf-8"))
|
||||
return Failure(f"cannot write {self.path}: {unwritten.reason}") if unwritten else None
|
||||
|
||||
@@ -79,8 +80,13 @@ def local_file(record: RecordStore, copy: pathlib.Path) -> pathlib.Path | Failur
|
||||
text = record.read()
|
||||
if isinstance(text, Failure):
|
||||
return text
|
||||
if text and (unwritten := FileStore(copy, None).write(text)):
|
||||
return unwritten
|
||||
if text:
|
||||
return FileStore(copy, None).write(text) or copy
|
||||
try:
|
||||
# An earlier copy would read as the record's text, and `stored` would put it back.
|
||||
copy.unlink(missing_ok=True)
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot remove {copy}: {failure.strerror}")
|
||||
return copy
|
||||
|
||||
|
||||
@@ -91,4 +97,4 @@ def stored(record: RecordStore, copy: pathlib.Path) -> Failure | None:
|
||||
text = FileStore(copy, None).read()
|
||||
if isinstance(text, Failure):
|
||||
return text
|
||||
return record.write(text) if text else Failure(f"{copy} is missing or empty, so nothing is stored in {record.label}; `record open` writes the file to edit")
|
||||
return record.write(text) if text else Failure(f"{copy} is missing or empty, so nothing is stored in {record.label}")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -41,10 +40,16 @@ class FileStore(unittest.TestCase):
|
||||
|
||||
def test_a_file_that_is_not_utf8_is_a_failure_naming_it(self):
|
||||
path = self.folder / "decisions.md"
|
||||
path.write_bytes(b"\xff\xfe")
|
||||
path.write_bytes(b"# Decisions\n\xff\xfe")
|
||||
self.assertEqual(stores.FileStore(path, None).read(), Failure(f"cannot read {path}: not UTF-8 on line 2"))
|
||||
|
||||
def test_a_folder_where_the_file_goes_is_a_failure_naming_it_once(self):
|
||||
path = self.folder / "decisions.md"
|
||||
path.mkdir()
|
||||
read = stores.FileStore(path, None).read()
|
||||
self.assertIsInstance(read, Failure)
|
||||
self.assertIn(f"cannot read {path}: ", read.reason)
|
||||
self.assertTrue(read.reason.startswith(f"cannot read {path}: "))
|
||||
self.assertEqual(read.reason.count(str(path)), 1)
|
||||
|
||||
def test_a_write_that_fails_is_a_failure_naming_it(self):
|
||||
(self.folder / "docs").write_text("a file where the folder goes")
|
||||
@@ -65,11 +70,10 @@ class FileStore(unittest.TestCase):
|
||||
self.assertIsInstance(written, Failure)
|
||||
self.assertIn(f"cannot write {path}: ", written.reason)
|
||||
|
||||
def test_a_write_keeps_the_text_as_given_not_the_platforms_line_ends(self):
|
||||
path = self.folder / "decisions.md"
|
||||
stores.FileStore(path, None).write("one\r\ntwo\n")
|
||||
self.assertEqual(path.read_bytes(), b"one\r\ntwo\n")
|
||||
self.assertEqual(stores.FileStore(path, None).read(), "one\r\ntwo\n")
|
||||
def test_a_file_with_windows_line_ends_reads_with_plain_ones(self):
|
||||
path = self.folder / "CHANGELOG.md"
|
||||
path.write_bytes(b"# Changelog\r\n\r\n## Unreleased\r\n")
|
||||
self.assertEqual(stores.FileStore(path, None).read(), "# Changelog\n\n## Unreleased\n")
|
||||
|
||||
|
||||
class HeldAt(unittest.TestCase):
|
||||
@@ -94,7 +98,10 @@ class HeldAt(unittest.TestCase):
|
||||
|
||||
def test_a_record_outside_the_checkout_reads_as_it_stands(self):
|
||||
store = stores.FileStore(self.top / "CHANGELOG.md", None)
|
||||
self.assertEqual(stores.held_at("main", store, str(self.top)), "as it stands\n")
|
||||
self.assertEqual(stores.held_at("no-such-revision", store, "/nowhere", run=self.refuse), "as it stands\n")
|
||||
|
||||
def refuse(self, *args: str, **options: object) -> str:
|
||||
self.fail(f"git {' '.join(args)} ran for a record no commit holds")
|
||||
|
||||
|
||||
class LocalFile(unittest.TestCase):
|
||||
@@ -120,6 +127,19 @@ class LocalFile(unittest.TestCase):
|
||||
copy = self.folder / "decisions.md"
|
||||
self.assertEqual((stores.local_file(MemoryStore(), copy), copy.exists()), (copy, False))
|
||||
|
||||
def test_a_record_that_is_empty_now_loses_the_copy_made_earlier(self):
|
||||
record, copy = MemoryStore("# Decisions\n"), self.folder / "decisions.md"
|
||||
stores.local_file(record, copy)
|
||||
record.text = ""
|
||||
self.assertEqual((stores.local_file(record, copy), copy.exists()), (copy, False))
|
||||
|
||||
def test_a_copy_that_cannot_be_written_is_a_failure_naming_it(self):
|
||||
(self.folder / "copies").write_text("a file where the folder goes")
|
||||
copy = self.folder / "copies" / "decisions.md"
|
||||
opened = stores.local_file(MemoryStore("# Decisions\n"), copy)
|
||||
self.assertIsInstance(opened, Failure)
|
||||
self.assertIn(f"cannot write {copy}: ", opened.reason)
|
||||
|
||||
def test_storing_a_missing_copy_fails_and_leaves_the_record(self):
|
||||
record = MemoryStore("kept\n")
|
||||
self.assertIn("is missing or empty", stores.stored(record, self.folder / "decisions.md").reason)
|
||||
@@ -151,13 +171,5 @@ class Store(unittest.TestCase):
|
||||
self.assertEqual(str(refused.exception), "plan is not a record; the records are decisions, score-anchors, comprehension-history, reading-cost, changelog")
|
||||
|
||||
|
||||
class OneWayIn(unittest.TestCase):
|
||||
def test_no_tool_reads_a_records_place_from_the_config_itself(self):
|
||||
bin_folder = pathlib.Path(__file__).resolve().parents[1]
|
||||
reach = re.compile(r"""(?:paths\[|\.place\(|\.tracked\()["'](?:%s)["']""" % "|".join(stores.RECORDS))
|
||||
found = [f"{path.relative_to(bin_folder)}:{number}" for path in sorted(bin_folder.rglob("*.py")) if "test_" not in path.name and path.parent.name != "record_store" for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1) if reach.search(line)]
|
||||
self.assertEqual(found, [], "read and write a record through record_store.stores.store")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -201,6 +201,27 @@ class ChunkItem(unittest.TestCase):
|
||||
run("commit", "-q", "--allow-empty", "-m", "Side work")
|
||||
self.assertEqual(release_standing.default_plan(repo, "main", "todo.md", changelog_of(repo)).cut.commits, 2, "the commits after Cut 0.0.1 on main")
|
||||
|
||||
def test_reads_the_changelog_and_its_cut_on_the_named_branch_whatever_is_checked_out(self):
|
||||
repo = tempfile.mkdtemp()
|
||||
self.addCleanup(subprocess.run, ["rm", "-rf", repo])
|
||||
run = lambda *args: subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], capture_output=True, check=True, cwd=repo, env=isolated_env(), text=True)
|
||||
changelog = pathlib.Path(repo, "CHANGELOG.md")
|
||||
run("init", "-q", "-b", "main")
|
||||
changelog.write_text("# Changelog\n\n## Unreleased\n")
|
||||
run("add", ".")
|
||||
run("commit", "-q", "-m", "Start")
|
||||
run("checkout", "-q", "-b", "side")
|
||||
changelog.write_text("# Changelog\n\n## 0.0.1 - 2026-10-02\n\n- Side.\n")
|
||||
run("commit", "-q", "-am", "Cut 0.0.1 on the side")
|
||||
run("checkout", "-q", "main")
|
||||
changelog.write_text("# Changelog\n\n## 0.0.1 - 2026-10-03\n")
|
||||
run("commit", "-q", "-am", "Cut 0.0.1")
|
||||
run("commit", "-q", "--allow-empty", "-m", "Ship item 2")
|
||||
run("checkout", "-q", "side")
|
||||
changelog.write_text("# Changelog\n\nAn edit nobody committed.\n")
|
||||
cut = release_standing.default_plan(repo, "main", "todo.md", changelog_of(repo)).cut
|
||||
self.assertEqual((cut.changelog, cut.commits), ("# Changelog\n\n## 0.0.1 - 2026-10-03\n", 1), "main's changelog, and the commit after Cut 0.0.1 on main")
|
||||
|
||||
def test_takes_the_tag_over_a_dated_heading_and_counts_every_commit_without_either(self):
|
||||
repo = tempfile.mkdtemp()
|
||||
self.addCleanup(subprocess.run, ["rm", "-rf", repo])
|
||||
|
||||
@@ -144,6 +144,16 @@ class Launch(unittest.TestCase):
|
||||
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, True)[1]
|
||||
self.assertTrue(prompt.endswith(f"Principles: read {self.config.parent}/AGENTS.md first, for the project principles and the decision titles."), prompt)
|
||||
|
||||
def test_names_the_decision_log_in_the_clone_or_where_it_stands_outside_the_checkout_without_agents_md(self):
|
||||
places = {"checkout:docs/decisions.md": self.clone / "docs" / "decisions.md", "folder:decisions.md": self.config.parent / "decisions.md"}
|
||||
for setting, decisions in places.items():
|
||||
with self.subTest(setting):
|
||||
self.config.write_text(self.config.read_text().replace('"checkout:docs/decisions.md"', f'"{setting}"'))
|
||||
decisions.parent.mkdir(exist_ok=True)
|
||||
decisions.write_text("1. A principle.\n\n# Decisions\n")
|
||||
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, True)[1]
|
||||
self.assertTrue(prompt.endswith(f"Principles: read {decisions} first, up to `# Decisions`, for the project principles and the decision titles."), prompt)
|
||||
|
||||
def test_fails_without_a_config_for_the_checkout(self):
|
||||
self.config.unlink()
|
||||
self.assertIn("no config names the checkout", replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, True).reason)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import contextlib
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
@@ -9,6 +10,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from score_outcomes.anchors import anchor_lines, parse_anchors
|
||||
from branch_chunks.cut import BranchChunk, Landing
|
||||
from project_config.test_project_config import configured, write_config
|
||||
from failure import Failure
|
||||
from score_outcomes.results import file_lines, NamedCode, nearest, rank_correlation, render, report, Result, results_of
|
||||
from review_rules.round_titles import Findings
|
||||
@@ -16,9 +18,8 @@ from test_env import isolated_env
|
||||
from release_plan.todo_table import Item
|
||||
from transcript_archive import outcomes
|
||||
from transcript_archive.location import project_archive
|
||||
from score_outcomes.main import report_text
|
||||
from score_outcomes.main import read_anchors, report_text
|
||||
from score_outcomes.reversals import reversal_lines
|
||||
from project_config.test_project_config import write_config
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes"
|
||||
HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
|
||||
@@ -549,5 +550,16 @@ class Reversals(unittest.TestCase):
|
||||
self.assertTrue(found.reason.startswith(f"could not read the archive file {archive / 'kept' / 'b.outcomes.md'}: "), found.reason)
|
||||
|
||||
|
||||
class ReadAnchors(unittest.TestCase):
|
||||
def test_fails_on_anchors_it_cannot_read_rather_than_scoring_without_them(self):
|
||||
checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||
configured(self, checkout)
|
||||
self.enterContext(contextlib.chdir(checkout))
|
||||
anchors = checkout.resolve() / "docs" / "score-anchors.md"
|
||||
anchors.parent.mkdir()
|
||||
anchors.write_bytes(b"\xff")
|
||||
self.assertEqual(read_anchors(), Failure(f"cannot read {anchors}: not UTF-8 on line 1"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -55,7 +55,7 @@ class Main(unittest.TestCase):
|
||||
self.assertEqual(self.run_main("--check"), (0, ""))
|
||||
self.assertEqual(pathlib.Path(temp, "todo.md").read_text(), "the project owners' own notes\n")
|
||||
(folder / "decisions.md").write_bytes(b"\xff")
|
||||
self.assertEqual(self.run_main(), (1, f"cannot read {folder}/decisions.md: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte\n"))
|
||||
self.assertEqual(self.run_main(), (1, f"cannot read {folder}/decisions.md: not UTF-8 on line 1\n"))
|
||||
|
||||
def test_refuses_a_file_that_is_not_the_plan_the_config_names_and_a_checkout_no_config_names(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
|
||||
@@ -18,7 +18,7 @@ It prints `Filed item <ID> in <todo.md's path>.` It doesn't write anything where
|
||||
finish removes the item's row and its detail. With --changelog it adds the bullet first under
|
||||
CHANGELOG.md's ## Unreleased, or a ## heading that says unreleased, creating the section, or the
|
||||
file, where missing. It refuses where that section holds ### subsections: add the bullet by hand.
|
||||
Where CHANGELOG.md exists, finish needs --changelog or --no-changelog, so no bullet is left out by
|
||||
Where CHANGELOG.md holds text, finish needs --changelog or --no-changelog, so no bullet is left out by
|
||||
mistake. It prints `Finished item <ID> in <todo.md's path>.` It doesn't write anything while docs/decisions.md cites the item.
|
||||
|
||||
show reads only todo.md. It prints `From <todo.md's path>:`, then the items table's header and divider, item <ID>'s row, and its detail
|
||||
|
||||
@@ -188,6 +188,10 @@ class Finish(TodoItem):
|
||||
self.assertEqual(self.run_main("finish", "2", "--changelog", "Tests are tight.")[0], 0)
|
||||
self.assertEqual(self.changelog.read_text(), "# Changelog\n\n## Unreleased\n\n- Tests are tight.\n")
|
||||
|
||||
def test_needs_no_changelog_choice_where_the_project_has_no_changelog(self):
|
||||
self.assertEqual(self.run_main("finish", "2"), (0, f"Finished item 2 in {self.todo}.\n", ""))
|
||||
self.assertFalse(self.changelog.exists())
|
||||
|
||||
def test_needs_a_changelog_choice_where_a_changelog_exists(self):
|
||||
self.changelog.write_text(CHANGELOG)
|
||||
before = self.todo.read_text()
|
||||
|
||||
Reference in New Issue
Block a user