hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

commit 2b74f41d3a6ea63706609e43fc6cc4098b3c5867
parent f31c041d2a0b4aeb1904a4f5187b619280fa8e06
Author: triesap <tyson@radroots.org>
Date:   Tue, 22 Sep 2026 22:23:06 +0000

test(hyf): scope the wait-taxonomy control and drop unused drain helper

- Wrap the wait-error taxonomy control stub in the ownership scope so an
  assertion failure still reaps the owned child
- Remove the now-unused drain_fd_bounded helper that could silently truncate
  at its cap if wired up later

Diffstat:
Mtests/parent_lifecycle.mojo | 23-----------------------
Mtests/test_provider_helpers.mojo | 11++++++-----
2 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/tests/parent_lifecycle.mojo b/tests/parent_lifecycle.mojo @@ -442,29 +442,6 @@ def read_line_bounded( return reader.read_line(deadline_ms) -def drain_fd_bounded( - fd: Int, max_bytes: Int, deadline_ms: Int -) raises -> String: - """Read available bytes up to ``max_bytes`` under deadline.""" - var out = List[UInt8]() - var buf = InlineArray[Byte, 1024](fill=0) - var start = now_ms() - while len(out) < max_bytes: - if now_ms() - start >= deadline_ms: - break - var ev = poll_fd(fd, POLLIN, LIFECYCLE_POLL_SLICE_MS) - if ev == 0: - continue - var n = read_fd(fd, buf.unsafe_ptr(), 1024) - if n <= 0: - break - var room = max_bytes - len(out) - var take = min(Int(n), room) - for index in range(take): - out.append(UInt8(Int(buf[index]))) - return bytes_to_string(out) - - def read_all_bounded( fd: Int, max_bytes: Int, deadline_ms: Int ) raises -> String: diff --git a/tests/test_provider_helpers.mojo b/tests/test_provider_helpers.mojo @@ -1021,11 +1021,12 @@ def test_wait_error_taxonomy_distinguishes_causes() raises: assert_equal(classify_wait_errno(Int(ErrNo.ECHILD.value)), "gone") assert_equal(classify_wait_errno(9999), "wait_error") assert_equal(wait_nohang(0).state, "wait_error") - var stub = spawn_max_local_stub(0, "count_requests", 1) - var live_pid = stub.pid - assert_equal(wait_nohang(live_pid).state, "running") - stub.terminate() - assert_equal(wait_nohang(live_pid).state, "gone") + var live_pid = 0 + with spawn_max_local_stub(0, "count_requests", 1) as stub: + live_pid = stub.pid + assert_equal(wait_nohang(live_pid).state, "running") + stub.terminate() + assert_equal(wait_nohang(live_pid).state, "gone") assert_true(pid_not_waitable(live_pid))