From ed944a9481976984a18c6709693be518675b6d8f Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Mon, 14 Sep 2026 23:43:18 -0600 Subject: [PATCH 1/3] test: cover exit code of bsh test --- src/commands/test.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/commands/test.test.ts diff --git a/src/commands/test.test.ts b/src/commands/test.test.ts new file mode 100644 index 0000000..6bb6465 --- /dev/null +++ b/src/commands/test.test.ts @@ -0,0 +1,29 @@ +import { fileURLToPath } from 'node:url'; +import { x } from 'tinyexec'; +import { describe, it, expect } from 'vitest'; +import { createFixture } from '../test-utils/index.ts'; + +const bin = fileURLToPath(new URL('../bin.ts', import.meta.url)); + +async function runBshTest(assertion: string): Promise { + const fixture = await createFixture({ + 'package.json': { name: 'test-pkg', type: 'module' }, + 'index.test.ts': `import { it, expect } from 'vitest';\nit('case', () => { ${assertion} });\n`, + }); + const result = await x( + process.execPath, + ['--experimental-strip-types', '--no-warnings', bin, 'test'], + { nodeOptions: { cwd: fileURLToPath(fixture.root) }, throwOnError: false }, + ); + return result.exitCode; +} + +describe('test command', () => { + it('exits non-zero when a test fails', async () => { + expect(await runBshTest('expect(1).toBe(2);')).toBe(1); + }); + + it('exits zero when all tests pass', async () => { + expect(await runBshTest('expect(1).toBe(1);')).toBe(0); + }); +}); From d14b07be91e40e00dcb37fad35e3c83e5210a963 Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Mon, 14 Sep 2026 23:44:23 -0600 Subject: [PATCH 2/3] fix(test): pass exit code on test command --- .changeset/quiet-tests-fail.md | 5 +++++ src/commands/test.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/quiet-tests-fail.md diff --git a/.changeset/quiet-tests-fail.md b/.changeset/quiet-tests-fail.md new file mode 100644 index 0000000..0221b52 --- /dev/null +++ b/.changeset/quiet-tests-fail.md @@ -0,0 +1,5 @@ +--- +"@bomb.sh/tools": patch +--- + +`test` CLI command respects internal `vitest` call and passes the exit code to the user. diff --git a/src/commands/test.ts b/src/commands/test.ts index 9a71fe3..a1a58dd 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -15,9 +15,10 @@ function resolveConfig(): string { } export async function test(ctx: CommandContext) { - const stdio = x(local('vitest'), ['run', '--config', resolveConfig(), ...ctx.args]); + const result = x(local('vitest'), ['run', '--config', resolveConfig(), ...ctx.args]); - for await (const line of stdio) { + for await (const line of result) { console.info(line); } + if (result.exitCode) process.exit(result.exitCode); } From 10c9413e9966d5ec31c1ba7313c6acbd0add830d Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Mon, 14 Sep 2026 23:54:45 -0600 Subject: [PATCH 3/3] refactor(test): keep stdio variable name --- src/commands/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/test.ts b/src/commands/test.ts index a1a58dd..dfa00fd 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -15,10 +15,10 @@ function resolveConfig(): string { } export async function test(ctx: CommandContext) { - const result = x(local('vitest'), ['run', '--config', resolveConfig(), ...ctx.args]); + const stdio = x(local('vitest'), ['run', '--config', resolveConfig(), ...ctx.args]); - for await (const line of result) { + for await (const line of stdio) { console.info(line); } - if (result.exitCode) process.exit(result.exitCode); + if (stdio.exitCode) process.exit(stdio.exitCode); }