Skip to content

Commit b81f4d1

Browse files
that-github-userunknownclaude
authored
Fix test runner to use shell execution for cross-platform compatibility (#19)
Switch from execFile to exec (shell mode) so npx, npm, and other platform-specific commands resolve correctly on both Windows and Unix. Remove ENOENT-specific handling (shell handles this internally). Co-authored-by: unknown <that-github-user@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c267219 commit b81f4d1

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

src/scoring/test-runner.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ describe("runTests", () => {
3636
});
3737

3838
it("returns failure for non-existent command", async () => {
39-
const result = await runTests(1, "nonexistent-command-xyz", "/tmp");
39+
const result = await runTests(1, "nonexistent-command-xyz", ".");
4040
assert.equal(result.passed, false);
41-
assert.equal(result.exitCode, 127);
42-
assert.ok(result.output.includes("Command not found"));
41+
assert.ok(result.exitCode !== 0);
4342
});
4443

4544
it("returns success for passing command", async () => {

src/scoring/test-runner.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { execFile } from "node:child_process";
1+
import { exec as execCb } from "node:child_process";
22
import { access } from "node:fs/promises";
33
import { join } from "node:path";
44
import { promisify } from "node:util";
55
import type { TestResult } from "../types.js";
66

7-
const exec = promisify(execFile);
7+
const exec = promisify(execCb);
88

99
const TEST_TIMEOUT_MS = 120_000;
1010

@@ -62,7 +62,8 @@ export async function runTests(
6262
}
6363

6464
try {
65-
const { stdout, stderr } = await exec(cmd, args, {
65+
// Use shell execution so npx, npm, etc. resolve correctly on all platforms
66+
const { stdout, stderr } = await exec(testCmd, {
6667
cwd: worktreePath,
6768
timeout: TEST_TIMEOUT_MS,
6869
env: { ...process.env, CI: "true" },
@@ -92,16 +93,6 @@ export async function runTests(
9293
};
9394
}
9495

95-
// Command not found
96-
if (typeof e.code === "string" && e.code === "ENOENT") {
97-
return {
98-
agentId,
99-
passed: false,
100-
output: `Command not found: ${cmd}. Is it installed?`,
101-
exitCode: 127,
102-
};
103-
}
104-
10596
return {
10697
agentId,
10798
passed: false,

0 commit comments

Comments
 (0)