Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tannal committed Aug 14, 2024
1 parent a4aa5fd commit f3b3b82
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
11 changes: 4 additions & 7 deletions test/common/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ const common = require('../common');
const gcTrackerMap = new WeakMap();
const gcTrackerTag = 'NODE_TEST_COMMON_GC_TRACKER';


/**
* Installs a garbage collection listener for the specified object.
* Uses async_hooks for GC tracking, which may affect test functionality.
* A full setImmediate() invocation passes between a global.gc() call and the listener being invoked.
*
* @param {Object} obj - The target object to track for garbage collection.
* @param {Object} gcListener - The listener object containing the ongc callback.
* @param {object} obj - The target object to track for garbage collection.
* @param {object} gcListener - The listener object containing the ongc callback.
* @param {Function} gcListener.ongc - The function to call when the target object is garbage collected.
*/
function onGC(obj, gcListener) {
Expand Down Expand Up @@ -42,9 +40,8 @@ function onGC(obj, gcListener) {

/**
* Repeatedly triggers garbage collection until a specified condition is met or a maximum number of attempts is reached.
*
* @param {string|function} [name] - Optional name for the test, used in the rejection message if the condition is not met.
* @param {function} condition - A function that returns true when the desired condition is met.
* @param {string|Function} [name] - Optional name, used in the rejection message if the condition is not met.
* @param {Function} condition - A function that returns true when the desired condition is met.
* @returns {Promise} A promise that resolves when the condition is met, or rejects after 10 failed attempts.
*/
function gcUntil(name, condition) {
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/8_passing_wrapped/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ async function runTest() {
obj1 = null;
obj2 = null;
await gcUntil('8_passing_wrapped',
() => (addon.finalizeCount() === 2));
() => (addon.finalizeCount() === 2));
}
runTest();
2 changes: 1 addition & 1 deletion test/js-native-api/test_finalizer/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function runAsyncTests() {
test_finalizer.addFinalizerWithJS(obj, () => { js_is_called = true; });
})();
await gcUntil('ensure JS finalizer called',
() => (test_finalizer.getFinalizerCallCount() === 2));
() => (test_finalizer.getFinalizerCallCount() === 2));
assert(js_is_called);
}
runAsyncTests();
2 changes: 1 addition & 1 deletion test/js-native-api/test_general/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function runGCTests() {
(() => test_general.wrap({}))();
await gcUntil('deref_item() was called upon garbage collecting a ' +
'wrapped object.',
() => test_general.derefItemWasCalled());
() => test_general.derefItemWasCalled());

// Ensure that removing a wrap and garbage collecting does not fire the
// finalize callback.
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/test_general/testFinalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ async function testFinalizeAndWrap() {
test_general.addFinalizerOnly(finalizeAndWrap, common.mustCall());
finalizeAndWrap = null;
await gcUntil('test finalize and wrap',
() => test_general.derefItemWasCalled());
() => test_general.derefItemWasCalled());
}
testFinalizeAndWrap();
1 change: 1 addition & 0 deletions test/parallel/test-internal-util-weakreference.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Flags: --expose-internals --expose-gc
'use strict';
require('../common');
const { gcUntil } = require('../common/gc');
const assert = require('assert');
const { WeakReference } = require('internal/util');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-primitive-timer-leak.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
// Flags: --expose-gc
const common = require('../common');
require('../common');
const { onGC } = require('../common/gc');

// See https://github.com/nodejs/node/issues/53335
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-source-map-cjs-require-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

'use strict';
require('../common');
const { gcUntil } = require('../common/gc');
const assert = require('node:assert');
const { findSourceMap } = require('node:module');
Expand Down

0 comments on commit f3b3b82

Please sign in to comment.