Answer stability round 1: 0 🔴, 4 🟡; test that rule-hook runs git guarded and that reading-cost lists the checkout from a subfolder
This commit is contained in:
@@ -15,7 +15,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
|||||||
from transcript_archive.write import archive
|
from transcript_archive.write import archive
|
||||||
from reading_cost.measure import Checkout, Reading
|
from reading_cost.measure import Checkout, Reading
|
||||||
from failure import Failure
|
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 transcript_archive.read import finished_chunks, FinishedChunk
|
||||||
from test_env import isolated_env
|
from test_env import isolated_env
|
||||||
from transcript_archive import outcomes
|
from transcript_archive import outcomes
|
||||||
@@ -160,5 +160,20 @@ class ReadingCostTool(unittest.TestCase):
|
|||||||
self.assertIn("not a git repository", ran.stderr)
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from test_env import isolated_env
|
|||||||
from model_routing import ladder
|
from model_routing import ladder
|
||||||
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
|
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
|
||||||
from rule_hook.reviewer_rung import reviewer_breaches
|
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 model_routing.ladder import Rung
|
||||||
from shell_command import simple_commands
|
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, "commit", "-q", "--allow-empty", "-m", "base")
|
||||||
git(self.repo, "checkout", "-q", "-b", "chunk")
|
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:
|
def listed(self) -> str:
|
||||||
return subprocess.run([str(HOOK), "overrides"], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout
|
return subprocess.run([str(HOOK), "overrides"], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user