test: adapt read mocks and fifo guard test to the sentinel probe

The combined [ -f ]/wc -c probe changes the first shell command each
read issues; update the stale mocks that only answered bare 'wc -c'.
The fifo tool-layer test now accepts the merged stat-guard's
success=False note (a fact, not an error) with the shell sentinel
behind it.
This commit is contained in:
teknium1 2026-08-10 00:03:42 -07:00 committed by Teknium
parent e0b5005985
commit ea68bdda92
2 changed files with 11 additions and 7 deletions

View File

@ -355,7 +355,7 @@ class TestShellFileOpsHelpers:
)
def side_effect(command, **kwargs):
if command.startswith("wc -c"):
if command.startswith("if [ -f ") or command.startswith("wc -c"):
return {"output": "12\n", "returncode": 0}
if command.startswith("head -c"):
return {"output": "print('ok')\n", "returncode": 0}
@ -383,7 +383,7 @@ class TestShellFileOpsHelpers:
)
def side_effect(command, **kwargs):
if command.startswith("wc -c"):
if command.startswith("if [ -f ") or command.startswith("wc -c"):
return {"output": "6\n", "returncode": 0}
if command.startswith("head -c"):
return {"output": "alpha\n", "returncode": 0}
@ -519,7 +519,7 @@ class TestPatchReplacePostWriteVerification:
if command.startswith("mkdir "):
return {"output": "", "returncode": 0}
# wc -c for byte count after write
if command.startswith("wc -c"):
if command.startswith("if [ -f ") or command.startswith("wc -c"):
for path in file_contents:
if path in command:
return {"output": str(len(file_contents[path].encode())), "returncode": 0}
@ -556,7 +556,7 @@ class TestPatchReplacePostWriteVerification:
return {"output": "", "returncode": 1}
if command.startswith("mkdir "):
return {"output": "", "returncode": 0}
if command.startswith("wc -c"):
if command.startswith("if [ -f ") or command.startswith("wc -c"):
return {"output": str(len(state["content"].encode())), "returncode": 0}
return {"output": "", "returncode": 0}
@ -776,7 +776,7 @@ class TestByteLayerBinaryDetection:
import base64 as b64
def side_effect(command, **kwargs):
if command.startswith("wc -c"):
if command.startswith("if [ -f ") or command.startswith("wc -c"):
return {"output": f"{len(cjk_bytes)}\n", "returncode": 0}
if command.startswith("head -c") and "| base64" in command:
return {"output": b64.b64encode(cjk_bytes[:1000]).decode(), "returncode": 0}

View File

@ -265,8 +265,12 @@ class TestNonRegularFileReads(unittest.TestCase):
result = self._read_within_deadline(fifo_path, "fifo_read_test")
self.assertIn("error", result)
self.assertIn("not a regular file", result["error"])
# The tool layer intercepts first with a success=False NOTE (a fact
# about the file, not an error — merged stat-guard design); the
# shell-layer sentinel behind it errors. Accept either surface.
surface = result.get("error") or result.get("note") or ""
self.assertTrue(surface, f"expected error or note, got: {result}")
self.assertIn("not a regular file", surface)
def test_read_file_tool_on_directory_errors_instead_of_blocking(self):
with tempfile.TemporaryDirectory() as tmpdir: