mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
test harness: runSkillTest accepts per-test env vars
Adds an optional env: param that Bun.spawn merges into the spawned
claude -p process environment. Backwards-compatible: omitting the
param keeps the prior behavior (inherit parent env only).
Motivation: E2E tests were stuffing environment setup into the prompt
itself ("Use GSTACK_HOME=X and the bin scripts at ./bin/"), which made
the agent interpret the prompt as bash-run instructions and bypass the
Skill tool. Slash-command routing tests failed because the routing
assertion (skillCalls includes "context-save") never fired.
With env: support, a test can pass GSTACK_HOME via process env and
leave the prompt as a minimal slash-command invocation. The agent sees
"/context-save wintermute" and the skill handles env lookup in its own
preamble. Routing assertion can now actually observe the Skill tool
being called.
Two lines of code. No behavioral change for existing tests that don't
pass env:.
This commit is contained in:
@@ -126,6 +126,10 @@ export async function runSkillTest(options: {
|
|||||||
runId?: string;
|
runId?: string;
|
||||||
/** Model to use. Defaults to claude-sonnet-4-6 (overridable via EVALS_MODEL env). */
|
/** Model to use. Defaults to claude-sonnet-4-6 (overridable via EVALS_MODEL env). */
|
||||||
model?: string;
|
model?: string;
|
||||||
|
/** Extra env vars merged into the spawned claude -p process. Useful for
|
||||||
|
* per-test GSTACK_HOME overrides so the test doesn't have to spell out
|
||||||
|
* env setup in the prompt itself. */
|
||||||
|
env?: Record<string, string>;
|
||||||
}): Promise<SkillTestResult> {
|
}): Promise<SkillTestResult> {
|
||||||
const {
|
const {
|
||||||
prompt,
|
prompt,
|
||||||
@@ -135,6 +139,7 @@ export async function runSkillTest(options: {
|
|||||||
timeout = 120_000,
|
timeout = 120_000,
|
||||||
testName,
|
testName,
|
||||||
runId,
|
runId,
|
||||||
|
env: extraEnv,
|
||||||
} = options;
|
} = options;
|
||||||
const model = options.model ?? process.env.EVALS_MODEL ?? 'claude-sonnet-4-6';
|
const model = options.model ?? process.env.EVALS_MODEL ?? 'claude-sonnet-4-6';
|
||||||
|
|
||||||
@@ -171,6 +176,7 @@ export async function runSkillTest(options: {
|
|||||||
|
|
||||||
const proc = Bun.spawn(['sh', '-c', `cat "${promptFile}" | claude ${args.map(a => `"${a}"`).join(' ')}`], {
|
const proc = Bun.spawn(['sh', '-c', `cat "${promptFile}" | claude ${args.map(a => `"${a}"`).join(' ')}`], {
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
|
env: extraEnv ? { ...process.env, ...extraEnv } : undefined,
|
||||||
stdout: 'pipe',
|
stdout: 'pipe',
|
||||||
stderr: 'pipe',
|
stderr: 'pipe',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user