1- // Process regression coverage for ACP help commands returning without loading runtime transports.
2- import {
3- execFile ,
4- spawn ,
5- spawnSync ,
6- type ChildProcessWithoutNullStreams ,
7- } from "node:child_process" ;
1+ // Process regression coverage for ACP bridge disconnect and startup-handshake exit paths.
2+ import { spawn , spawnSync , type ChildProcessWithoutNullStreams } from "node:child_process" ;
83import { createServer } from "node:http" ;
94import path from "node:path" ;
10- import { promisify , stripVTControlCharacters } from "node:util" ;
5+ import { stripVTControlCharacters } from "node:util" ;
116import { describe , expect , it } from "vitest" ;
127import { type RawData , WebSocketServer } from "ws" ;
138import {
@@ -16,7 +11,6 @@ import {
1611} from "../state/openclaw-state-db.js" ;
1712import { createOpenClawTestState } from "../test-utils/openclaw-test-state.js" ;
1813
19- const execFileAsync = promisify ( execFile ) ;
2014const CHILD_PROCESS_TIMEOUT_MS = 30_000 ;
2115
2216const INITIALIZE_FRAME = {
@@ -126,46 +120,7 @@ function rawDataToText(data: RawData): string {
126120}
127121
128122describe ( "ACP CLI process exit" , ( ) => {
129- it . each ( [
130- { args : [ "acp" , "--help" ] , usage : "Usage: openclaw acp [options] [command]" } ,
131- { args : [ "acp" , "client" , "--help" ] , usage : "Usage: openclaw acp client [options]" } ,
132- ] ) (
133- "exits promptly after $args" ,
134- async ( { args, usage } ) => {
135- const state = await createPreparedAcpProcessState ( ) ;
136- try {
137- const result = await execFileAsync (
138- process . execPath ,
139- [ "--import" , "tsx" , "src/entry.ts" , ...args ] ,
140- {
141- cwd : path . resolve ( "." ) ,
142- encoding : "utf8" ,
143- env : {
144- ...createAcpProcessEnv ( state . env ) ,
145- NODE_OPTIONS : process . platform === "darwin" ? "--use-system-ca" : undefined ,
146- NODE_USE_SYSTEM_CA : undefined ,
147- } ,
148- killSignal : "SIGKILL" ,
149- timeout : CHILD_PROCESS_TIMEOUT_MS ,
150- } ,
151- ) ;
152-
153- expect ( withoutSqliteTransactionWarnings ( result . stderr ) ) . toBe ( "" ) ;
154- expect ( result . stdout ) . toContain ( usage ) ;
155- } finally {
156- await state . cleanup ( ) ;
157- }
158- } ,
159- CHILD_PROCESS_TIMEOUT_MS + 5_000 ,
160- ) ;
161-
162- it . each ( [
163- { name : "empty stdin" , input : "" } ,
164- {
165- name : "an initialize frame" ,
166- input : `${ JSON . stringify ( INITIALIZE_FRAME ) } \n` ,
167- } ,
168- ] ) ( "exits when the bridge starts with $name and the client disconnects" , async ( { input } ) => {
123+ it ( "exits when the client disconnects after sending an initialize frame" , async ( ) => {
169124 const state = await createPreparedAcpProcessState ( ) ;
170125 try {
171126 const result = spawnSync (
@@ -175,7 +130,7 @@ describe("ACP CLI process exit", () => {
175130 cwd : path . resolve ( "." ) ,
176131 encoding : "utf8" ,
177132 env : createAcpProcessEnv ( state . env ) ,
178- input,
133+ input : ` ${ JSON . stringify ( INITIALIZE_FRAME ) } \n` ,
179134 killSignal : "SIGKILL" ,
180135 timeout : CHILD_PROCESS_TIMEOUT_MS ,
181136 } ,
0 commit comments