@@ -4,7 +4,7 @@ import { MINIMUM_SUPPORTED_PATCHLOOM_VERSION } from "../../src/binary/patchloom.
44import { classifyAgentsFile } from "../../src/commands/initializeProject.js" ;
55import { buildStatusDetails , preferredStatusAction } from "../../src/commands/showStatus.js" ;
66import { buildPatchloomMcpEntry , configureMcpTargets , inspectMcpTargets } from "../../src/mcp/config.js" ;
7- import { formatError } from "../../src/util.js" ;
7+ import { formatCliOutput , formatError } from "../../src/util.js" ;
88
99test ( "formatError extracts message from Error instances" , ( ) => {
1010 assert . equal ( formatError ( new Error ( "disk full" ) ) , "disk full" ) ;
@@ -22,6 +22,23 @@ test("formatError falls back to String for Error with empty message", () => {
2222 assert . equal ( formatError ( err ) , String ( err ) ) ;
2323} ) ;
2424
25+ // --- #36: direct unit tests for formatCliOutput ---
26+
27+ test ( "formatCliOutput merges stderr and stdout into a single line" , ( ) => {
28+ const result = formatCliOutput ( { exitCode : 0 , stdout : "hello world" , stderr : "warn: something" } ) ;
29+ assert . equal ( result , "warn: something hello world" ) ;
30+ } ) ;
31+
32+ test ( "formatCliOutput returns exit code when both streams are empty" , ( ) => {
33+ assert . equal ( formatCliOutput ( { exitCode : 1 , stdout : "" , stderr : "" } ) , "exit code 1" ) ;
34+ assert . equal ( formatCliOutput ( { exitCode : 0 , stdout : " \n " , stderr : " " } ) , "exit code 0" ) ;
35+ } ) ;
36+
37+ test ( "formatCliOutput normalizes CRLF line endings" , ( ) => {
38+ const result = formatCliOutput ( { exitCode : 0 , stdout : "line1\r\nline2\r\n" , stderr : "" } ) ;
39+ assert . equal ( result , "line1 line2" ) ;
40+ } ) ;
41+
2542test ( "classifyAgentsFile returns missing when AGENTS.md does not exist" , ( ) => {
2643 assert . equal ( classifyAgentsFile ( undefined , "# Rules\n" ) , "missing" ) ;
2744} ) ;
0 commit comments