vouchington-tooling 0.53.0 → 0.55.0
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 +99 -12
- package/dist/agent-blackboard/index.d.mts +0 -1
- package/dist/agent-blackboard/index.mjs +0 -23
- package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
- package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
- package/dist/cli/commands/agent-blackboard.d.mts +0 -2
- package/dist/cli/commands/agent-blackboard.mjs +7 -121
- package/dist/cli/commands/story-coverage.d.mts +2 -0
- package/dist/cli/commands/story-coverage.mjs +56 -0
- package/dist/cli/index.mjs +6 -0
- package/dist/cli/optional-peer.d.mts +5 -0
- package/dist/cli/optional-peer.mjs +17 -0
- package/dist/cli/parse-forwarded-commands.d.mts +3 -0
- package/dist/cli/parse-forwarded-commands.mjs +2 -0
- package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
- package/dist/cli/parse-story-coverage-fields.mjs +69 -0
- package/dist/cli/parse-story-coverage.d.mts +8 -0
- package/dist/cli/parse-story-coverage.mjs +34 -0
- package/dist/cli/parse.d.mts +5 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/story-coverage-lazy.d.mts +3 -0
- package/dist/cli/story-coverage-lazy.mjs +6 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +8 -7
- package/dist/host-storage/check.d.mts +38 -0
- package/dist/host-storage/check.mjs +109 -0
- package/dist/host-storage/cli.d.mts +7 -0
- package/dist/host-storage/cli.mjs +102 -0
- package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
- package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
- package/dist/host-storage/index.d.mts +3 -0
- package/dist/host-storage/index.mjs +3 -0
- package/dist/host-storage/preflight.d.mts +22 -0
- package/dist/host-storage/preflight.mjs +105 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/playwright/assertions.d.mts +1 -0
- package/dist/playwright/assertions.mjs +5 -0
- package/dist/playwright/blocked-external-network.d.mts +15 -0
- package/dist/playwright/blocked-external-network.mjs +73 -0
- package/dist/playwright/browser-dialog-issues.d.mts +12 -0
- package/dist/playwright/browser-dialog-issues.mjs +29 -0
- package/dist/playwright/browser-errors.d.mts +23 -0
- package/dist/playwright/browser-errors.mjs +130 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
- package/dist/playwright/browser-issue-records.d.mts +42 -0
- package/dist/playwright/browser-issue-records.mjs +148 -0
- package/dist/playwright/browser-test.d.mts +22 -0
- package/dist/playwright/browser-test.mjs +68 -0
- package/dist/playwright/expect-no-broken-images.d.mts +17 -0
- package/dist/playwright/expect-no-broken-images.mjs +39 -0
- package/dist/playwright/index.d.mts +32 -0
- package/dist/playwright/index.mjs +22 -0
- package/dist/playwright/mobile-assertions.d.mts +14 -0
- package/dist/playwright/mobile-assertions.mjs +43 -0
- package/dist/playwright/monitored-test-info.d.mts +14 -0
- package/dist/playwright/monitored-test-info.mjs +1 -0
- package/dist/playwright/navigate-to.d.mts +27 -0
- package/dist/playwright/navigate-to.mjs +39 -0
- package/dist/playwright/radix-select.d.mts +18 -0
- package/dist/playwright/radix-select.mjs +19 -0
- package/dist/playwright/random-id.d.mts +34 -0
- package/dist/playwright/random-id.mjs +37 -0
- package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
- package/dist/playwright/retry-on-connection-lost.mjs +107 -0
- package/dist/playwright/scroll-to-load-more.d.mts +37 -0
- package/dist/playwright/scroll-to-load-more.mjs +158 -0
- package/dist/playwright/storybook.d.mts +2 -0
- package/dist/playwright/storybook.mjs +13 -0
- package/dist/playwright/test-fixtures.d.mts +1 -0
- package/dist/playwright/test-fixtures.mjs +2 -0
- package/dist/playwright/test-lifecycle-reporter.d.mts +27 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +57 -0
- package/dist/playwright/totp.d.mts +6 -0
- package/dist/playwright/totp.mjs +37 -0
- package/dist/playwright/turnstile-stub.d.mts +8 -0
- package/dist/playwright/turnstile-stub.mjs +61 -0
- package/dist/playwright/viewport-constants.d.mts +30 -0
- package/dist/playwright/viewport-constants.mjs +9 -0
- package/dist/playwright/virtual-authenticator.d.mts +5 -0
- package/dist/playwright/virtual-authenticator.mjs +15 -0
- package/dist/playwright/wait-for-hydration.d.mts +29 -0
- package/dist/playwright/wait-for-hydration.mjs +81 -0
- package/dist/shell-parse/ansi-c-string.d.mts +12 -0
- package/dist/shell-parse/ansi-c-string.mjs +80 -0
- package/dist/shell-parse/index.d.mts +20 -0
- package/dist/shell-parse/index.mjs +15 -0
- package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
- package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
- package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
- package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
- package/dist/shell-parse/shell-commands.d.mts +24 -0
- package/dist/shell-parse/shell-commands.mjs +155 -0
- package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
- package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
- package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
- package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
- package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
- package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
- package/dist/shell-parse/shell-heredoc.d.mts +10 -0
- package/dist/shell-parse/shell-heredoc.mjs +90 -0
- package/dist/shell-parse/shell-redirections.d.mts +5 -0
- package/dist/shell-parse/shell-redirections.mjs +34 -0
- package/dist/shell-parse/shell-script-operand.d.mts +13 -0
- package/dist/shell-parse/shell-script-operand.mjs +103 -0
- package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
- package/dist/shell-parse/shell-stdin-script.mjs +61 -0
- package/dist/shell-parse/shell-token-utils.d.mts +9 -0
- package/dist/shell-parse/shell-token-utils.mjs +33 -0
- package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
- package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
- package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
- package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
- package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
- package/dist/shell-parse/shell-tokenizer.mjs +104 -0
- package/dist/story-coverage/analyze.d.mts +8 -0
- package/dist/story-coverage/analyze.mjs +24 -0
- package/dist/story-coverage/check.d.mts +11 -0
- package/dist/story-coverage/check.mjs +42 -0
- package/dist/story-coverage/components.d.mts +10 -0
- package/dist/story-coverage/components.mjs +40 -0
- package/dist/story-coverage/coverage.d.mts +10 -0
- package/dist/story-coverage/coverage.mjs +43 -0
- package/dist/story-coverage/index.d.mts +13 -0
- package/dist/story-coverage/index.mjs +7 -0
- package/dist/story-coverage/messages.d.mts +10 -0
- package/dist/story-coverage/messages.mjs +42 -0
- package/dist/story-coverage/options.d.mts +27 -0
- package/dist/story-coverage/options.mjs +51 -0
- package/dist/story-coverage/workspace.d.mts +2 -0
- package/dist/story-coverage/workspace.mjs +27 -0
- package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
- package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
- package/dist/vitest-diagnostics/browser.d.mts +2 -0
- package/dist/vitest-diagnostics/browser.mjs +6 -0
- package/dist/vitest-diagnostics/index.d.mts +14 -23
- package/dist/vitest-diagnostics/index.mjs +8 -124
- package/dist/vitest-diagnostics/report-summary.d.mts +22 -0
- package/dist/vitest-diagnostics/report-summary.mjs +123 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +17 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +44 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +55 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +74 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
- package/dist/vitest-diagnostics/vitest-process-resources.d.mts +10 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +54 -0
- package/dist/vitest-effective-timeout/cap.d.mts +9 -0
- package/dist/vitest-effective-timeout/cap.mjs +28 -0
- package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
- package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
- package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
- package/dist/vitest-effective-timeout/config-file.mjs +23 -0
- package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
- package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
- package/dist/vitest-effective-timeout/index.d.mts +7 -0
- package/dist/vitest-effective-timeout/index.mjs +4 -0
- package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
- package/dist/vitest-effective-timeout/profiles.mjs +33 -0
- package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
- package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
- package/docs/mcp-server.md +2 -13
- package/package.json +37 -2
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/chromium-launch-probe.d.mts +7 -0
- package/scripts/chromium-launch-probe.mjs +101 -0
- package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
- package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
- package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
- package/scripts/run-bounded.py +199 -0
- package/scripts/run_bounded_process.py +129 -0
- package/scripts/worktree/git-index-lock.sh +16 -0
- package/scripts/worktree/git-worktrees.sh +23 -20
- package/scripts/worktree/reset-worktree-run.sh +199 -0
- package/scripts/worktree/reset-worktree.sh +122 -0
- package/skills/blackboard/SKILL.md +4 -64
- package/skills/stacked-prs/SKILL.md +1 -1
- package/skills/stacked-prs/references/drain.md +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vouchington-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Vouchington CLI and extractable tooling libraries.",
|
|
5
5
|
"homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
"import": "./dist/runner-port-policy/index.mjs",
|
|
56
56
|
"default": "./dist/runner-port-policy/index.mjs"
|
|
57
57
|
},
|
|
58
|
+
"./host-storage": {
|
|
59
|
+
"types": "./dist/host-storage/index.d.mts",
|
|
60
|
+
"import": "./dist/host-storage/index.mjs",
|
|
61
|
+
"default": "./dist/host-storage/index.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./shell-parse": {
|
|
64
|
+
"types": "./dist/shell-parse/index.d.mts",
|
|
65
|
+
"import": "./dist/shell-parse/index.mjs",
|
|
66
|
+
"default": "./dist/shell-parse/index.mjs"
|
|
67
|
+
},
|
|
58
68
|
"./retrospective-transcript": {
|
|
59
69
|
"types": "./dist/retrospective-transcript/index.d.mts",
|
|
60
70
|
"import": "./dist/retrospective-transcript/index.mjs",
|
|
@@ -146,6 +156,11 @@
|
|
|
146
156
|
"import": "./dist/source-module-graph/index.mjs",
|
|
147
157
|
"default": "./dist/source-module-graph/index.mjs"
|
|
148
158
|
},
|
|
159
|
+
"./story-coverage": {
|
|
160
|
+
"types": "./dist/story-coverage/index.d.mts",
|
|
161
|
+
"import": "./dist/story-coverage/index.mjs",
|
|
162
|
+
"default": "./dist/story-coverage/index.mjs"
|
|
163
|
+
},
|
|
149
164
|
"./gha-selected-files": {
|
|
150
165
|
"types": "./dist/gha-selected-files/index.d.mts",
|
|
151
166
|
"import": "./dist/gha-selected-files/index.mjs",
|
|
@@ -311,6 +326,21 @@
|
|
|
311
326
|
"import": "./dist/vitest-diagnostics/index.mjs",
|
|
312
327
|
"default": "./dist/vitest-diagnostics/index.mjs"
|
|
313
328
|
},
|
|
329
|
+
"./vitest-diagnostics/browser": {
|
|
330
|
+
"types": "./dist/vitest-diagnostics/browser.d.mts",
|
|
331
|
+
"import": "./dist/vitest-diagnostics/browser.mjs",
|
|
332
|
+
"default": "./dist/vitest-diagnostics/browser.mjs"
|
|
333
|
+
},
|
|
334
|
+
"./vitest-effective-timeout": {
|
|
335
|
+
"types": "./dist/vitest-effective-timeout/index.d.mts",
|
|
336
|
+
"import": "./dist/vitest-effective-timeout/index.mjs",
|
|
337
|
+
"default": "./dist/vitest-effective-timeout/index.mjs"
|
|
338
|
+
},
|
|
339
|
+
"./playwright": {
|
|
340
|
+
"types": "./dist/playwright/index.d.mts",
|
|
341
|
+
"import": "./dist/playwright/index.mjs",
|
|
342
|
+
"default": "./dist/playwright/index.mjs"
|
|
343
|
+
},
|
|
314
344
|
"./gh-cli": {
|
|
315
345
|
"types": "./dist/gh-cli/index.d.mts",
|
|
316
346
|
"import": "./dist/gh-cli/index.mjs",
|
|
@@ -374,7 +404,7 @@
|
|
|
374
404
|
"dependencies": {
|
|
375
405
|
"@types/mdast": "4.0.4",
|
|
376
406
|
"@types/unist": "3.0.3",
|
|
377
|
-
"@typescript-eslint/parser": "^8.71.
|
|
407
|
+
"@typescript-eslint/parser": "^8.71.2",
|
|
378
408
|
"agent-blackboard": "^0.7.0",
|
|
379
409
|
"csv-parse": "7.0.3",
|
|
380
410
|
"csv-stringify": "6.9.0",
|
|
@@ -389,6 +419,7 @@
|
|
|
389
419
|
"devDependencies": {
|
|
390
420
|
"@ast-grep/cli": "0.50.0",
|
|
391
421
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
422
|
+
"@playwright/test": "1.64.1",
|
|
392
423
|
"@types/picomatch": "^4.0.3",
|
|
393
424
|
"@types/spdx-expression-parse": "4.0.0",
|
|
394
425
|
"no-mistakes": "0.83.0",
|
|
@@ -397,6 +428,7 @@
|
|
|
397
428
|
},
|
|
398
429
|
"peerDependencies": {
|
|
399
430
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
431
|
+
"@playwright/test": ">=1.64.1",
|
|
400
432
|
"no-mistakes": "*",
|
|
401
433
|
"typescript": ">=5",
|
|
402
434
|
"vitest": ">=5"
|
|
@@ -405,6 +437,9 @@
|
|
|
405
437
|
"@modelcontextprotocol/sdk": {
|
|
406
438
|
"optional": true
|
|
407
439
|
},
|
|
440
|
+
"@playwright/test": {
|
|
441
|
+
"optional": true
|
|
442
|
+
},
|
|
408
443
|
"no-mistakes": {
|
|
409
444
|
"optional": true
|
|
410
445
|
},
|
|
Binary file
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Exit 0 when the selected browser launches and closes cleanly, 1 otherwise.
|
|
3
|
+
// Plain JavaScript so a Node 20 runner can execute it. setup-playwright runs this
|
|
4
|
+
// before it spends an apt download on playwright install-deps. Chromium also
|
|
5
|
+
// launches with channel chromium, because that build can need different host
|
|
6
|
+
// libraries than the headless shell. Chrome and Edge are Chromium channels, not
|
|
7
|
+
// separate Playwright exports. Any failure counts, and the cause is only printed,
|
|
8
|
+
// so the probe never depends on Playwright's error wording.
|
|
9
|
+
|
|
10
|
+
import { realpathSync } from 'node:fs'
|
|
11
|
+
import { createRequire } from 'node:module'
|
|
12
|
+
import { join } from 'node:path'
|
|
13
|
+
import { pathToFileURL } from 'node:url'
|
|
14
|
+
|
|
15
|
+
const chromiumChannels = new Set([
|
|
16
|
+
'chrome',
|
|
17
|
+
'chrome-beta',
|
|
18
|
+
'chrome-dev',
|
|
19
|
+
'chrome-canary',
|
|
20
|
+
'msedge',
|
|
21
|
+
'msedge-beta',
|
|
22
|
+
'msedge-dev',
|
|
23
|
+
'msedge-canary',
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
export async function chromiumLaunchProbeExitCode(launches) {
|
|
27
|
+
try {
|
|
28
|
+
for (const launch of launches) {
|
|
29
|
+
const browser = await launch()
|
|
30
|
+
await browser.close()
|
|
31
|
+
}
|
|
32
|
+
return 0
|
|
33
|
+
} catch (err) {
|
|
34
|
+
process.stderr.write(`Browser failed to launch: ${String(err)}\n`)
|
|
35
|
+
return 1
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function probeLaunches(browserName, playwright) {
|
|
40
|
+
if (!/^[A-Za-z0-9_-]+$/.test(browserName)) return 'browser must be a single token'
|
|
41
|
+
if (browserName === 'chromium' || chromiumChannels.has(browserName)) {
|
|
42
|
+
const browser = playwright.chromium
|
|
43
|
+
if (!browser) return 'Playwright has no browser chromium'
|
|
44
|
+
if (browserName === 'chromium') {
|
|
45
|
+
return [() => browser.launch(), () => browser.launch({ channel: 'chromium' })]
|
|
46
|
+
}
|
|
47
|
+
return [() => browser.launch({ channel: browserName })]
|
|
48
|
+
}
|
|
49
|
+
const browser = playwright[browserName]
|
|
50
|
+
if (!browser) return `Playwright has no browser ${browserName}`
|
|
51
|
+
return [() => browser.launch()]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function hasCode(err, code) {
|
|
55
|
+
return typeof err === 'object' && err !== null && 'code' in err && err.code === code
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function loadPlaywright(workspace) {
|
|
59
|
+
const require = createRequire(join(workspace, 'package.json'))
|
|
60
|
+
let missing
|
|
61
|
+
for (const specifier of ['playwright', '@playwright/test']) {
|
|
62
|
+
try {
|
|
63
|
+
return require(specifier)
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (hasCode(err, 'ERR_REQUIRE_ESM')) {
|
|
66
|
+
return import(pathToFileURL(require.resolve(specifier)).href)
|
|
67
|
+
}
|
|
68
|
+
if (!hasCode(err, 'MODULE_NOT_FOUND')) throw err
|
|
69
|
+
missing = err
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw missing
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function ranAsScript() {
|
|
76
|
+
const entry = process.argv[1]
|
|
77
|
+
if (entry === undefined) return false
|
|
78
|
+
// argv keeps the path the caller passed. import.meta.url is the real file,
|
|
79
|
+
// which differs when that path goes through a symlink such as macOS /var.
|
|
80
|
+
try {
|
|
81
|
+
return import.meta.url === pathToFileURL(realpathSync(entry)).href
|
|
82
|
+
} catch {
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ranAsScript()) {
|
|
88
|
+
const browserName = process.env.PLAYWRIGHT_BROWSER ?? 'chromium'
|
|
89
|
+
const workspace = process.env.GITHUB_WORKSPACE || process.cwd()
|
|
90
|
+
let exitCode = 1
|
|
91
|
+
try {
|
|
92
|
+
// Resolve from the caller workspace. The script itself lives in the action checkout.
|
|
93
|
+
const playwright = await loadPlaywright(workspace)
|
|
94
|
+
const launches = probeLaunches(browserName, playwright)
|
|
95
|
+
exitCode = typeof launches === 'string' ? 1 : await chromiumLaunchProbeExitCode(launches)
|
|
96
|
+
if (typeof launches === 'string') process.stderr.write(`${launches}\n`)
|
|
97
|
+
} catch (err) {
|
|
98
|
+
process.stderr.write(`Browser failed to launch: ${String(err)}\n`)
|
|
99
|
+
}
|
|
100
|
+
process.exit(exitCode)
|
|
101
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Real CLI fixture: release bounded downstream sockets on owned source-pipe closure."""
|
|
2
|
+
import array
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import selectors
|
|
6
|
+
import socket
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import tempfile
|
|
10
|
+
import threading
|
|
11
|
+
|
|
12
|
+
if sys.version_info < (3, 11):
|
|
13
|
+
sys.stderr.write('run-bounded-backpressure.py requires Python 3.11 or newer\n')
|
|
14
|
+
raise SystemExit(1)
|
|
15
|
+
|
|
16
|
+
command = '''
|
|
17
|
+
import array, os, socket, sys
|
|
18
|
+
control = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
19
|
+
control.connect(sys.argv[1])
|
|
20
|
+
control.sendmsg([b'owned-source-fds'], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array('i', [1, 2]))])
|
|
21
|
+
assert control.recv(1) == b'r'
|
|
22
|
+
for gate, payload in ((b'r', b'a' * 8191 + b'z'), (b's', b'b' * 4095 + b'y')):
|
|
23
|
+
if gate == b's':
|
|
24
|
+
assert control.recv(1) == gate
|
|
25
|
+
while payload:
|
|
26
|
+
payload = payload[os.write(1, payload):]
|
|
27
|
+
raise SystemExit(3)
|
|
28
|
+
'''
|
|
29
|
+
holder = '''
|
|
30
|
+
import os, sys
|
|
31
|
+
os.write(int(sys.argv[1]), b'ready')
|
|
32
|
+
os.close(int(sys.argv[1]))
|
|
33
|
+
try:
|
|
34
|
+
remaining = 1024 * 1024
|
|
35
|
+
while remaining:
|
|
36
|
+
remaining -= os.write(2, b'x' * min(remaining, 65536))
|
|
37
|
+
raise RuntimeError('Source never backpressured')
|
|
38
|
+
except BrokenPipeError:
|
|
39
|
+
pass
|
|
40
|
+
'''
|
|
41
|
+
with tempfile.TemporaryDirectory(prefix='run-bounded-backpressure-') as directory:
|
|
42
|
+
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
43
|
+
path = directory + '/control.sock'
|
|
44
|
+
server.bind(path)
|
|
45
|
+
server.listen(1)
|
|
46
|
+
out_read, out_write = socket.socketpair()
|
|
47
|
+
err_read, err_write = socket.socketpair()
|
|
48
|
+
for writer in (out_write, err_write):
|
|
49
|
+
if sys.argv[2:] == ['nonblocking']:
|
|
50
|
+
writer.setblocking(False)
|
|
51
|
+
writer.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024)
|
|
52
|
+
assert writer.getsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF) < 8192
|
|
53
|
+
wrapper = None
|
|
54
|
+
source_holder = None
|
|
55
|
+
connection = None
|
|
56
|
+
owned_fds = []
|
|
57
|
+
selector = selectors.DefaultSelector()
|
|
58
|
+
outputs = {'stdout': bytearray(), 'stderr': bytearray()}
|
|
59
|
+
wake_read, wake_write = socket.socketpair()
|
|
60
|
+
disposed = threading.Event()
|
|
61
|
+
wrapper_exited = threading.Event()
|
|
62
|
+
closing = threading.Event()
|
|
63
|
+
waiter = None
|
|
64
|
+
def wake():
|
|
65
|
+
try:
|
|
66
|
+
wake_write.sendall(b'w')
|
|
67
|
+
except OSError:
|
|
68
|
+
if not closing.is_set():
|
|
69
|
+
raise
|
|
70
|
+
def dispose_on_input_eof():
|
|
71
|
+
while os.read(0, 4096):
|
|
72
|
+
pass
|
|
73
|
+
disposed.set()
|
|
74
|
+
wake()
|
|
75
|
+
for reader in (out_read, err_read):
|
|
76
|
+
try:
|
|
77
|
+
reader.shutdown(socket.SHUT_RDWR)
|
|
78
|
+
except OSError:
|
|
79
|
+
pass
|
|
80
|
+
threading.Thread(target=dispose_on_input_eof, daemon=True).start()
|
|
81
|
+
def await_readable(descriptor):
|
|
82
|
+
with selectors.DefaultSelector() as readiness:
|
|
83
|
+
readiness.register(descriptor, selectors.EVENT_READ)
|
|
84
|
+
readiness.register(wake_read, selectors.EVENT_READ)
|
|
85
|
+
while True:
|
|
86
|
+
if disposed.is_set():
|
|
87
|
+
raise RuntimeError('Owned fixture disposed during startup')
|
|
88
|
+
if wrapper_exited.is_set():
|
|
89
|
+
raise RuntimeError('Wrapper exited before fixture readiness')
|
|
90
|
+
events = readiness.select()
|
|
91
|
+
if any(key.fileobj == wake_read for key, _ in events):
|
|
92
|
+
wake_read.recv(64)
|
|
93
|
+
continue
|
|
94
|
+
return
|
|
95
|
+
try:
|
|
96
|
+
wrapper = subprocess.Popen(
|
|
97
|
+
[sys.executable, sys.argv[1], '30', sys.executable, '-c', command, path],
|
|
98
|
+
stdin=subprocess.PIPE, stdout=out_write, stderr=err_write,
|
|
99
|
+
)
|
|
100
|
+
out_write.close()
|
|
101
|
+
err_write.close()
|
|
102
|
+
def observe_wrapper_exit():
|
|
103
|
+
wrapper.wait()
|
|
104
|
+
wrapper_exited.set()
|
|
105
|
+
wake()
|
|
106
|
+
waiter = threading.Thread(target=observe_wrapper_exit)
|
|
107
|
+
waiter.start()
|
|
108
|
+
await_readable(server)
|
|
109
|
+
connection, _ = server.accept()
|
|
110
|
+
await_readable(connection)
|
|
111
|
+
_, controls, _, _ = connection.recvmsg(64, socket.CMSG_SPACE(2 * array.array('i').itemsize))
|
|
112
|
+
for level, kind, data in controls:
|
|
113
|
+
assert (level, kind) == (socket.SOL_SOCKET, socket.SCM_RIGHTS)
|
|
114
|
+
descriptors = array.array('i')
|
|
115
|
+
descriptors.frombytes(data)
|
|
116
|
+
owned_fds.extend(descriptors)
|
|
117
|
+
assert len(owned_fds) == 2
|
|
118
|
+
ready_read, ready_write = os.pipe()
|
|
119
|
+
try:
|
|
120
|
+
source_holder = subprocess.Popen(
|
|
121
|
+
[sys.executable, '-c', holder, str(ready_write)],
|
|
122
|
+
stdin=subprocess.DEVNULL, stdout=owned_fds[0], stderr=owned_fds[1],
|
|
123
|
+
pass_fds=(ready_write,), start_new_session=True,
|
|
124
|
+
)
|
|
125
|
+
os.close(ready_write)
|
|
126
|
+
ready_write = None
|
|
127
|
+
await_readable(ready_read)
|
|
128
|
+
assert os.read(ready_read, 5) == b'ready'
|
|
129
|
+
finally:
|
|
130
|
+
if ready_write is not None:
|
|
131
|
+
os.close(ready_write)
|
|
132
|
+
os.close(ready_read)
|
|
133
|
+
for descriptor in owned_fds:
|
|
134
|
+
os.close(descriptor)
|
|
135
|
+
owned_fds.clear()
|
|
136
|
+
connection.sendall(b'r')
|
|
137
|
+
# Readability proves the relay has consumed the first source chunk.
|
|
138
|
+
# Leave that output unread so its bounded target remains backpressured.
|
|
139
|
+
await_readable(out_read)
|
|
140
|
+
connection.sendall(b's')
|
|
141
|
+
# No elapsed-time wait: the native source write returns EPIPE only when its reader closes.
|
|
142
|
+
holder_status = source_holder.wait()
|
|
143
|
+
assert holder_status == 0
|
|
144
|
+
for reader, name in ((out_read, 'stdout'), (err_read, 'stderr')):
|
|
145
|
+
selector.register(reader, selectors.EVENT_READ, name)
|
|
146
|
+
while selector.get_map():
|
|
147
|
+
for key, _ in selector.select():
|
|
148
|
+
chunk = key.fileobj.recv(65536)
|
|
149
|
+
if chunk:
|
|
150
|
+
outputs[key.data].extend(chunk)
|
|
151
|
+
else:
|
|
152
|
+
selector.unregister(key.fileobj)
|
|
153
|
+
status = wrapper.wait()
|
|
154
|
+
print(json.dumps({'status': status, 'stdout': outputs['stdout'].decode(),
|
|
155
|
+
'sourceHolderStatus': holder_status, 'wrapperDrained': True}))
|
|
156
|
+
finally:
|
|
157
|
+
# Every owned resource gets a cleanup attempt, even after an earlier failure.
|
|
158
|
+
primary = sys.exception()
|
|
159
|
+
cleanup_errors = []
|
|
160
|
+
def settle(operation):
|
|
161
|
+
try:
|
|
162
|
+
operation()
|
|
163
|
+
except BaseException as err:
|
|
164
|
+
cleanup_errors.append(err)
|
|
165
|
+
for descriptor in owned_fds:
|
|
166
|
+
settle(lambda descriptor=descriptor: os.close(descriptor))
|
|
167
|
+
# Closing the listener also rejects queued, not-yet-accepted handshakes.
|
|
168
|
+
settle(server.close)
|
|
169
|
+
if connection is not None:
|
|
170
|
+
settle(connection.close)
|
|
171
|
+
for reader in (out_read, err_read):
|
|
172
|
+
settle(reader.close)
|
|
173
|
+
if wrapper is not None:
|
|
174
|
+
if wrapper.stdin is not None:
|
|
175
|
+
settle(wrapper.stdin.close)
|
|
176
|
+
settle(wrapper.wait)
|
|
177
|
+
if source_holder is not None:
|
|
178
|
+
settle(source_holder.wait)
|
|
179
|
+
if waiter is not None:
|
|
180
|
+
settle(waiter.join)
|
|
181
|
+
closing.set()
|
|
182
|
+
for resource in (wake_read, wake_write, selector, out_write, err_write):
|
|
183
|
+
settle(resource.close)
|
|
184
|
+
if cleanup_errors:
|
|
185
|
+
failures = ([primary] if primary is not None else []) + cleanup_errors
|
|
186
|
+
raise BaseExceptionGroup('Fixture failure and owned cleanup', failures) from failures[0]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Exercise native merged sinks and independent regular-file open descriptions."""
|
|
2
|
+
import errno
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import pty
|
|
6
|
+
import socket
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import tempfile
|
|
10
|
+
import tty
|
|
11
|
+
|
|
12
|
+
script, mode = sys.argv[1:]
|
|
13
|
+
command = 'import os; os.write(1, b"a" * 1048576); os.write(2, b"Z"); raise SystemExit(3)'
|
|
14
|
+
if mode == 'terminal':
|
|
15
|
+
command = 'import os; assert os.isatty(1) and os.isatty(2); ' + command.removeprefix('import os; ')
|
|
16
|
+
with tempfile.TemporaryDirectory(prefix='bounded-merged-') as directory:
|
|
17
|
+
if mode == 'independent-files':
|
|
18
|
+
path = directory + '/output'
|
|
19
|
+
with open(path, 'w+b') as out, open(path, 'r+b') as err:
|
|
20
|
+
err.seek(1048576)
|
|
21
|
+
proc = subprocess.Popen([sys.executable, script, '5', sys.executable, '-c', command],
|
|
22
|
+
stdout=out, stderr=err)
|
|
23
|
+
status = proc.wait()
|
|
24
|
+
positions = [out.tell(), err.tell()]
|
|
25
|
+
data = open(path, 'rb').read()
|
|
26
|
+
elif mode == 'regular':
|
|
27
|
+
path = directory + '/output'
|
|
28
|
+
with open(path, 'w+b') as target:
|
|
29
|
+
proc = subprocess.Popen([sys.executable, script, '5', sys.executable, '-c', command],
|
|
30
|
+
stdout=target, stderr=target)
|
|
31
|
+
status = proc.wait()
|
|
32
|
+
data = open(path, 'rb').read()
|
|
33
|
+
positions = None
|
|
34
|
+
else:
|
|
35
|
+
if mode == 'socket':
|
|
36
|
+
reader, writer = socket.socketpair()
|
|
37
|
+
writer.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024)
|
|
38
|
+
read_fd, write_fd = reader.fileno(), writer.fileno()
|
|
39
|
+
elif mode == 'terminal':
|
|
40
|
+
read_fd, write_fd = pty.openpty()
|
|
41
|
+
tty.setraw(write_fd)
|
|
42
|
+
else:
|
|
43
|
+
read_fd, write_fd = os.pipe()
|
|
44
|
+
proc = None
|
|
45
|
+
try:
|
|
46
|
+
proc = subprocess.Popen([sys.executable, script, '5', sys.executable, '-c', command],
|
|
47
|
+
stdout=write_fd, stderr=write_fd)
|
|
48
|
+
if mode == 'socket':
|
|
49
|
+
writer.close()
|
|
50
|
+
else:
|
|
51
|
+
os.close(write_fd)
|
|
52
|
+
chunks = []
|
|
53
|
+
while True:
|
|
54
|
+
try:
|
|
55
|
+
chunk = os.read(read_fd, 128)
|
|
56
|
+
except OSError as err:
|
|
57
|
+
if mode != 'terminal' or err.errno != errno.EIO:
|
|
58
|
+
raise
|
|
59
|
+
break
|
|
60
|
+
if not chunk:
|
|
61
|
+
break
|
|
62
|
+
chunks.append(chunk)
|
|
63
|
+
data = b''.join(chunks)
|
|
64
|
+
status = proc.wait()
|
|
65
|
+
positions = None
|
|
66
|
+
finally:
|
|
67
|
+
if mode == 'socket':
|
|
68
|
+
reader.close()
|
|
69
|
+
writer.close()
|
|
70
|
+
else:
|
|
71
|
+
os.close(read_fd)
|
|
72
|
+
if proc is not None:
|
|
73
|
+
proc.wait()
|
|
74
|
+
print(json.dumps(dict(status=status, length=len(data), marker=data.find(b'Z'),
|
|
75
|
+
allBytes=data == b'a' * 1048576 + b'Z', positions=positions)))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""A genuine peer RST must not replace the completed command status."""
|
|
2
|
+
import json
|
|
3
|
+
import select
|
|
4
|
+
import socket
|
|
5
|
+
import struct
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
command = 'import os; os.write(1, b"x" * 70000); os.write(2, b"err\\n"); raise SystemExit(3)'
|
|
10
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
|
|
11
|
+
server.bind(('127.0.0.1', 0))
|
|
12
|
+
server.listen(1)
|
|
13
|
+
with socket.create_connection(server.getsockname(), timeout=5) as downstream:
|
|
14
|
+
peer, _ = server.accept()
|
|
15
|
+
with peer:
|
|
16
|
+
peer.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0))
|
|
17
|
+
# Observe peer-close readiness without consuming the pending native reset error.
|
|
18
|
+
if not select.select([downstream], [], [], 5)[0]:
|
|
19
|
+
raise RuntimeError('Owned reset socket never became readable')
|
|
20
|
+
downstream.settimeout(None)
|
|
21
|
+
result = subprocess.run(
|
|
22
|
+
[sys.executable, sys.argv[1], '5', sys.executable, '-c', command],
|
|
23
|
+
stdout=downstream, stderr=subprocess.PIPE, text=True,
|
|
24
|
+
)
|
|
25
|
+
print(json.dumps(dict(status=result.returncode, stderr=result.stderr)))
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Run a command until it exits or the deadline elapses, then kill its process group."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import array
|
|
7
|
+
import fcntl
|
|
8
|
+
import os
|
|
9
|
+
import select
|
|
10
|
+
import signal
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
import threading
|
|
14
|
+
import termios
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
from run_bounded_process import (
|
|
18
|
+
WrapperSignal,
|
|
19
|
+
arm_termination,
|
|
20
|
+
command_outputs,
|
|
21
|
+
output_sinks,
|
|
22
|
+
reap_terminated_group,
|
|
23
|
+
run,
|
|
24
|
+
signal_group,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
RELAY_JOIN_SECONDS = 3
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Relay(threading.Thread):
|
|
31
|
+
def __init__(self, source, target: int | None) -> None:
|
|
32
|
+
super().__init__()
|
|
33
|
+
self.source = source
|
|
34
|
+
self.target = target
|
|
35
|
+
self.lock = threading.Lock()
|
|
36
|
+
self.pending: list[bytes] = []
|
|
37
|
+
self.closed = False
|
|
38
|
+
self.error: BaseException | None = None
|
|
39
|
+
os.set_blocking(source.fileno(), False)
|
|
40
|
+
self.wake_read, self.wake_write = os.pipe()
|
|
41
|
+
|
|
42
|
+
def cut_source(self) -> None:
|
|
43
|
+
try:
|
|
44
|
+
with self.lock:
|
|
45
|
+
if not self.closed:
|
|
46
|
+
try:
|
|
47
|
+
available = array.array('i', [0])
|
|
48
|
+
fcntl.ioctl(self.source.fileno(), termios.FIONREAD, available, True)
|
|
49
|
+
remaining = available[0]
|
|
50
|
+
while remaining:
|
|
51
|
+
data = os.read(self.source.fileno(), min(remaining, 65536))
|
|
52
|
+
if not data:
|
|
53
|
+
break
|
|
54
|
+
self.pending.append(data)
|
|
55
|
+
remaining -= len(data)
|
|
56
|
+
finally:
|
|
57
|
+
self.closed = True
|
|
58
|
+
self.source.close()
|
|
59
|
+
finally:
|
|
60
|
+
os.write(self.wake_write, b'close')
|
|
61
|
+
|
|
62
|
+
def next_chunk(self) -> bytes:
|
|
63
|
+
while True:
|
|
64
|
+
with self.lock:
|
|
65
|
+
if self.pending:
|
|
66
|
+
return self.pending.pop(0)
|
|
67
|
+
if self.closed:
|
|
68
|
+
return b''
|
|
69
|
+
source_fd = self.source.fileno()
|
|
70
|
+
try:
|
|
71
|
+
select.select([source_fd, self.wake_read], [], [])
|
|
72
|
+
except (OSError, ValueError):
|
|
73
|
+
with self.lock:
|
|
74
|
+
if not self.closed:
|
|
75
|
+
raise
|
|
76
|
+
continue # Take cutoff-buffered bytes under the lock.
|
|
77
|
+
with self.lock:
|
|
78
|
+
if self.closed:
|
|
79
|
+
continue
|
|
80
|
+
try:
|
|
81
|
+
data = os.read(source_fd, 65536)
|
|
82
|
+
except BlockingIOError:
|
|
83
|
+
continue
|
|
84
|
+
if not data:
|
|
85
|
+
self.closed = True
|
|
86
|
+
self.source.close()
|
|
87
|
+
return data
|
|
88
|
+
|
|
89
|
+
def run(self) -> None:
|
|
90
|
+
target = self.target
|
|
91
|
+
try:
|
|
92
|
+
while data := self.next_chunk():
|
|
93
|
+
if target is None:
|
|
94
|
+
continue
|
|
95
|
+
try:
|
|
96
|
+
while data:
|
|
97
|
+
try:
|
|
98
|
+
written = os.write(target, data)
|
|
99
|
+
except BlockingIOError:
|
|
100
|
+
select.select([], [target], [])
|
|
101
|
+
continue
|
|
102
|
+
if written == 0:
|
|
103
|
+
raise RuntimeError('Output write made no progress')
|
|
104
|
+
data = data[written:]
|
|
105
|
+
except (BrokenPipeError, ConnectionResetError):
|
|
106
|
+
target = None # Downstream closed; drain without leaking a sink FD.
|
|
107
|
+
except BaseException as err:
|
|
108
|
+
self.error = err
|
|
109
|
+
finally:
|
|
110
|
+
with self.lock:
|
|
111
|
+
self.closed = True
|
|
112
|
+
try:
|
|
113
|
+
self.source.close()
|
|
114
|
+
except BaseException as err:
|
|
115
|
+
if self.error is None:
|
|
116
|
+
self.error = err
|
|
117
|
+
else:
|
|
118
|
+
failure = RuntimeError(f'Relay failed: {self.error!r}; source close: {err!r}')
|
|
119
|
+
failure.__cause__ = self.error
|
|
120
|
+
self.error = failure
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def main() -> None:
|
|
124
|
+
if len(sys.argv) < 3:
|
|
125
|
+
print('usage: run-bounded.py <seconds> <command> [args...]', file=sys.stderr)
|
|
126
|
+
raise SystemExit(2)
|
|
127
|
+
try:
|
|
128
|
+
seconds = int(sys.argv[1])
|
|
129
|
+
except ValueError:
|
|
130
|
+
print('timeout seconds must be an integer', file=sys.stderr)
|
|
131
|
+
raise SystemExit(2) from None
|
|
132
|
+
if seconds < 1:
|
|
133
|
+
print('timeout seconds must be positive', file=sys.stderr)
|
|
134
|
+
raise SystemExit(2)
|
|
135
|
+
|
|
136
|
+
with output_sinks() as targets:
|
|
137
|
+
execute(seconds, targets)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def execute(seconds: int, targets: list[int | None]) -> None:
|
|
141
|
+
proc = subprocess.Popen(
|
|
142
|
+
sys.argv[2:], **command_outputs(targets), start_new_session=True
|
|
143
|
+
)
|
|
144
|
+
relays: list[Relay] = []
|
|
145
|
+
started: list[Relay] = []
|
|
146
|
+
errors: list[BaseException] = []
|
|
147
|
+
status = 1
|
|
148
|
+
try:
|
|
149
|
+
arm_termination()
|
|
150
|
+
for stream, fd in zip((proc.stdout, proc.stderr), targets):
|
|
151
|
+
if stream is not None:
|
|
152
|
+
relays.append(Relay(stream, fd))
|
|
153
|
+
for thread in relays:
|
|
154
|
+
thread.start()
|
|
155
|
+
started.append(thread)
|
|
156
|
+
status = run(proc, seconds)
|
|
157
|
+
except WrapperSignal as err:
|
|
158
|
+
status = reap_terminated_group(proc, err.signum)
|
|
159
|
+
except BaseException as err:
|
|
160
|
+
errors.append(err)
|
|
161
|
+
for sig in (signal.SIGTERM, signal.SIGKILL):
|
|
162
|
+
try:
|
|
163
|
+
signal_group(proc.pid, sig)
|
|
164
|
+
proc.wait(timeout=10)
|
|
165
|
+
except BaseException as cleanup_err:
|
|
166
|
+
errors.append(cleanup_err)
|
|
167
|
+
finally:
|
|
168
|
+
deadline = time.monotonic() + RELAY_JOIN_SECONDS
|
|
169
|
+
for thread in started:
|
|
170
|
+
thread.join(max(0.0, deadline - time.monotonic()))
|
|
171
|
+
# Sever descendant sources, never abandon a write to the downstream consumer.
|
|
172
|
+
for thread in relays:
|
|
173
|
+
try:
|
|
174
|
+
thread.cut_source()
|
|
175
|
+
except BaseException as err:
|
|
176
|
+
errors.append(err)
|
|
177
|
+
for thread in started:
|
|
178
|
+
thread.join()
|
|
179
|
+
if thread.error is not None:
|
|
180
|
+
errors.append(thread.error)
|
|
181
|
+
for stream in (proc.stdout, proc.stderr):
|
|
182
|
+
try:
|
|
183
|
+
if stream is not None:
|
|
184
|
+
stream.close()
|
|
185
|
+
except BaseException as err:
|
|
186
|
+
errors.append(err)
|
|
187
|
+
for thread in relays:
|
|
188
|
+
for descriptor in (thread.wake_read, thread.wake_write):
|
|
189
|
+
try:
|
|
190
|
+
os.close(descriptor)
|
|
191
|
+
except BaseException as err:
|
|
192
|
+
errors.append(err)
|
|
193
|
+
if errors:
|
|
194
|
+
raise RuntimeError('Command/relay cleanup failed: ' + '; '.join(map(repr, errors))) from errors[0]
|
|
195
|
+
raise SystemExit(status)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == '__main__':
|
|
199
|
+
main()
|