From 983e7328cfe7a7f59c220d59aa25b9c50602e04c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 19 Nov 2026 05:25:51 +0100 Subject: [PATCH] Kill the mutants of stdin, undecodable lines and repeated record writes --- bin/loop_claude/test_loop_claude.py | 5 +++++ bin/loop_effects/test_effects.py | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 4e92dd62..31db647d 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -838,6 +838,11 @@ class LingeringWorkers(unittest.TestCase): self.assertEqual(streamed.stopped, held) self.assertIn("could not record the stop", failed.getvalue()) + def test_every_stop_of_a_check_is_recorded_though_the_archive_folder_exists_after_the_first(self): + held = [self.shell(), self.shell()] + _, said, record = self.worker_with(self.RESULT, None, held=held) + self.assertEqual(record.count("stopped shell 7"), 2) + class MemoryWait(unittest.TestCase): def test_a_worker_starts_only_once_a_quarter_of_memory_is_available(self): diff --git a/bin/loop_effects/test_effects.py b/bin/loop_effects/test_effects.py index 9351e7f2..60d514f7 100644 --- a/bin/loop_effects/test_effects.py +++ b/bin/loop_effects/test_effects.py @@ -243,12 +243,22 @@ class StreamingClaudeLines(unittest.TestCase): return streaming, folder.name def test_yields_each_line_with_its_newline_and_the_last_one_without_and_replaces_bytes_that_are_not_utf8(self): - streaming, _ = self.claude("printf 'one\\ntwo\\n\\377-tail'") - self.assertEqual(list(streaming.lines(5)), ["one\n", "two\n", "\ufffd-tail"]) + streaming, _ = self.claude("printf 'one\\n\\377two\\n\\377-tail'") + self.assertEqual(list(streaming.lines(5)), ["one\n", "\ufffdtwo\n", "\ufffd-tail"]) self.assertEqual(streaming.wait(), 0) def test_runs_claude_in_the_folder_with_the_arguments_and_the_environment_and_without_input(self): - streaming, folder = self.claude('echo "$PWD $MARK $*"; if read -r line; then echo data; else echo eof; fi', ["-p", "hi"]) + # Fills the test's own standard input, so that a claude that inherited it would read data. + read, write = os.pipe() + os.write(write, b"data\n") + saved = os.dup(0) + os.dup2(read, 0) + try: + streaming, folder = self.claude('echo "$PWD $MARK $*"; if read -r line; then echo data; else echo eof; fi', ["-p", "hi"]) + finally: + os.dup2(saved, 0) + for each in (read, write, saved): + os.close(each) self.assertEqual(list(streaming.lines(5)), [f"{os.path.realpath(folder)} marked -p hi\n", "eof\n"]) def test_yields_none_whenever_the_idle_time_passes_without_a_line(self):