Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/fixtures/test-runner/run-timeout.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test, { after } from 'node:test';

// Keep the event loop alive until both tests time out.
const interval = setInterval(() => {}, 1000);
after(() => clearInterval(interval));

test('pending promise', () => new Promise(() => {}));

test('pending assertion plan', (t) => {
t.plan(1, { wait: true });
});
9 changes: 6 additions & 3 deletions test/parallel/test-inspector-async-hook-setup-at-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function waitUntilDebugged() {

// This function is called by the inspector client (session)
function setupTimeoutWithBreak() {
clearInterval(waiting);
process._rawDebug('Debugger ready, setting up timeout with a break');
setTimeout(() => { debugger; }, 50);
}
Expand All @@ -46,16 +45,20 @@ async function waitForInitialSetup(session) {

async function setupTimeoutForStackTrace(session) {
console.error('[test]', 'Setting up timeout for async stack trace');
// Async hook setup is deferred when requested from a V8 interrupt. Let the
// event loop finish that setup before creating the timeout whose stack we test.
await session.send([
{ 'method': 'Runtime.evaluate',
'params': { expression: 'setupTimeoutWithBreak()' } },
'params': {
expression: 'clearInterval(waiting); setImmediate(setupTimeoutWithBreak)',
} },
{ 'method': 'Debugger.resume' },
]);
}

async function checkAsyncStackTrace(session) {
console.error('[test]', 'Verify basic properties of asyncStackTrace');
const paused = await session.waitForBreakOnLine(23, '[eval]');
const paused = await session.waitForBreakOnLine(22, '[eval]');
assert(paused.params.asyncStackTrace,
`${Object.keys(paused.params)} contains "asyncStackTrace" property`);
assert(paused.params.asyncStackTrace.description, 'Timeout');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {

it('should support timeout', async () => {
const stream = run({ timeout: 50, files: [
fixtures.path('test-runner', 'plan', 'timeout-basic.mjs'),
fixtures.path('test-runner', 'run-timeout.mjs'),
] });
stream.on('test:fail', common.mustCall((data) => {
assert.strictEqual(data.details.error.failureType, 'testTimeoutFailure');
Expand Down
Loading