Skip to content

Commit

Permalink
Fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Feb 23, 2022
1 parent 72c7f1e commit 5b54fb0
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/test/index.spec.ts
Expand Up @@ -1072,26 +1072,40 @@ test('Falls back to transpileOnly when ts compiler returns emitSkipped', async (
});

test.suite('node environment', (test) => {
test('Sets argv and execArgv correctly in forked processes', async (t) => {
const { err, stderr, stdout } = await exec(
`node --no-warnings ${BIN_PATH} --skipIgnore ./recursive-fork/index.ts argv2`
test.suite('Sets argv and execArgv correctly in forked processes', (test) => {
forkTest(`node --no-warnings ${BIN_PATH_JS}`, BIN_PATH_JS, '--no-warnings');
forkTest(
`${BIN_PATH}`,
process.platform === 'win32' ? BIN_PATH_JS : BIN_PATH
);
expect(err).toBeNull();
expect(stderr).toBe('');
const generations = stdout.split('\n');
const expectation = {
execArgv: ['--no-warnings', BIN_PATH_JS, '--skipIgnore'],
argv: [
// Note: argv[0] is BIN_PATH in parent, BIN_PATH_JS in child & grandchild
BIN_PATH,
resolve(TEST_DIR, 'recursive-fork/index.ts'),
'argv2',
],
};
expect(JSON.parse(generations[0])).toMatchObject(expectation);
expectation.argv[0] = BIN_PATH_JS;
expect(JSON.parse(generations[1])).toMatchObject(expectation);
expect(JSON.parse(generations[2])).toMatchObject(expectation);

function forkTest(
command: string,
expectParentArgv0: string,
nodeFlag?: string
) {
test(command, async (t) => {
const { err, stderr, stdout } = await exec(
`${command} --skipIgnore ./recursive-fork/index.ts argv2`
);
expect(err).toBeNull();
expect(stderr).toBe('');
const generations = stdout.split('\n');
const expectation = {
execArgv: [nodeFlag, BIN_PATH_JS, '--skipIgnore'].filter((v) => v),
argv: [
// Note: argv[0] is *always* BIN_PATH_JS in child & grandchild
expectParentArgv0,
resolve(TEST_DIR, 'recursive-fork/index.ts'),
'argv2',
],
};
expect(JSON.parse(generations[0])).toMatchObject(expectation);
expectation.argv[0] = BIN_PATH_JS;
expect(JSON.parse(generations[1])).toMatchObject(expectation);
expect(JSON.parse(generations[2])).toMatchObject(expectation);
});
}
});
});

Expand Down

0 comments on commit 5b54fb0

Please sign in to comment.