@capybara-hq/testing 0.1.0-rc.36 → 0.1.0-rc.37

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.
@@ -221,7 +221,10 @@ export interface SandboxPermissionFixture {
221
221
  readFile(path: string): Promise<Uint8Array | null>;
222
222
  /** Permission bits (`st_mode & 0o7777`), or null when missing. */
223
223
  mode(path: string): Promise<number | null>;
224
- /** The subset of `pids` still running on the device. */
224
+ /**
225
+ * The subset of `pids` still running on the device (a zombie waiting for its reaper may count
226
+ * either way: the harness polls until the killed ones are gone).
227
+ */
225
228
  alive(pids: readonly number[]): Promise<number[]>;
226
229
  /**
227
230
  * Runs a Python 3 program (`python3 - ...args`, program on stdin) as the device user in a
@@ -423,6 +423,21 @@ export async function runSandboxPermissionConformance(fixture, options = {}) {
423
423
  await assert.rejects(promise, (error) => isSandboxScopeDeniedError(error), what);
424
424
  };
425
425
  const waitFor = (path, pending) => waitForFile(fixture.inspect.readFile, path, pending);
426
+ /**
427
+ * Asserts that every process of `pids` ends. A kill is asynchronous: the operation can report
428
+ * its cancel or timeout while a killed descendant is still being delivered its signal or waits
429
+ * for its reaper, so this polls `alive` until none is left, failing with the survivors after
430
+ * 10 s.
431
+ */
432
+ const ended = async (pids, message) => {
433
+ const deadline = Date.now() + 10_000;
434
+ let left = await fixture.inspect.alive(pids);
435
+ while (left.length > 0 && Date.now() < deadline) {
436
+ await new Promise((resolve) => setTimeout(resolve, 20));
437
+ left = await fixture.inspect.alive(left);
438
+ }
439
+ assert.deepEqual(left, [], message);
440
+ };
426
441
  const receipts = async () => Promise.all([granted, ...ungranted].map((endpoint) => endpoint.receipts()));
427
442
  const connect = (endpoint) => `python3 -c ${quote(`import socket; socket.create_connection((${JSON.stringify(endpoint.address)}, ${endpoint.port}), 10).close()`)}`;
428
443
  /** An HTTP request by name; curl and Python use the environment's proxy when there is one. */
@@ -603,7 +618,7 @@ export async function runSandboxPermissionConformance(fixture, options = {}) {
603
618
  abort.abort();
604
619
  const stopped = await cancelled;
605
620
  assert.equal(stopped.exitCode, null, "a cancelled operation has no exit code");
606
- assert.deepEqual(await fixture.inspect.alive(pids), [], "cancellation ends every descendant");
621
+ await ended(pids, "cancellation ends every descendant");
607
622
  await exec(grant, "touch release-keep");
608
623
  assert.equal((await keepAlive).exitCode, 0, "the sibling operation survives the cancel");
609
624
  assert.equal(text(await fixture.inspect.readFile(at(root, "kept"))), "done");
@@ -611,7 +626,7 @@ export async function runSandboxPermissionConformance(fixture, options = {}) {
611
626
  const timed = await exec(grant, `(sleep 1005 & echo $! > p4); sleep 1006`, signal, 1000);
612
627
  assert.equal(timed.timedOut, true, "a restricted timeout is reported");
613
628
  const p4 = Number(text(await fixture.inspect.readFile(at(root, "p4"))));
614
- assert.deepEqual(await fixture.inspect.alive([p4]), [], "timeout ends background children");
629
+ await ended([p4], "timeout ends background children");
615
630
  };
616
631
  /**
617
632
  * An instance-boundary provider (a cloud device): the container or microVM is the sandbox, its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/testing",
3
- "version": "0.1.0-rc.36",
3
+ "version": "0.1.0-rc.37",
4
4
  "description": "Test helpers for Capybara: test containers, dual-replica harness and fake third-party servers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,18 +47,18 @@
47
47
  "tsx": "^4.23.15",
48
48
  "ws": "^8.22.0",
49
49
  "zod": "^4.6.7",
50
- "@capybara-hq/kernel": "^0.1.0-rc.73"
50
+ "@capybara-hq/kernel": "^0.1.0-rc.74"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/pg": "^8.23.1",
54
54
  "@types/ws": "^8.18.2",
55
55
  "@capybara-hq/plugin-client": "^0.1.0-rc.8",
56
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.57"
56
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.59"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "vitest": "^5.0.5",
60
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.57",
61
- "@capybara-hq/plugin-tools": "^0.1.0-rc.20"
60
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.59",
61
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.21"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@capybara-hq/plugin-tools": {