ccqa 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/dist/bin/ccqa.mjs +1130 -180
- package/dist/package.json +1 -1
- package/dist/runtime/test-helpers.mjs +29 -7
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -3,31 +3,52 @@ import { spawnSync } from "node:child_process";
|
|
|
3
3
|
//#region src/runtime/test-helpers.ts
|
|
4
4
|
const AB = createRequire(import.meta.url).resolve("agent-browser/bin/agent-browser.js");
|
|
5
5
|
const EAGAIN_PATTERN = /Resource temporarily unavailable|os error 35/i;
|
|
6
|
-
const
|
|
6
|
+
const EAGAIN_TOTAL_BUDGET_MS = 3e4;
|
|
7
7
|
const EAGAIN_BACKOFF_MS = [
|
|
8
|
+
100,
|
|
8
9
|
200,
|
|
10
|
+
300,
|
|
9
11
|
500,
|
|
10
|
-
|
|
12
|
+
700,
|
|
13
|
+
1e3,
|
|
14
|
+
1500,
|
|
15
|
+
2e3,
|
|
16
|
+
2500,
|
|
17
|
+
3e3,
|
|
18
|
+
3e3,
|
|
19
|
+
3e3,
|
|
20
|
+
3e3,
|
|
21
|
+
3e3,
|
|
22
|
+
3e3
|
|
11
23
|
];
|
|
24
|
+
const POST_OPEN_SETTLE_MS = 600;
|
|
12
25
|
function sleepSync(ms) {
|
|
13
26
|
const buf = new SharedArrayBuffer(4);
|
|
14
27
|
Atomics.wait(new Int32Array(buf), 0, 0, ms);
|
|
15
28
|
}
|
|
29
|
+
const PROCESS_HARD_TIMEOUT_MS = 9e4;
|
|
16
30
|
function spawnABOnce(args) {
|
|
17
|
-
const result = spawnSync(AB, args, {
|
|
31
|
+
const result = spawnSync(AB, args, {
|
|
32
|
+
stdio: "pipe",
|
|
33
|
+
timeout: PROCESS_HARD_TIMEOUT_MS
|
|
34
|
+
});
|
|
18
35
|
return {
|
|
19
36
|
status: result.status,
|
|
20
37
|
stdout: result.stdout?.toString() ?? "",
|
|
21
|
-
stderr: result.stderr?.toString() ?? ""
|
|
38
|
+
stderr: (result.stderr?.toString() ?? "") + (result.signal === "SIGTERM" ? "\n[ccqa] agent-browser killed after hard timeout" : "")
|
|
22
39
|
};
|
|
23
40
|
}
|
|
24
41
|
function spawnAB(args) {
|
|
25
42
|
let result = spawnABOnce(args);
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
let elapsed = 0;
|
|
44
|
+
let attempt = 0;
|
|
45
|
+
while (result.status !== 0 && elapsed < EAGAIN_TOTAL_BUDGET_MS) {
|
|
28
46
|
const combined = `${result.stdout}\n${result.stderr}`;
|
|
29
47
|
if (!EAGAIN_PATTERN.test(combined)) return result;
|
|
30
|
-
|
|
48
|
+
const wait = EAGAIN_BACKOFF_MS[attempt] ?? 3e3;
|
|
49
|
+
sleepSync(wait);
|
|
50
|
+
elapsed += wait;
|
|
51
|
+
attempt++;
|
|
31
52
|
result = spawnABOnce(args);
|
|
32
53
|
}
|
|
33
54
|
return result;
|
|
@@ -47,6 +68,7 @@ function ab(...args) {
|
|
|
47
68
|
logStep(command, rest);
|
|
48
69
|
const result = spawnAB(args);
|
|
49
70
|
if (result.status !== 0) fail(`agent-browser ${command} failed (exit ${result.status})`, result);
|
|
71
|
+
if (command === "open") sleepSync(POST_OPEN_SETTLE_MS);
|
|
50
72
|
}
|
|
51
73
|
/** Wait for element/text with an explicit timeout so long-running async ops don't hang. */
|
|
52
74
|
function abWait(selector, timeoutMs = 18e4) {
|