@@ -19,34 +19,8 @@ describe("auto-pair approval receipts (#4616)", () => {
1919 const pythonUnavailable =
2020 spawnSync ( "sh" , [ "-c" , "command -v python3" ] , { stdio : "ignore" } ) . status !== 0 ;
2121
22- it . skipIf ( pythonUnavailable ) ( "omits raw output from devices-list failure classifications" , ( ) => {
23- const policy = readAutoPairApprovalPolicyModule ( ) ;
24- expect ( policy ) . toBeTruthy ( ) ;
25- const script = buildAutoPairApprovalScript (
26- Buffer . from ( policy as string , "utf-8" ) . toString ( "base64" ) ,
27- {
28- emitReceipt : true ,
29- budget : { listTimeoutS : 0.5 } ,
30- } ,
31- ) ;
32- const tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "nemoclaw-auto-pair-list-receipt-" ) ) ;
33- try {
34- fs . writeFileSync (
35- path . join ( tmpDir , "openclaw" ) ,
36- `#!${ process . execPath }
37- const args = process.argv.slice(2);
38- if (args[0] !== "devices" || args[1] !== "list") process.exit(2);
39- const sleepMs = Number(process.env.NEMOCLAW_LIST_SLEEP_MS || "0");
40- if (sleepMs > 0) {
41- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, sleepMs);
42- }
43- process.stdout.write(process.env.NEMOCLAW_LIST_STDOUT || "");
44- process.stderr.write(process.env.NEMOCLAW_LIST_STDERR || "");
45- process.exit(Number(process.env.NEMOCLAW_LIST_EXIT_CODE || "0"));
46- ` ,
47- { mode : 0o755 } ,
48- ) ;
49- for ( const [ environment , receipt ] of [
22+ it . skipIf ( pythonUnavailable ) . each (
23+ [
5024 [ { NEMOCLAW_LIST_SLEEP_MS : "800" } , "list-timeout" ] ,
5125 [
5226 { NEMOCLAW_LIST_EXIT_CODE : "1" , NEMOCLAW_LIST_STDERR : "raw failure" } ,
@@ -77,7 +51,37 @@ process.exit(Number(process.env.NEMOCLAW_LIST_EXIT_CODE || "0"));
7751 [ { NEMOCLAW_LIST_STDOUT : "raw invalid json" } , "list-invalid-json" ] ,
7852 [ { NEMOCLAW_LIST_STDOUT : "[]\n" } , "list-invalid-output" ] ,
7953 [ { NEMOCLAW_LIST_STDOUT : "{}\n" } , "list-missing-pending" ] ,
80- ] as const ) {
54+ ] as const ,
55+ ) (
56+ "omits raw output from devices-list failure classifications [case %#]" ,
57+ ( environment , receipt ) => {
58+ const policy = readAutoPairApprovalPolicyModule ( ) ;
59+ expect ( policy ) . toBeTruthy ( ) ;
60+ const script = buildAutoPairApprovalScript (
61+ Buffer . from ( policy as string , "utf-8" ) . toString ( "base64" ) ,
62+ {
63+ emitReceipt : true ,
64+ budget : { listTimeoutS : 0.5 } ,
65+ } ,
66+ ) ;
67+ const tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "nemoclaw-auto-pair-list-receipt-" ) ) ;
68+ try {
69+ fs . writeFileSync (
70+ path . join ( tmpDir , "openclaw" ) ,
71+ `#!${ process . execPath }
72+ const args = process.argv.slice(2);
73+ if (args[0] !== "devices" || args[1] !== "list") process.exit(2);
74+ const sleepMs = Number(process.env.NEMOCLAW_LIST_SLEEP_MS || "0");
75+ if (sleepMs > 0) {
76+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, sleepMs);
77+ }
78+ process.stdout.write(process.env.NEMOCLAW_LIST_STDOUT || "");
79+ process.stderr.write(process.env.NEMOCLAW_LIST_STDERR || "");
80+ process.exit(Number(process.env.NEMOCLAW_LIST_EXIT_CODE || "0"));
81+ ` ,
82+ { mode : 0o755 } ,
83+ ) ;
84+
8185 const result = spawnSync ( "sh" , [ "-c" , script ] , {
8286 encoding : "utf-8" ,
8387 env : {
@@ -89,11 +93,11 @@ process.exit(Number(process.env.NEMOCLAW_LIST_EXIT_CODE || "0"));
8993 } ) ;
9094 expect ( parseAutoPairApprovalReceipt ( result . stdout ) ) . toBe ( receipt ) ;
9195 expect ( `${ result . stdout } ${ result . stderr } ` ) . not . toContain ( "raw " ) ;
96+ } finally {
97+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
9298 }
93- } finally {
94- fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
95- }
96- } ) ;
99+ } ,
100+ ) ;
97101
98102 it ( "distinguishes host execution failures without returning their details" , ( ) => {
99103 const timeoutError = Object . assign ( new Error ( "private timeout detail" ) , {
0 commit comments