mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test_runner: make end of work check stricter
This commit updates the logic that checks for the end of the test run. Prior to this change, it was possible for root.run() to be called multiple times because of the way pending subtests were tracked. The extra calls to root.run() were harmless, but could trigger an EventEmitter leak warning due to 'abort' listeners being created. PR-URL: https://github.com/nodejs/node/pull/52326 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
@@ -829,11 +829,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) {
|
||||
|
||||
11
test/parallel/test-runner-filter-warning.js
Normal file
11
test/parallel/test-runner-filter-warning.js
Normal file
@@ -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}`);
|
||||
}
|
||||
Reference in New Issue
Block a user