Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execFile } from "node:child_process";
import { exec as execCb, execFile } from "node:child_process";
import { mkdir, readFile, statfs, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
Expand Down Expand Up @@ -322,14 +322,14 @@ export async function retry(opts: RunOptions): Promise<void> {
* Returns a warning string if the tests fail, or null if they pass.
*/
export async function preflightTestRun(testCmd: string, repoRoot: string): Promise<string | null> {
const { cmd, args } = parseTestCommand(testCmd);
const { cmd } = parseTestCommand(testCmd);
if (!cmd) return null;

const execAsync = promisify(execCb);
try {
await execFileAsync(cmd, args, {
await execAsync(testCmd, {
cwd: repoRoot,
timeout: 60_000,
shell: true,
env: { ...process.env, CI: "true" },
});
return null;
Expand Down
23 changes: 7 additions & 16 deletions src/scoring/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execFile } from "node:child_process";
import { exec as execCb } from "node:child_process";
import { access } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
import type { TestResult } from "../types.js";

const exec = promisify(execFile);
const exec = promisify(execCb);

const DEFAULT_TEST_TIMEOUT_MS = 120_000;

Expand Down Expand Up @@ -65,7 +65,7 @@ export async function runTests(
};
}

const { cmd, args } = parseTestCommand(testCmd);
const { cmd } = parseTestCommand(testCmd);

if (!cmd) {
return {
Expand All @@ -88,12 +88,12 @@ export async function runTests(
}

try {
// Use execFile with shell:true for cross-platform command resolution
// while keeping args as an array to prevent injection via arguments.
const { stdout, stderr } = await exec(cmd, args, {
// Use exec (shell string) for cross-platform command resolution (npx, npm, etc.).
// Safety: testCmd is validated by validateTestCommand() which rejects shell operators.
// This avoids the DEP0190 deprecation from execFile + shell:true + args array.
const { stdout, stderr } = await exec(testCmd, {
cwd: worktreePath,
timeout: timeoutMs,
shell: true,
env: { ...process.env, CI: "true" },
});
return {
Expand All @@ -120,15 +120,6 @@ export async function runTests(
};
}

if (typeof e.code === "string" && e.code === "ENOENT") {
return {
agentId,
passed: false,
output: `Command not found: ${cmd}. Is it installed?`,
exitCode: 127,
};
}

return {
agentId,
passed: false,
Expand Down
Loading