Kill the mutants of stdin, undecodable lines and repeated record writes
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user