Skip to content

The agent that grows with you

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

ethernet744ffcfe363c
diff --git a/tests/hermes_cli/test_source_launcher_publication.py b/tests/hermes_cli/test_source_launcher_publication.py
index a28c1263f07..ade25b261cc 100644
--- a/tests/hermes_cli/test_source_launcher_publication.py
+++ b/tests/hermes_cli/test_source_launcher_publication.py
@@ -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()
diff --git a/tests/scripts/test_source_build_env.py b/tests/scripts/test_source_build_env.py
index 4ffd5cbcbdb..4884d5623fd 100644
--- a/tests/scripts/test_source_build_env.py
+++ b/tests/scripts/test_source_build_env.py
@@ -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")