From a45e77df1b0024707914a446aa89d33baa223787 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sun, 27 Sep 2026 22:21:26 +0200 Subject: test: make both suites pass on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of these failed on Windows for reasons that had nothing to do with the code under test, which is how real Windows defects hid among them: - Read and write files as UTF-8, and talk to Node in UTF-8. read_text(), write_text() and subprocess text=True use the locale codepage, cp1252 on Windows: "é", "—" and "→" arrived as "?" or crashed, some sixty tests. Calls to PowerShell and schtasks are left alone -- they answer in the console codepage. - Import ESM harness modules by file URL (as_uri): a raw "C:\..." path is not a module specifier. - test_cli_golden: mask the tmp path in its JSON-escaped form, spell it the POSIX way, record on Linux, mask the protocol version (the recording had failed everywhere since the MNP 4.0 bump) and argparse's version-dependent quoting; point USERPROFILE at the tmp home, or `member invite` and `operator pair` wrote their codes into the developer's profile. - test_disk_io_off_loop: expect what a free loop can reach on the platform's timer, 15.6 ms on Windows, not an assumed 5 ms. - test_root_paths_are_operator_only: expect the OS's spelling of the path. - test_audio_meta_cache: find ffprobe with shutil.which. Node suite on Windows: 1489 passed, none failed. Hub suite: 3 failures left, all older than this change (two SQLite concurrency tests, one transfer resume). Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-node/tests/test_disk_io_off_loop.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'packages/meshbay-node/tests/test_disk_io_off_loop.py') diff --git a/packages/meshbay-node/tests/test_disk_io_off_loop.py b/packages/meshbay-node/tests/test_disk_io_off_loop.py index a94789a..44864ba 100644 --- a/packages/meshbay-node/tests/test_disk_io_off_loop.py +++ b/packages/meshbay-node/tests/test_disk_io_off_loop.py @@ -47,6 +47,11 @@ GROUP = "g" * 32 # gets ~40 wake-ups inside one of these and a blocked one gets none. SLOW_S = 0.2 TICK_S = 0.005 +# What a free loop actually achieves: Windows' asyncio timers run on the 15.6 ms +# system tick, so a 5 ms sleep takes 15.6 and a free loop gets ~13 wake-ups, +# never 40 -- every test here failed there against a threshold of 20. Still +# unmistakable: a blocked loop gets none. +FREE_TICKS = SLOW_S / max(TICK_S, time.get_clock_info("monotonic").resolution) CONTENT = b"a file worth waking a disk for" * 400 @@ -139,7 +144,7 @@ async def test_a_slow_chunk_read_does_not_stop_the_loop(tmp_path, monkeypatch): # The read really did take its time, and the loop really did keep running: # both halves matter, because a wrapper that never ran would also leave the # ticker free. - assert ticker.ticks > SLOW_S / TICK_S / 2, ( + assert ticker.ticks > FREE_TICKS / 2, ( f"the loop was blocked: {ticker.ticks} wake-ups during a {SLOW_S}s read") chunk = next(m for m in session.sent if m.get("type") == MNP.FILE_CHUNK) @@ -161,7 +166,7 @@ async def test_a_slow_stat_does_not_stop_the_loop(tmp_path, monkeypatch): await session._do_file_request( {"type": MNP.FILE_REQUEST, "file_id": entry.id, "chunk_index": 0}) - assert ticker.ticks > SLOW_S / TICK_S / 2, ( + assert ticker.ticks > FREE_TICKS / 2, ( f"the loop was blocked: {ticker.ticks} wake-ups during a {SLOW_S}s stat") assert any(m.get("type") == MNP.FILE_CHUNK for m in session.sent) @@ -230,7 +235,7 @@ async def test_the_availability_poll_does_not_stop_the_loop(tmp_path, monkeypatc await idx.stop() roots.close_io() - assert ticker.ticks > SLOW_S / TICK_S / 2, ( + assert ticker.ticks > FREE_TICKS / 2, ( f"the loop was blocked: {ticker.ticks} wake-ups during a {SLOW_S}s poll") @@ -322,7 +327,7 @@ async def test_a_slow_upload_write_does_not_stop_the_loop(tmp_path, monkeypatch) await session._do_file_upload(sealed_upload( session, filename="clip.bin", data=CONTENT)) - assert ticker.ticks > SLOW_S / TICK_S / 2, ( + assert ticker.ticks > FREE_TICKS / 2, ( f"the loop was blocked: {ticker.ticks} wake-ups during a {SLOW_S}s write") assert (shared / "clip.bin").read_bytes() == CONTENT @@ -405,5 +410,5 @@ async def test_a_slow_scratch_read_does_not_stop_the_loop(tmp_path, monkeypatch) media_tools._read_scratch_capped, scratch, 1 << 20, "subtitle track") assert blob == CONTENT - assert ticker.ticks > SLOW_S / TICK_S / 2, ( + assert ticker.ticks > FREE_TICKS / 2, ( f"the loop was blocked: {ticker.ticks} wake-ups during a {SLOW_S}s read") -- cgit v1.2.3