From 1c8d5a1a429c12420ad010d48624257cad5bdd8a Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Sat, 15 Jun 2024 19:05:55 -0400 Subject: [PATCH] fix: test runner not exiting with code 1 when test fails --- src/testRunner.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/testRunner.ts b/src/testRunner.ts index ed803bf..87a6a12 100644 --- a/src/testRunner.ts +++ b/src/testRunner.ts @@ -23,16 +23,18 @@ const positionalArgs = Object.entries(args) console.log(formatCmd(args["dbCommand"])); const dbProcess = $({ quote: (arg) => arg })`${args["dbCommand"]}`.nothrow(); -$.env = { - ...getTestEnvVariables(), - PATH: process.env["PATH"], - HOME: process.env["HOME"], - SHOULD_LOG_ERRORS: process.env["SHOULD_LOG_ERRORS"] ?? "true", -}; -await $`bun db:migrate`.nothrow(); -await $({ - verbose: true, - quote: (arg) => arg, -})`FORCE_COLOR=1 bun test ${positionalArgs.join(" ")}`.nothrow(); - -await dbProcess.kill("SIGINT"); +try { + $.env = { + ...getTestEnvVariables(), + PATH: process.env["PATH"], + HOME: process.env["HOME"], + SHOULD_LOG_ERRORS: process.env["SHOULD_LOG_ERRORS"] ?? "true", + }; + await $`bun db:migrate`.nothrow(); + await $({ + verbose: true, + quote: (arg) => arg, + })`FORCE_COLOR=1 bun test ${positionalArgs.join(" ")}`; +} finally { + await dbProcess.kill("SIGINT"); +}