Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: make end of work check stricter #52326

Merged
merged 1 commit into from
Apr 11, 2024
Merged
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
9 changes: 9 additions & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,20 @@ class Test extends AsyncResource {
this.parent.activeSubtests--;
}

// The call to processPendingSubtests() below can change the number of
// pending subtests. When detecting if we are done running tests, we want
// to check if there are no pending subtests both before and after
// calling processPendingSubtests(). Otherwise, it is possible to call
// root.run() multiple times (which is harmless but can trigger an
// EventEmitter leak warning).
const pendingSiblingCount = this.parent.pendingSubtests.length;

this.parent.addReadySubtest(this);
this.parent.processReadySubtestRange(false);
this.parent.processPendingSubtests();

if (this.parent === this.root &&
pendingSiblingCount === 0 &&
this.root.activeSubtests === 0 &&
this.root.pendingSubtests.length === 0 &&
this.root.readySubtests.size === 0) {
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-runner-filter-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Flags: --test-only
'use strict';
const common = require('../common');
const { test } = require('node:test');
const { defaultMaxListeners } = require('node:events');

process.on('warning', common.mustNotCall());

for (let i = 0; i < defaultMaxListeners + 1; ++i) {
test(`test ${i + 1}`);
}
Loading