test: launchd survive-collection execs the osascript child; pwsh probe traps and narrates

- test_source_launcher_publication: launchd ProgramArguments are `/usr/bin/osascript -e` since #71206;
  on Linux exec the child argv the script would spawn (minus the shell redirection tail).
- test_source_build_env: pwsh 7.6.5 on the Windows lane exits 0 without running the child; the probe
  now traps any terminating error (exit 97 + stack) and narrates each step to stderr.
This commit is contained in:
ethernet
2026-09-21 08:52:49 -04:00
parent 9d036f8ac9
commit 744ffcfe36
2 changed files with 9 additions and 2 deletions

View File

@@ -276,8 +276,11 @@ def _command_survives_generation_collection(tmp_path, monkeypatch, surface):
monkeypatch.setattr(gateway, "PROJECT_ROOT", repo)
if surface == "launchd":
import plistlib
from tests.hermes_cli.test_gateway_service import _osascript_exec_argv
unit = gateway.generate_launchd_plist()
command = plistlib.loads(unit.encode())["ProgramArguments"]
# The job runs through osascript (#71206); exec the child it would spawn, minus the
# `>> log 2>> log` tail that only means something to the shell.
command = _osascript_exec_argv(plistlib.loads(unit.encode())["ProgramArguments"])[:-4]
args = ["gateway", "run", "--external-supervisor"]
else:
unit = gateway.generate_systemd_unit()

View File

@@ -89,10 +89,14 @@ console.log(JSON.stringify(process.env));
script = tmp_path / "probe.ps1"
script.write_text('''$ErrorActionPreference = 'Stop'
[Console]::Error.WriteLine("probe start: $($PSVersionTable.PSVersion) assets=$env:ASSETS python=$env:PROBE_PYTHON")
trap { [Console]::Error.WriteLine("probe trap: $_"); [Console]::Error.WriteLine($_.ScriptStackTrace); exit 97 }
. (Join-Path $env:ASSETS 'source-build-env.ps1')
Invoke-SourceBuild { & $env:PROBE_PYTHON -I -S $env:PROBE_SCRIPT; if ($LASTEXITCODE) { throw 'stamp failed' } }
[Console]::Error.WriteLine("probe: asset sourced")
Invoke-SourceBuild { & $env:PROBE_PYTHON -I -S $env:PROBE_SCRIPT; [Console]::Error.WriteLine("probe: child exit $LASTEXITCODE"); if ($LASTEXITCODE) { throw 'stamp failed' } }
[Console]::Error.WriteLine("probe: stamp step done")
try { Invoke-SourceBuild { throw 'child failure' }; throw 'lost exception' }
catch { if ($_.Exception.Message -ne 'child failure') { throw } }
[Console]::Error.WriteLine("probe: failure step done")
& $env:PROBE_PYTHON -I -S -c 'import json, os; print(json.dumps(dict(os.environ)))'
if ($LASTEXITCODE) { exit $LASTEXITCODE }
''', encoding="utf-8-sig")