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-hub/tests/test_session_renewal.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'packages/meshbay-hub/tests/test_session_renewal.py') diff --git a/packages/meshbay-hub/tests/test_session_renewal.py b/packages/meshbay-hub/tests/test_session_renewal.py index 7b8c108..ecf9ac5 100644 --- a/packages/meshbay-hub/tests/test_session_renewal.py +++ b/packages/meshbay-hub/tests/test_session_renewal.py @@ -50,7 +50,7 @@ pytestmark = pytest.mark.skipif( def _run(scenario: str, app: Path = APP) -> dict: proc = subprocess.run( ["node", str(HARNESS), str(app), json.dumps({"scenario": scenario})], - capture_output=True, text=True, timeout=60) + capture_output=True, text=True, encoding="utf-8", timeout=60) assert proc.returncode == 0, f"{proc.stdout}\n{proc.stderr}" return json.loads(proc.stdout.strip().splitlines()[-1]) @@ -59,14 +59,14 @@ def _run(scenario: str, app: Path = APP) -> dict: def broken(tmp_path_factory): """The client as it shipped: the rotated refresh token dropped.""" out = tmp_path_factory.mktemp("session") / "broken.js" - src = APP.read_text() + src = APP.read_text(encoding="utf-8") replaced = src.replace( " refreshToken: data.refresh_token || _auth.refreshToken,", " refreshToken: _auth.refreshToken,") assert replaced != src, ( "could not reconstruct the defect — the line it hinged on has moved, " "and the A/B below would be comparing the fix against itself") - out.write_text(replaced) + out.write_text(replaced, encoding="utf-8") return out @@ -186,13 +186,13 @@ def test_the_session_is_much_longer_than_the_token(): def test_renewal_happens_before_expiry_not_after(): """A margin, so the first click after a long film does not pay for a 401.""" - src = APP.read_text() + src = APP.read_text(encoding="utf-8") import re margin = int(re.search(r"const TOKEN_RENEW_MARGIN_S = (\d+)", src).group(1)) assert margin >= 300, ( f"{margin} s of margin against a one-hour token is thin: a backgrounded " "tab has its timers throttled and may not check for minutes") - assert "visibilitychange" in APP_JS.read_text(), ( + assert "visibilitychange" in APP_JS.read_text(encoding="utf-8"), ( "nothing re-checks when the tab comes back, which is exactly when the " "token is most likely to have aged out unnoticed") @@ -213,7 +213,7 @@ def test_renewing_does_not_tear_down_the_webrtc_connection(): Signing in or out must still re-run it, so the dependency is whether there is a token, not which one. """ - src = GROUP_PAGE.read_text() + src = GROUP_PAGE.read_text(encoding="utf-8") i = src.index("means tearing down the WebRTC connection") deps = src[i:src.index(");", i)] assert "Boolean(token)" in deps, ( @@ -228,7 +228,7 @@ def test_the_connection_signs_its_offer_with_a_live_token(): It signs the offer relayed through the hub, where an expired one is a 401 and no connection at all. """ - src = GROUP_PAGE.read_text() + src = GROUP_PAGE.read_text(encoding="utf-8") connect = src[src.index("const connect = async () => {"):] connect = connect[:connect.index("\n };")] assert "await ensureFreshToken()" in connect, ( -- cgit v1.2.3