From 0f808cf7588b772ffac789ecf49877d616580164 Mon Sep 17 00:00:00 2001 From: Aaron Stainback Date: Sat, 16 May 2026 18:44:36 -0400 Subject: [PATCH 1/2] test(B-0156): add bun test for tools/profile.ts CLI dispatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes one acceptance bullet for B-0156: "Each TS sibling has at least one `bun test` covering its primary entry path." This is the 4th of 6 non-install .sh-port targets to get test coverage (amara and ani are covered by peer-call/smoke.test.ts; snapshot / check-drift / check-shard-schema and tools/profile.ts had no dedicated tests). Scope: 8 tests covering help / unknown-command / missing-arg paths that exit early — no external `dotnet-counters` / `dotnet-trace` / `dotnet-gcdump` invocations. Mirrors the established peer-call/smoke.test.ts pattern (spawnSync, 10s timeout, validates CLI plumbing not external-tool behavior). Result: `bun test tools/profile.test.ts` → 8 pass / 0 fail / 24 expect() calls / 896ms. operative-authorization: aaron 2026-05-14: "- **Devil-pole** (edge-runner drive): keep pushing, discover, go hard, never-be-idle" Co-Authored-By: Claude Opus 4.7 --- tools/profile.test.ts | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tools/profile.test.ts diff --git a/tools/profile.test.ts b/tools/profile.test.ts new file mode 100644 index 0000000000..6fa5dc0d6d --- /dev/null +++ b/tools/profile.test.ts @@ -0,0 +1,93 @@ +// profile.test.ts — smoke tests for the DBSP profiling helper CLI. +// +// Scope: VALIDATES CLI DISPATCH AND ARG-PARSING, NOT external tool +// invocations. The `counters` / `trace` / `gcdump` / `bench` / +// `coverage` / `install` branches shell out to `dotnet-counters`, +// `dotnet-trace`, etc., which are not guaranteed to be installed +// on every developer machine or CI runner. This suite covers only +// the help / unknown-command / missing-arg paths that exit early +// before any external process is launched. +// +// Closes one acceptance bullet for B-0156: "Each TS sibling has at +// least one `bun test` covering its primary entry path." + +import { describe, expect, test } from "bun:test"; +import { spawnSync } from "node:child_process"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const PROFILE_TS = resolve( + dirname(fileURLToPath(import.meta.url)), + "profile.ts", +); + +function runProfile(args: readonly string[]): { + status: number; + stdout: string; + stderr: string; +} { + const result = spawnSync("bun", [PROFILE_TS, ...args], { + encoding: "utf8", + timeout: 10_000, + }); + return { + status: result.status ?? -1, + stdout: result.stdout ?? "", + stderr: result.stderr ?? "", + }; +} + +describe("tools/profile.ts CLI dispatch", () => { + test("no args prints help and exits 0", () => { + const result = runProfile([]); + expect(result.status).toBe(0); + expect(result.stdout).toContain("DBSP profiling helper"); + }); + + test("--help exits 0 and prints help text", () => { + const result = runProfile(["--help"]); + expect(result.status).toBe(0); + expect(result.stdout).toContain("DBSP profiling helper"); + }); + + test("-h exits 0 and prints help text", () => { + const result = runProfile(["-h"]); + expect(result.status).toBe(0); + expect(result.stdout).toContain("DBSP profiling helper"); + }); + + test("help lists all canonical subcommands", () => { + const result = runProfile(["--help"]); + expect(result.status).toBe(0); + for (const cmd of ["install", "counters", "trace", "gcdump", "bench", "coverage"]) { + expect(result.stdout).toContain(cmd); + } + }); + + test("unknown command exits 64 (EX_USAGE) and prints help", () => { + const result = runProfile(["not-a-real-command"]); + expect(result.status).toBe(64); + expect(result.stdout).toContain("DBSP profiling helper"); + }); + + test("counters without pid exits 64 with usage on stderr", () => { + const result = runProfile(["counters"]); + expect(result.status).toBe(64); + expect(result.stderr).toContain("usage:"); + expect(result.stderr).toContain("counters"); + }); + + test("trace without pid exits 64 with usage on stderr", () => { + const result = runProfile(["trace"]); + expect(result.status).toBe(64); + expect(result.stderr).toContain("usage:"); + expect(result.stderr).toContain("trace"); + }); + + test("gcdump without pid exits 64 with usage on stderr", () => { + const result = runProfile(["gcdump"]); + expect(result.status).toBe(64); + expect(result.stderr).toContain("usage:"); + expect(result.stderr).toContain("gcdump"); + }); +}); From c84e8e0ddacc350a1bb6d8dcb555d65f753eb0be Mon Sep 17 00:00:00 2001 From: Aaron Stainback Date: Fri, 22 May 2026 16:17:25 -0400 Subject: [PATCH 2/2] fix(test): add bun-types to tsconfig --- fix-3962-tsconfig-imports-4 | 1 + otto-cli/b0156-profile-ts-test-2026-05-16 | 1 + tsconfig.json | 2 +- zeta-lior-preserve-4649 | 1 + zeta-lior-preserve-4650 | 1 + zeta-lior-preserve-4651 | 1 + zeta-lior-preserve-4652 | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) create mode 160000 fix-3962-tsconfig-imports-4 create mode 160000 otto-cli/b0156-profile-ts-test-2026-05-16 create mode 160000 zeta-lior-preserve-4649 create mode 160000 zeta-lior-preserve-4650 create mode 160000 zeta-lior-preserve-4651 create mode 160000 zeta-lior-preserve-4652 diff --git a/fix-3962-tsconfig-imports-4 b/fix-3962-tsconfig-imports-4 new file mode 160000 index 0000000000..f355f51c35 --- /dev/null +++ b/fix-3962-tsconfig-imports-4 @@ -0,0 +1 @@ +Subproject commit f355f51c35f1dc6dbfe7e81044190e13372a37dc diff --git a/otto-cli/b0156-profile-ts-test-2026-05-16 b/otto-cli/b0156-profile-ts-test-2026-05-16 new file mode 160000 index 0000000000..f355f51c35 --- /dev/null +++ b/otto-cli/b0156-profile-ts-test-2026-05-16 @@ -0,0 +1 @@ +Subproject commit f355f51c35f1dc6dbfe7e81044190e13372a37dc diff --git a/tsconfig.json b/tsconfig.json index 3870b40455..3469657630 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,7 @@ "isolatedModules": true, "moduleDetection": "force", "skipLibCheck": true, - "types": ["bun"] + "types": ["bun", "bun-types"] }, "include": ["**/*.ts"], "exclude": [ diff --git a/zeta-lior-preserve-4649 b/zeta-lior-preserve-4649 new file mode 160000 index 0000000000..385ab1ffb4 --- /dev/null +++ b/zeta-lior-preserve-4649 @@ -0,0 +1 @@ +Subproject commit 385ab1ffb44e43af7bd564d090f28170e789717d diff --git a/zeta-lior-preserve-4650 b/zeta-lior-preserve-4650 new file mode 160000 index 0000000000..92510d6f24 --- /dev/null +++ b/zeta-lior-preserve-4650 @@ -0,0 +1 @@ +Subproject commit 92510d6f24b443cf1e341a556dd8fdc69893c193 diff --git a/zeta-lior-preserve-4651 b/zeta-lior-preserve-4651 new file mode 160000 index 0000000000..99d831dd10 --- /dev/null +++ b/zeta-lior-preserve-4651 @@ -0,0 +1 @@ +Subproject commit 99d831dd10f1d04526572e041517acf6afd1fc47 diff --git a/zeta-lior-preserve-4652 b/zeta-lior-preserve-4652 new file mode 160000 index 0000000000..b3605731dc --- /dev/null +++ b/zeta-lior-preserve-4652 @@ -0,0 +1 @@ +Subproject commit b3605731dc57d9a9db93a5919488533a16870dbb