Files
reliquary/plugins/spire/skills/gremlins/tests/_pin.py
T
g4borg f6dc43be19 ✨ export: 36 files (features)
M plugins/gitea/.claude-plugin/plugin.json
M plugins/gitea/.codex-plugin/plugin.json
M plugins/gitea/README.md
M plugins/gitea/skills/gitea/SKILL.md
M plugins/gitea/skills/gitea/scripts/fetch_ticket.py
M plugins/gitea/skills/gitea/scripts/start_ticket.py
A plugins/spire/UPGRADES.md
A plugins/spire/agents/designer.md
M plugins/spire/agents/planner.md
A plugins/spire/providers/README.md
A plugins/spire/providers/hosts/claude-desktop/spawning.md
A plugins/spire/providers/hosts/t3-code/spawning.md
A plugins/spire/providers/runtimes/codex/spawning.md
M plugins/spire/skills/gremlins/grm/call.py
M plugins/spire/skills/gremlins/grm/cli.py
A plugins/spire/skills/gremlins/grm/codex.py
A plugins/spire/skills/gremlins/grm/errors.py
A plugins/spire/skills/gremlins/grm/harness.py
M plugins/spire/skills/gremlins/grm/launch.py
A plugins/spire/skills/gremlins/grm/scrub.py
M plugins/spire/skills/gremlins/grm/stream.py
A plugins/spire/skills/gremlins/grm/title.py
A plugins/spire/skills/gremlins/tests/_pin.py
M plugins/spire/skills/gremlins/tests/fake_claude.py
A plugins/spire/skills/gremlins/tests/fake_codex.py
M plugins/spire/skills/gremlins/tests/test_cli.py
A plugins/spire/skills/gremlins/tests/test_cli_codex.py
A plugins/spire/skills/gremlins/tests/test_codex.py
A plugins/spire/skills/gremlins/tests/test_harness.py
A plugins/spire/skills/gremlins/tests/test_scrub.py
A plugins/spire/skills/gremlins/tests/test_title.py
A plugins/spire/skills/igor/references/upgrades.md
A plugins/spire/skills/igor/tests/test_upgrade_notes.py
A plugins/spire/skills/igor/upgrade-notes.sh
R plugins/spire/skills/implementation/references/spawning-claude-code.md -> plugins/spire/providers/runtimes/claude-code/spawning.md
M plugins/spire/skills/project/SKILL.md
2026-11-25 01:52:10 +01:00

31 lines
1.3 KiB
Python

"""Pin the caller's harness markers and `CODEX_HOME` for a test, so no test depends on the host's
env (this suite usually runs inside a Claude Code Bash, with a real `~/.codex`)."""
import os
import shutil
import tempfile
from unittest import mock
MARKERS = {"claude": {"CLAUDECODE": "1"}, "codex": {"CODEX_THREAD_ID": "pinned-thread"},
"both": {"CLAUDECODE": "1", "CODEX_THREAD_ID": "pinned-thread"}, None: {}}
def pinned(environ, harness, codex_home) -> dict:
"""A copy of `environ` with only `harness`'s markers (None: no marker; "both": both) and
`CODEX_HOME` = `codex_home`."""
env = {k: v for k, v in environ.items() if k not in ("CLAUDECODE", "CODEX_THREAD_ID")}
env.update(MARKERS[harness])
env["CODEX_HOME"] = str(codex_home)
return env
def pin_caller(test, harness, codex_home=None) -> str:
"""Patch os.environ for `test` (undone at cleanup); returns the pinned `CODEX_HOME`, a fresh
temp dir unless given."""
if codex_home is None:
codex_home = tempfile.mkdtemp(prefix="codex-home-")
test.addCleanup(shutil.rmtree, codex_home, True)
patch = mock.patch.dict(os.environ, pinned(os.environ, harness, codex_home), clear=True)
patch.start()
test.addCleanup(patch.stop)
return str(codex_home)