From 3bb4e87775c6875eb35a7e57c9581cfa06f2a53d Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 4 Oct 2026 15:40:21 -0700 Subject: [PATCH] test(update): runtime unicode docstring matches the ProcessStartInfo UTF-8 capture Review R8 m7: after the merge with main's 732b63d61a8 the probe decodes launcher stdout as UTF-8 through ProcessStartInfo.StandardOutputEncoding and never touches [Console]::OutputEncoding, so the test docstrings no longer claim the call sites scope and restore it. runtime.ps1 keeps a one-line #124526 pointer at the encoding line. Behaviour and assertions are unchanged. --- scripts/desktop-update/runtime.ps1 | 1 + .../test_desktop_update_runtime_unicode.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/desktop-update/runtime.ps1 b/scripts/desktop-update/runtime.ps1 index ad7756eed4..8b6c826006 100644 --- a/scripts/desktop-update/runtime.ps1 +++ b/scripts/desktop-update/runtime.ps1 @@ -24,6 +24,7 @@ function Invoke-HermesProbe { $psi.RedirectStandardInput = $true $psi.RedirectStandardOutput = $true $psi.RedirectStandardError = $true + # Launchers print UTF-8; PowerShell 5.1 would decode with the OEM code page (#124526). $psi.StandardOutputEncoding = [System.Text.Encoding]::UTF8 $process = [System.Diagnostics.Process]::Start($psi) try { $process.StandardInput.Close() } catch {} diff --git a/tests/scripts/desktop_update/test_desktop_update_runtime_unicode.py b/tests/scripts/desktop_update/test_desktop_update_runtime_unicode.py index 797a6bc00b..541bd0972b 100644 --- a/tests/scripts/desktop_update/test_desktop_update_runtime_unicode.py +++ b/tests/scripts/desktop_update/test_desktop_update_runtime_unicode.py @@ -10,10 +10,12 @@ decodes captured native stdout with the console OEM code page, mojibaking the path (``á`` → ``├í``, ``ł`` → ``┼é``) so the returned command cannot run and the legacy identity check never matches. -Both call sites now scope ``[Console]::OutputEncoding`` to UTF-8 around the -capture and restore it. These tests drive the REAL script against a REAL -published launcher under non-ASCII paths, across three console code pages, and -assert the caller's encoding is restored. They never read the script's text. +Both captures go through ``Invoke-HermesProbe``, which decodes the child's +stdout as UTF-8 via ``ProcessStartInfo.StandardOutputEncoding`` and never +touches ``[Console]::OutputEncoding``. These tests drive the REAL script against +a REAL published launcher under non-ASCII paths, across three console code +pages, and assert the caller's console encoding is left unchanged. They never +read the script's text. """ from __future__ import annotations @@ -79,8 +81,8 @@ def test_runtime_command_survives_a_non_ascii_profile_path(tmp_path: Path, code_ The launcher JSON is ASCII-escaped today, so this is the round-trip contract for the boundary every other consumer (hermes_cli.windows_ssh_ runtime, the Electron updater, the Rust bootstrap) already decodes as - UTF-8: the scoped capture must return the path byte-exact and restore - the caller's console encoding, whatever code page the console carries. + UTF-8: the capture must return the path byte-exact and leave the caller's + console encoding unchanged, whatever code page the console carries. """ profile = tmp_path / PROFILE install = profile / 'hermes-agent' @@ -104,7 +106,7 @@ def test_runtime_command_survives_a_non_ascii_profile_path(tmp_path: Path, code_ lines = _run_helper(script, home, {'HERMES_RUNTIME_DIR': str(store)}, tmp_path / 'answer.txt') assert lines[0] == str(python), ( f"interpreter path was mojibaked under code page {code_page}: {lines[0]!r}") - assert int(lines[1]) == code_page, 'the capture must restore the caller console encoding' + assert int(lines[1]) == code_page, 'the capture must leave the caller console encoding unchanged' @pytest.mark.platforms('windows')