diff --git a/bin/reading_cost/test_reading_cost.py b/bin/reading_cost/test_reading_cost.py index fc48796e..ad128597 100644 --- a/bin/reading_cost/test_reading_cost.py +++ b/bin/reading_cost/test_reading_cost.py @@ -15,7 +15,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from transcript_archive.write import archive from reading_cost.measure import Checkout, Reading from failure import Failure -from reading_cost import figures, measure +from reading_cost import figures, main, measure from transcript_archive.read import finished_chunks, FinishedChunk from test_env import isolated_env from transcript_archive import outcomes @@ -160,5 +160,20 @@ class ReadingCostTool(unittest.TestCase): self.assertIn("not a git repository", ran.stderr) +class Located(unittest.TestCase): + def test_lists_the_whole_checkout_from_a_folder_inside_it(self): + temp = tempfile.TemporaryDirectory() + self.addCleanup(temp.cleanup) + root = pathlib.Path(temp.name).resolve() + (root / "sub").mkdir() + (root / "a.txt").write_text("a") + (root / "sub" / "b.txt").write_text("b") + for args in (("init", "--quiet"), ("add", ".")): + subprocess.run(["git", *args], check=True, cwd=root, env=isolated_env()) + with contextlib.chdir(root / "sub"): + found = main.located() + self.assertEqual(found, Checkout(str(root), str(root), frozenset({"a.txt", "sub/b.txt"}))) + + if __name__ == "__main__": unittest.main() diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 15443ead..6eca207f 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -18,6 +18,7 @@ from test_env import isolated_env from model_routing import ladder from rule_hook.override_log import LogLine, parsed_entry, this_chunks from rule_hook.reviewer_rung import reviewer_breaches +from rule_hook.git import git as rule_hook_git from model_routing.ladder import Rung from shell_command import simple_commands @@ -288,6 +289,10 @@ class Hook(unittest.TestCase): git(self.repo, "commit", "-q", "--allow-empty", "-m", "base") git(self.repo, "checkout", "-q", "-b", "chunk") + def test_runs_git_guarded(self): + git(self.repo, "config", "core.fsmonitor", "/bin/false") + self.assertEqual(rule_hook_git(self.repo, "config", "core.fsmonitor"), "false") + def listed(self) -> str: return subprocess.run([str(HOOK), "overrides"], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout