More unit test kill -9 fixes (#2570)

* More unit test kill -9 fixes

* Fix linter warning
This commit is contained in:
Chris Estreich 2025-04-13 09:44:45 -07:00 • committed by GitHub
parent 8bb3839b4d
commit 352a6b9c75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 10 deletions

View file

@ -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

View file

@ -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