Skip to content

Commit

Permalink
test: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarchini committed Sep 26, 2024
1 parent 2f4389c commit 558b2c7
Showing 1 changed file with 66 additions and 6 deletions.
72 changes: 66 additions & 6 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -591,52 +591,112 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {

it('should run with different cwd while in watch mode', async () => {
const controller = new AbortController();
let passed = 0;
let failedBeforeAbort = 0;
let failedAferAbort = 0;
let aborted = false;
const stream = run({
cwd: fixtures.path('test-runner', 'cwd'),
watch: true,
signal: controller.signal,
}).on('data', function({ type }) {
if (type === 'test:watch:drained') {
aborted = true;
controller.abort();
}
});

stream.on('test:fail', common.mustNotCall());
stream.on('test:pass', common.mustCall(1));
stream.on('test:fail', (data) => {
if (!aborted) {
failedBeforeAbort++;
} else {
failedAferAbort++;
}
});
stream.on('test:pass', () => {
passed++;
});

// eslint-disable-next-line no-unused-vars
for await (const _ of stream);

assert.strictEqual(failedBeforeAbort, 0);
assert.strictEqual(failedAferAbort, 0);
assert.strictEqual(passed, 1);
});

it('should run with different cwd while in watch mode and isolation "none"', async () => {
const controller = new AbortController();
let passed = 0;
let failedBeforeAbort = 0;
let failedAferAbort = 0;
let aborted = false;
const stream = run({
cwd: fixtures.path('test-runner', 'cwd'),
watch: true,
signal: controller.signal,
isolation: 'none',
}).on('data', function({ type }) {
if (type === 'test:watch:drained') {
aborted = true;
controller.abort();
}
});

stream.on('test:fail', common.mustNotCall());
stream.on('test:pass', common.mustCall(1));
stream.on('test:fail', (data) => {
if (!aborted) {
failedBeforeAbort++;
} else {
failedAferAbort++;
}
});
stream.on('test:pass', () => {
passed++;
});

// eslint-disable-next-line no-unused-vars
for await (const _ of stream);

assert.strictEqual(failedBeforeAbort, 0);
assert.strictEqual(failedAferAbort, 0);
assert.strictEqual(passed, 1);
});

it('should run with different cwd while in watch mode and isolation "process"', async () => {
const controller = new AbortController();
let passed = 0;
let failedBeforeAbort = 0;
let failedAferAbort = 0;
let aborted = false;
const stream = run({
cwd: fixtures.path('test-runner', 'cwd'),
watch: true,
signal: controller.signal,
isolation: 'process',
}).on('data', function({ type }) {
if (type === 'test:watch:drained') {
aborted = true;
controller.abort();
}
});

stream.on('test:fail', common.mustNotCall());
stream.on('test:pass', common.mustCall(1));
stream.on('test:fail', (data) => {
if (!aborted) {
failedBeforeAbort++;
} else {
failedAferAbort++;
}
});
stream.on('test:pass', () => {
passed++;
});

// eslint-disable-next-line no-unused-vars
for await (const _ of stream);

assert.strictEqual(failedBeforeAbort, 0);
assert.strictEqual(failedAferAbort, 0);
assert.strictEqual(passed, 1);
});
});

Expand Down

0 comments on commit 558b2c7

Please sign in to comment.