@@ -53,6 +53,17 @@ function shellTestEnv(overrides: Record<string, string | undefined>): NodeJS.Pro
5353 return env ;
5454}
5555
56+ function runSourcedHelper (
57+ script : string ,
58+ overrides : Record < string , string | undefined > = { } ,
59+ ) : ReturnType < typeof spawnSync > {
60+ return spawnSync (
61+ "bash" ,
62+ [ "-lc" , [ "set -euo pipefail" , `source ${ shellQuote ( helperPath ) } ` , script ] . join ( "; " ) ] ,
63+ { encoding : "utf8" , env : shellTestEnv ( overrides ) } ,
64+ ) ;
65+ }
66+
5667function expectShellSuccess ( result : ReturnType < typeof spawnSync > ) {
5768 expect ( result . status , result . stderr || result . stdout || result . error ?. message ) . toBe ( 0 ) ;
5869}
@@ -149,6 +160,27 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
149160 expect ( result . stderr ) . toContain ( "decoded to an empty script" ) ;
150161 } ) ;
151162
163+ it ( "reads positive integer env values without treating decimal input as durations" , ( ) => {
164+ const fallback = runSourcedHelper (
165+ 'printf "%s" "$(openclaw_e2e_read_positive_int_env OPENCLAW_E2E_SAMPLE_SECONDS 180)"' ,
166+ ) ;
167+ const leadingZero = runSourcedHelper (
168+ 'printf "%s" "$(openclaw_e2e_read_positive_int_env OPENCLAW_E2E_SAMPLE_SECONDS 180)"' ,
169+ { OPENCLAW_E2E_SAMPLE_SECONDS : "008" } ,
170+ ) ;
171+ const duration = runSourcedHelper (
172+ "openclaw_e2e_read_positive_int_env OPENCLAW_E2E_SAMPLE_SECONDS 180" ,
173+ { OPENCLAW_E2E_SAMPLE_SECONDS : "30s" } ,
174+ ) ;
175+
176+ expectShellSuccess ( fallback ) ;
177+ expect ( fallback . stdout ) . toBe ( "180" ) ;
178+ expectShellSuccess ( leadingZero ) ;
179+ expect ( leadingZero . stdout ) . toBe ( "008" ) ;
180+ expect ( duration . status ) . toBe ( 2 ) ;
181+ expect ( duration . stderr ) . toContain ( "invalid OPENCLAW_E2E_SAMPLE_SECONDS: 30s" ) ;
182+ } ) ;
183+
152184 it ( "requires /readyz after the gateway ready log" , ( ) => {
153185 const tempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-e2e-readyz-required-" ) ) ;
154186 try {
0 commit comments