@@ -53,6 +53,17 @@ function shellTestEnv(overrides: Record<string, string | undefined>): NodeJS.Pro
|
53 | 53 | return env; |
54 | 54 | } |
55 | 55 | |
| 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 | + |
56 | 67 | function expectShellSuccess(result: ReturnType<typeof spawnSync>) { |
57 | 68 | expect(result.status, result.stderr || result.stdout || result.error?.message).toBe(0); |
58 | 69 | } |
@@ -149,6 +160,27 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
|
149 | 160 | expect(result.stderr).toContain("decoded to an empty script"); |
150 | 161 | }); |
151 | 162 | |
| 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 | + |
152 | 184 | it("requires /readyz after the gateway ready log", () => { |
153 | 185 | const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-e2e-readyz-required-")); |
154 | 186 | try { |
|