Browse Source

More unit test kill -9 fixes (#2570)

* More unit test kill -9 fixes

* Fix linter warning
Chris Estreich 9 months ago
parent
commit
352a6b9c75
2 changed files with 21 additions and 10 deletions
  1. 20 9
      evals/apps/cli/src/index.ts
  2. 1 1
      evals/packages/db/src/schema.ts

+ 20 - 9
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 }) => {
 					})
 				})
 
+				console.log(
+					`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] "${command.join(" ")}": ${subprocess.pid} -> ${JSON.stringify(descendants)}`,
+				)
+
 				if (descendants.length > 0) {
-					try {
-						console.log(
-							`${Date.now()} [cli#runUnitTest | ${task.language} / ${task.exercise}] killing ${descendants.join(" ")}`,
-						)
-
-						await execa`kill -9 ${descendants.join(" ")}`
-					} catch (error) {
-						console.error("Error killing descendant processes:", error)
+					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

+ 1 - 1
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