test: add CLI black-box integration tests from kael.factory#15
Conversation
Migrates the end-to-end CLI tests from kael.factory's tool-base.test.ts that were missing in this repo. These cover Tool.run() behavior as a child process (exit codes, stdout JSON, stderr markers) complementing the existing in-process invoke() tests.
Greptile SummaryThis PR migrates end-to-end CLI integration tests from
Confidence Score: 5/5Pure test addition with no changes to production code; all 108 tests pass and the new tests cover the full range of Tool.run() behaviors. Only production-safe test files are added. The helpers correctly guard against spawn failures and malformed stdout, and every error envelope path now has dedicated assertions. No regressions are introduced. No files require special attention.
|
| Filename | Overview |
|---|---|
| tests/cli.test.ts | Adds 38 black-box integration tests across 9 describe blocks; runTool and parseOutput helpers now guard against spawn failures and empty/malformed stdout. One dead-code branch (sub === "") in the exit-code umbrella callback is never reachable. |
| tests/fixtures/dummy-tool.ts | 8-subcommand fixture covering sync, async, defaults, throws, ToolError, output schema violation, l3Output pipeline, and stderr side-effect detection; all intentional mismatches are clearly marked. |
Sequence Diagram
sequenceDiagram
participant T as bun:test
participant R as runTool()
participant S as spawnSync
participant F as dummy-tool.ts
participant TR as Tool.run()
participant H as subcommand handler
T->>R: runTool(subcommand, ...args)
R->>S: spawnSync bun FIXTURE args
S->>F: spawn child process
F->>TR: tool.run(argv)
alt input valid
TR->>H: invoke handler
H-->>TR: result or throw
TR-->>F: JSON envelope stdout
else input invalid
TR-->>F: ok:false envelope stdout
end
F-->>S: exit 0
S-->>R: stdout stderr status
R-->>T: stdout stderr exitCode
T->>T: parseOutput then assertions
Reviews (2): Last reviewed commit: "fix(tests): address Greptile review — sp..." | Re-trigger Greptile
… assertions - runTool now throws on spawn failure instead of silently passing - parseOutput gives clear error on empty/malformed stdout - Added dedicated test blocks for throws (unexpected_error), businessError (ToolError envelope), and badShape (schema_violation)
|
🎉 This PR is included in version 0.1.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
kael.factory/tests/tool-base.test.tsthat exerciseTool.run()as a child processtests/fixtures/dummy-tool.tsfixture with 8 subcommands covering sync, async, defaults, throws, ToolError, badShape, l3Output, and side-effect pathstests/cli.test.tswith 38 black-box tests covering: defaults applied, handler non-invocation on validation failure (security contract), l3Output pipeline,--subcommandnormalization, global--help/--schemaoverride, and exit-code-always-0 umbrella assertionTest plan
bun test tests/cli.test.ts— 38 tests passbun test— all 108 tests pass (no regressions)