Answer stability round 1: 0 🔴, 8 🟡 (0 misread); keep Ask.asked in seconds and stamp it only in its file, keep the dated-heading rule in one function and the preflight's wording in chunk_preflight, match the heading line itself, and test a device path, a tagged repo with a dated heading, an untagged one without, and the wording where nothing is cut
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import datetime
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import resource
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -659,12 +661,15 @@ class Hook(unittest.TestCase):
|
||||
self.assertIn("Blocked by rule image-pin: ", ran.stderr)
|
||||
self.assertIn("`# rule-override image-pin: <reason>`", ran.stderr)
|
||||
|
||||
def test_an_edit_of_a_fifo_finishes(self):
|
||||
def test_an_edit_of_a_fifo_or_a_device_finishes(self):
|
||||
fifo = f"{self.repo}/pipe"
|
||||
os.mkfifo(fifo)
|
||||
for tool, given in (("Write", {"content": "x\n"}), ("Edit", {"old_string": "a", "new_string": "b"}), ("MultiEdit", {"edits": [{"old_string": "a", "new_string": "b"}]})):
|
||||
with self.subTest(tool=tool):
|
||||
ran = hook({"cwd": self.repo, "tool_input": {"file_path": fifo, **given}, "tool_name": tool}, self.repo)
|
||||
# A cap on the hook's memory, so a read of /dev/zero fails fast instead of filling the machine.
|
||||
capped = lambda: resource.setrlimit(resource.RLIMIT_AS, (1 << 30, 1 << 30))
|
||||
for path, (tool, given) in itertools.product((fifo, "/dev/zero"), (("Write", {"content": "x\n"}), ("Edit", {"old_string": "a", "new_string": "b"}), ("MultiEdit", {"edits": [{"old_string": "a", "new_string": "b"}]}))):
|
||||
with self.subTest(path=path, tool=tool):
|
||||
call = {"cwd": self.repo, "tool_input": {"file_path": path, **given}, "tool_name": tool}
|
||||
ran = subprocess.run([str(HOOK)], capture_output=True, cwd=self.repo, env=isolated_env(), input=json.dumps(call), preexec_fn=capped, text=True, timeout=10)
|
||||
self.assertEqual(ran.returncode, 0)
|
||||
|
||||
def test_an_override_passes_and_is_listed_for_the_chunk(self):
|
||||
|
||||
Reference in New Issue
Block a user