From 185efb9bea434f106054e195ad25ceb62cfe0bb5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 20:11:26 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20test=20located=20on=20a=20p?= =?UTF-8?q?ath=20holding=20a=20newline,=20limit=20run=5Fscores'=20comment?= =?UTF-8?q?=20to=20bin/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/metric_bench/main.py | 2 +- bin/reading_cost/test_reading_cost.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/metric_bench/main.py b/bin/metric_bench/main.py index b5fef7c2..631ca7b6 100644 --- a/bin/metric_bench/main.py +++ b/bin/metric_bench/main.py @@ -111,7 +111,7 @@ def noted(notes: list[str]) -> str: def run_scores(run: Entry, top: str) -> tuple[RunScores | None, list[str]] | Failure: """The run's scores, and why each file left out was: git could not show it as UTF-8, or it does not parse.""" - # A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool reads git's output through git_repo.git's one contract. + # A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool in bin/ but the status line, item 204's, reads git's output through git_repo.git's one contract. listed = git("ls-tree", "-r", "-z", "--name-only", run.commit, cwd=top) if isinstance(listed, Failure): return listed diff --git a/bin/reading_cost/test_reading_cost.py b/bin/reading_cost/test_reading_cost.py index ad128597..e86154ed 100644 --- a/bin/reading_cost/test_reading_cost.py +++ b/bin/reading_cost/test_reading_cost.py @@ -174,6 +174,15 @@ class Located(unittest.TestCase): found = main.located() self.assertEqual(found, Checkout(str(root), str(root), frozenset({"a.txt", "sub/b.txt"}))) + def test_fails_in_a_checkout_whose_path_holds_a_newline(self): + temp = tempfile.TemporaryDirectory() + self.addCleanup(temp.cleanup) + root = pathlib.Path(temp.name, "a\nb") + root.mkdir() + subprocess.run(["git", "init", "--quiet"], check=True, cwd=root, env=isolated_env()) + with contextlib.chdir(root): + self.assertIsInstance(main.located(), Failure) + if __name__ == "__main__": unittest.main()