From 21d99d1b5caf53cbdfc8ac44234e408d3670f565 Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Sat, 15 Jun 2024 20:14:51 -0400 Subject: [PATCH] fix: read exit code of bun test in test runner this will avoid duplicate error output --- src/testRunner.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/testRunner.ts b/src/testRunner.ts index 87a6a12..49e3b88 100644 --- a/src/testRunner.ts +++ b/src/testRunner.ts @@ -23,6 +23,7 @@ const positionalArgs = Object.entries(args) console.log(formatCmd(args["dbCommand"])); const dbProcess = $({ quote: (arg) => arg })`${args["dbCommand"]}`.nothrow(); +let exitCode = 0; try { $.env = { ...getTestEnvVariables(), @@ -31,10 +32,13 @@ try { SHOULD_LOG_ERRORS: process.env["SHOULD_LOG_ERRORS"] ?? "true", }; await $`bun db:migrate`.nothrow(); - await $({ + const testProcess = await $({ verbose: true, quote: (arg) => arg, - })`FORCE_COLOR=1 bun test ${positionalArgs.join(" ")}`; + })`FORCE_COLOR=1 bun test ${positionalArgs.join(" ")}`.nothrow(); + exitCode = (await testProcess.exitCode) ?? 0; } finally { await dbProcess.kill("SIGINT"); } + +process.exit(exitCode);