Skip to content

Commit 62dc284

Browse files
committed
More unit test kill -9 fixes
1 parent 8bb3839 commit 62dc284

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

evals/apps/cli/src/index.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ const runUnitTest = async ({ task }: { task: Task }) => {
357357
console.log(
358358
`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] running "${command.join(" ")}"`,
359359
)
360+
360361
const subprocess = execa({ cwd, shell: true, reject: false })`${command}`
361362

362363
const timeout = setTimeout(async () => {
@@ -370,23 +371,33 @@ const runUnitTest = async ({ task }: { task: Task }) => {
370371
})
371372
})
372373

374+
console.log(
375+
`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] "${command.join(" ")}": ${subprocess.pid} -> ${JSON.stringify(descendants)}`,
376+
)
377+
373378
if (descendants.length > 0) {
374-
try {
375-
console.log(
376-
`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${descendants.join(" ")}`,
377-
)
378-
379-
await execa`kill -9 ${descendants.join(" ")}`
380-
} catch (error) {
381-
console.error("Error killing descendant processes:", error)
379+
for (const descendant of descendants) {
380+
try {
381+
console.log(
382+
`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${descendant}`,
383+
)
384+
385+
await execa`kill -9 ${descendant}`
386+
} catch (error) {
387+
console.error("Error killing descendant processes:", error)
388+
}
382389
}
383390
}
384391

385392
console.log(
386393
`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${subprocess.pid}`,
387394
)
388395

389-
await execa`kill -9 ${subprocess.pid!}`
396+
try {
397+
await execa`kill -9 ${subprocess.pid!}`
398+
} catch (error) {
399+
console.error("Error killing process:", error)
400+
}
390401
}, UNIT_TEST_TIMEOUT)
391402

392403
const result = await subprocess

0 commit comments

Comments
 (0)