Skip to content

Commit

Permalink
test(xsnap): fix child process types
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Sep 20, 2024
1 parent 904eba6 commit 1aca531
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/xsnap/test/xsnap-eof.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import { makePromiseKit } from '@endo/promise-kit';
import { options } from './message-tools.js';
import { xsnap, QUERY_RESPONSE_BUF } from '../src/xsnap.js';

/**
* @import { Readable, Writable, Duplex } from 'stream'
*/

/**
* @typedef {Omit<import("child_process").ChildProcess, 'stdio'> &
* {

Check warning on line 20 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`

Check warning on line 20 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Expected JSDoc block to be aligned
* stdin: null;

Check warning on line 21 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
* stdout: null;

Check warning on line 22 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
* stderr: Readable;

Check warning on line 23 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
* readonly stdio: [null, null, Readable, Duplex, Duplex, undefined, undefined, Duplex, Duplex];

Check warning on line 24 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
* }

Check warning on line 25 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
* } XsnapChildProcess

Check warning on line 26 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`
*/

Check warning on line 27 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `·`

test('xsnap-worker complains while waiting for answer when parent is killed', async t => {
const exitedPKit = makePromiseKit();

Expand Down Expand Up @@ -48,13 +63,15 @@ test('xsnap-worker complains while waiting for answer when parent is killed', as

async function spawnReflectiveWorker(handleCommand) {
const exitedPKit = makePromiseKit();
/** @type {XsnapChildProcess | undefined} */
let xsnapProcess;

/** @type {typeof import('child_process').spawn} */
const spawnSpy = (...args) => {
// @ts-expect-error overloaded signature
xsnapProcess = proc.spawn(...args);
return xsnapProcess;
const cp = proc.spawn(...args)

Check warning on line 72 in packages/xsnap/test/xsnap-eof.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `;`
xsnapProcess = cp;
return cp;
};

const io = { spawn: spawnSpy, os: os.type(), fs, tmpName };
Expand All @@ -63,6 +80,8 @@ async function spawnReflectiveWorker(handleCommand) {
'function handleCommand(message) { issueCommand(new Uint8Array().buffer); };',
);

assert(xsnapProcess);

const toXsnap = xsnapProcess.stdio[3];
const fromXsnap = xsnapProcess.stdio[4];
const stderrP = text(xsnapProcess.stderr);
Expand Down

0 comments on commit 1aca531

Please sign in to comment.