From 352a6b9c75e6a07be665e5255a1c52c6529e31db Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Sun, 13 Apr 2025 09:44:45 -0700 Subject: [PATCH] More unit test kill -9 fixes (#2570) * More unit test kill -9 fixes * Fix linter warning --- evals/apps/cli/src/index.ts | 29 ++++++++++++++++++++--------- evals/packages/db/src/schema.ts | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/evals/apps/cli/src/index.ts b/evals/apps/cli/src/index.ts index 2491b16ef6..d911082848 100644 --- a/evals/apps/cli/src/index.ts +++ b/evals/apps/cli/src/index.ts @@ -357,6 +357,7 @@ const runUnitTest = async ({ task }: { task: Task }) => { console.log( `${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] running "${command.join(" ")}"`, ) + const subprocess = execa({ cwd, shell: true, reject: false })`${command}` const timeout = setTimeout(async () => { @@ -370,15 +371,21 @@ const runUnitTest = async ({ task }: { task: Task }) => { }) }) - if (descendants.length > 0) { - try { - console.log( - `${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${descendants.join(" ")}`, - ) + console.log( + `${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] "${command.join(" ")}": ${subprocess.pid} -> ${JSON.stringify(descendants)}`, + ) - await execa`kill -9 ${descendants.join(" ")}` - } catch (error) { - console.error("Error killing descendant processes:", error) + if (descendants.length > 0) { + for (const descendant of descendants) { + try { + console.log( + `${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${descendant}`, + ) + + await execa`kill -9 ${descendant}` + } catch (error) { + console.error("Error killing descendant processes:", error) + } } } @@ -386,7 +393,11 @@ const runUnitTest = async ({ task }: { task: Task }) => { `${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${subprocess.pid}`, ) - await execa`kill -9 ${subprocess.pid!}` + try { + await execa`kill -9 ${subprocess.pid!}` + } catch (error) { + console.error("Error killing process:", error) + } }, UNIT_TEST_TIMEOUT) const result = await subprocess diff --git a/evals/packages/db/src/schema.ts b/evals/packages/db/src/schema.ts index 522d5999fb..f2fa86a826 100644 --- a/evals/packages/db/src/schema.ts +++ b/evals/packages/db/src/schema.ts @@ -2,7 +2,7 @@ import { sqliteTable, text, real, integer, blob, uniqueIndex } from "drizzle-orm import { relations } from "drizzle-orm" import { createInsertSchema } from "drizzle-zod" -import { GlobalSettings, RooCodeSettings, exerciseLanguages, rooCodeSettingsSchema } from "@evals/types" +import { RooCodeSettings, exerciseLanguages, rooCodeSettingsSchema } from "@evals/types" /** * runs