claude-dev-env 8.44.2 → 8.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import io
|
|
2
2
|
import json
|
|
3
|
-
import
|
|
3
|
+
from collections.abc import Callable
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
import pytest
|
|
@@ -160,6 +160,24 @@ def test_should_allow_every_parallel_call_under_one_note(
|
|
|
160
160
|
assert (first_exit_code, second_exit_code) == (0, 0)
|
|
161
161
|
|
|
162
162
|
|
|
163
|
+
class HarnessWritesDuringFirstSleep:
|
|
164
|
+
"""Stand-in for the time module that runs the harness write on the first poll sleep."""
|
|
165
|
+
|
|
166
|
+
def __init__(self, write_late_lines: Callable[[], None]) -> None:
|
|
167
|
+
self.write_late_lines = write_late_lines
|
|
168
|
+
self.elapsed_seconds = 0.0
|
|
169
|
+
self.sleep_count = 0
|
|
170
|
+
|
|
171
|
+
def monotonic(self) -> float:
|
|
172
|
+
return self.elapsed_seconds
|
|
173
|
+
|
|
174
|
+
def sleep(self, seconds: float) -> None:
|
|
175
|
+
if self.sleep_count == 0:
|
|
176
|
+
self.write_late_lines()
|
|
177
|
+
self.sleep_count += 1
|
|
178
|
+
self.elapsed_seconds += seconds
|
|
179
|
+
|
|
180
|
+
|
|
163
181
|
def test_should_see_a_note_the_harness_writes_after_the_hook_starts(
|
|
164
182
|
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
|
|
165
183
|
) -> None:
|
|
@@ -174,12 +192,11 @@ def test_should_see_a_note_the_harness_writes_after_the_hook_starts(
|
|
|
174
192
|
with transcript.open("a", encoding="utf-8") as transcript_file:
|
|
175
193
|
transcript_file.write(late_lines)
|
|
176
194
|
|
|
177
|
-
|
|
178
|
-
|
|
195
|
+
harness_clock = HarnessWritesDuringFirstSleep(append_late_lines)
|
|
196
|
+
monkeypatch.setattr(step_note_gate, "time", harness_clock)
|
|
179
197
|
exit_code, _ = run_gate(monkeypatch, capsys, transcript, "call_1")
|
|
180
|
-
writer.join()
|
|
181
198
|
|
|
182
|
-
assert exit_code == 0
|
|
199
|
+
assert (exit_code, harness_clock.sleep_count) == (0, 1)
|
|
183
200
|
|
|
184
201
|
|
|
185
202
|
def test_should_block_a_bare_call_the_harness_writes_after_the_hook_starts(
|
|
@@ -192,12 +209,11 @@ def test_should_block_a_bare_call_the_harness_writes_after_the_hook_starts(
|
|
|
192
209
|
with transcript.open("a", encoding="utf-8") as transcript_file:
|
|
193
210
|
transcript_file.write(json.dumps(call_entry("m1", "call_1")) + "\n")
|
|
194
211
|
|
|
195
|
-
|
|
196
|
-
|
|
212
|
+
harness_clock = HarnessWritesDuringFirstSleep(append_late_call)
|
|
213
|
+
monkeypatch.setattr(step_note_gate, "time", harness_clock)
|
|
197
214
|
exit_code, _ = run_gate(monkeypatch, capsys, transcript, "call_1")
|
|
198
|
-
writer.join()
|
|
199
215
|
|
|
200
|
-
assert exit_code == 2
|
|
216
|
+
assert (exit_code, harness_clock.sleep_count) == (2, 1)
|
|
201
217
|
|
|
202
218
|
|
|
203
219
|
def test_should_allow_a_call_that_never_reaches_the_transcript(
|