From: Jérôme Benoit Date: Sun, 2 Jul 2023 19:54:58 +0000 (+0200) Subject: refactor: split TestUtils class into arrow functions X-Git-Tag: v2.6.7~14 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bac873bd6581e5d5c0884bc520e9ec3c446509e6;p=poolifier.git refactor: split TestUtils class into arrow functions Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index d2f4fc23..225143f1 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -8,7 +8,7 @@ import { } from '../lib/index.mjs' import { PoolTypes, WorkerFunctions, WorkerTypes } from './benchmarks-types.mjs' -export async function runTest (pool, { taskExecutions, workerData }) { +export const runTest = async (pool, { taskExecutions, workerData }) => { return new Promise((resolve, reject) => { let executions = 0 for (let i = 1; i <= taskExecutions; i++) { @@ -29,7 +29,10 @@ export async function runTest (pool, { taskExecutions, workerData }) { }) } -export function generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) { +export const generateRandomInteger = ( + max = Number.MAX_SAFE_INTEGER, + min = 0 +) => { if (max < min || max < 0 || min < 0) { throw new RangeError('Invalid interval') } @@ -41,7 +44,7 @@ export function generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) { return Math.floor(Math.random() * (max + 1)) } -function jsonIntegerSerialization (n) { +const jsonIntegerSerialization = n => { for (let i = 0; i < n; i++) { const o = { a: i @@ -55,7 +58,7 @@ function jsonIntegerSerialization (n) { * @param {number} n - The number of fibonacci numbers to generate. * @returns {number} - The nth fibonacci number. */ -function fibonacci (n) { +const fibonacci = n => { if (n <= 1) return n return fibonacci(n - 1) + fibonacci(n - 2) } @@ -65,19 +68,19 @@ function fibonacci (n) { * @param {number} n - The number to calculate the factorial of. * @returns {number} - The factorial of n. */ -function factorial (n) { +const factorial = n => { if (n === 0) { return 1 } return factorial(n - 1) * n } -function readWriteFiles ( +const readWriteFiles = ( n, baseDirectory = `/tmp/poolifier-benchmarks/${crypto.randomInt( 281474976710655 )}` -) { +) => { if (fs.existsSync(baseDirectory) === true) { fs.rmSync(baseDirectory, { recursive: true }) } @@ -93,7 +96,7 @@ function readWriteFiles ( fs.rmSync(baseDirectory, { recursive: true }) } -export function executeWorkerFunction (data) { +export const executeWorkerFunction = data => { switch (data.function) { case WorkerFunctions.jsonIntegerSerialization: return jsonIntegerSerialization(data.taskSize || 1000) @@ -108,7 +111,7 @@ export function executeWorkerFunction (data) { } } -export function buildPool (workerType, poolType, poolSize, poolOptions) { +export const buildPool = (workerType, poolType, poolSize, poolOptions) => { switch (poolType) { case PoolTypes.fixed: switch (workerType) { diff --git a/tests/pools/cluster/dynamic.test.js b/tests/pools/cluster/dynamic.test.js index ed634083..78bdc214 100644 --- a/tests/pools/cluster/dynamic.test.js +++ b/tests/pools/cluster/dynamic.test.js @@ -1,7 +1,7 @@ const { expect } = require('expect') const { DynamicClusterPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') -const TestUtils = require('../../test-utils') +const { sleep, waitWorkerEvents } = require('../../test-utils') describe('Dynamic cluster pool test suite', () => { const min = 1 @@ -37,11 +37,7 @@ describe('Dynamic cluster pool test suite', () => { // The `busy` event is triggered when the number of submitted tasks at once reach the max number of workers in the dynamic pool. // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool. expect(poolBusy).toBe(max + 1) - const numberOfExitEvents = await TestUtils.waitWorkerEvents( - pool, - 'exit', - max - min - ) + const numberOfExitEvents = await waitWorkerEvents(pool, 'exit', max - min) expect(numberOfExitEvents).toBe(max - min) }) @@ -51,18 +47,18 @@ describe('Dynamic cluster pool test suite', () => { pool.execute() } expect(pool.workerNodes.length).toBeGreaterThan(min) - await TestUtils.waitWorkerEvents(pool, 'exit', max - min) + await waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) for (let i = 0; i < max * 2; i++) { pool.execute() } expect(pool.workerNodes.length).toBeGreaterThan(min) - await TestUtils.waitWorkerEvents(pool, 'exit', max - min) + await waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerEvents(pool, 'exit', min) + const exitPromise = waitWorkerEvents(pool, 'exit', min) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(min) @@ -102,7 +98,7 @@ describe('Dynamic cluster pool test suite', () => { longRunningPool.execute() } expect(longRunningPool.workerNodes.length).toBe(max) - await TestUtils.waitWorkerEvents(longRunningPool, 'exit', max - min) + await waitWorkerEvents(longRunningPool, 'exit', max - min) expect(longRunningPool.workerNodes.length).toBe(min) expect( longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get( @@ -129,7 +125,7 @@ describe('Dynamic cluster pool test suite', () => { longRunningPool.execute() } expect(longRunningPool.workerNodes.length).toBe(max) - await TestUtils.sleep(1500) + await sleep(1500) // Here we expect the workerNodes to be at the max size since the task is still executing expect(longRunningPool.workerNodes.length).toBe(max) // We need to clean up the resources after our test diff --git a/tests/pools/cluster/fixed.test.js b/tests/pools/cluster/fixed.test.js index ccdd2870..48455f18 100644 --- a/tests/pools/cluster/fixed.test.js +++ b/tests/pools/cluster/fixed.test.js @@ -1,7 +1,7 @@ const { expect } = require('expect') const { FixedClusterPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') -const TestUtils = require('../../test-utils') +const { waitWorkerEvents } = require('../../test-utils') describe('Fixed cluster pool test suite', () => { const numberOfWorkers = 6 @@ -195,11 +195,7 @@ describe('Fixed cluster pool test suite', () => { }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerEvents( - pool, - 'exit', - numberOfWorkers - ) + const exitPromise = waitWorkerEvents(pool, 'exit', numberOfWorkers) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(numberOfWorkers) diff --git a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js index b21c41ff..7cdd327b 100644 --- a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js +++ b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js @@ -4,7 +4,7 @@ const { FixedThreadPool } = require('../../../lib') const { WeightedRoundRobinWorkerChoiceStrategy } = require('../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy') -const TestUtils = require('../../test-utils') +const { generateRandomInteger } = require('../../test-utils') describe('Weighted round robin strategy worker choice strategy test suite', () => { // const min = 1 @@ -25,11 +25,8 @@ describe('Weighted round robin strategy worker choice strategy test suite', () = it('Verify that reset() resets internals', () => { const strategy = new WeightedRoundRobinWorkerChoiceStrategy(pool) - strategy.currentWorkerId = TestUtils.generateRandomInteger( - Number.MAX_SAFE_INTEGER, - 1 - ) - strategy.workerVirtualTaskRunTime = TestUtils.generateRandomInteger( + strategy.currentWorkerId = generateRandomInteger(Number.MAX_SAFE_INTEGER, 1) + strategy.workerVirtualTaskRunTime = generateRandomInteger( Number.MAX_SAFE_INTEGER, 1 ) diff --git a/tests/pools/thread/dynamic.test.js b/tests/pools/thread/dynamic.test.js index 11c99593..1de66446 100644 --- a/tests/pools/thread/dynamic.test.js +++ b/tests/pools/thread/dynamic.test.js @@ -1,7 +1,7 @@ const { expect } = require('expect') const { DynamicThreadPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') -const TestUtils = require('../../test-utils') +const { sleep, waitWorkerEvents } = require('../../test-utils') describe('Dynamic thread pool test suite', () => { const min = 1 @@ -37,11 +37,7 @@ describe('Dynamic thread pool test suite', () => { // The `busy` event is triggered when the number of submitted tasks at once reach the max number of workers in the dynamic pool. // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool. expect(poolBusy).toBe(max + 1) - const numberOfExitEvents = await TestUtils.waitWorkerEvents( - pool, - 'exit', - max - min - ) + const numberOfExitEvents = await waitWorkerEvents(pool, 'exit', max - min) expect(numberOfExitEvents).toBe(max - min) }) @@ -51,18 +47,18 @@ describe('Dynamic thread pool test suite', () => { pool.execute() } expect(pool.workerNodes.length).toBe(max) - await TestUtils.waitWorkerEvents(pool, 'exit', max - min) + await waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) for (let i = 0; i < max * 2; i++) { pool.execute() } expect(pool.workerNodes.length).toBe(max) - await TestUtils.waitWorkerEvents(pool, 'exit', max - min) + await waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerEvents(pool, 'exit', min) + const exitPromise = waitWorkerEvents(pool, 'exit', min) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(min) @@ -102,7 +98,7 @@ describe('Dynamic thread pool test suite', () => { longRunningPool.execute() } expect(longRunningPool.workerNodes.length).toBe(max) - await TestUtils.waitWorkerEvents(longRunningPool, 'exit', max - min) + await waitWorkerEvents(longRunningPool, 'exit', max - min) expect(longRunningPool.workerNodes.length).toBe(min) expect( longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get( @@ -129,7 +125,7 @@ describe('Dynamic thread pool test suite', () => { longRunningPool.execute() } expect(longRunningPool.workerNodes.length).toBe(max) - await TestUtils.sleep(1500) + await sleep(1500) // Here we expect the workerNodes to be at the max size since the task is still executing expect(longRunningPool.workerNodes.length).toBe(max) // We need to clean up the resources after our test diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index d0e31bab..45197cba 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -1,7 +1,7 @@ const { expect } = require('expect') const { FixedThreadPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') -const TestUtils = require('../../test-utils') +const { waitWorkerEvents } = require('../../test-utils') describe('Fixed thread pool test suite', () => { const numberOfThreads = 6 @@ -199,11 +199,7 @@ describe('Fixed thread pool test suite', () => { }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerEvents( - pool, - 'exit', - numberOfThreads - ) + const exitPromise = waitWorkerEvents(pool, 'exit', numberOfThreads) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(numberOfThreads) diff --git a/tests/test-utils.js b/tests/test-utils.js index ceaff7be..0014a791 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -1,114 +1,122 @@ const { WorkerFunctions } = require('./test-types') -class TestUtils { - static async waitWorkerEvents (pool, workerEvent, numberOfEventsToWait) { - return new Promise(resolve => { - let events = 0 - if (numberOfEventsToWait === 0) { - resolve(events) - } - for (const workerNode of pool.workerNodes) { - workerNode.worker.on(workerEvent, () => { - ++events - if (events === numberOfEventsToWait) { - resolve(events) - } - }) - } - }) - } - - static async waitPoolEvents (pool, poolEvent, numberOfEventsToWait) { - return new Promise(resolve => { - let events = 0 - if (numberOfEventsToWait === 0) { - resolve(events) - } - pool.emitter.on(poolEvent, () => { +const waitWorkerEvents = async (pool, workerEvent, numberOfEventsToWait) => { + return new Promise(resolve => { + let events = 0 + if (numberOfEventsToWait === 0) { + resolve(events) + } + for (const workerNode of pool.workerNodes) { + workerNode.worker.on(workerEvent, () => { ++events if (events === numberOfEventsToWait) { resolve(events) } }) + } + }) +} + +const waitPoolEvents = async (pool, poolEvent, numberOfEventsToWait) => { + return new Promise(resolve => { + let events = 0 + if (numberOfEventsToWait === 0) { + resolve(events) + } + pool.emitter.on(poolEvent, () => { + ++events + if (events === numberOfEventsToWait) { + resolve(events) + } }) - } + }) +} - static async sleep (ms) { - return new Promise(resolve => setTimeout(resolve, ms)) - } +const sleep = async ms => { + return new Promise(resolve => setTimeout(resolve, ms)) +} - static async sleepWorkerFunction ( - data, - ms, - rejection = false, - rejectionMessage = '' - ) { - return new Promise((resolve, reject) => { - setTimeout( - () => - rejection === true - ? reject(new Error(rejectionMessage)) - : resolve(data), - ms - ) - }) - } +const sleepWorkerFunction = async ( + data, + ms, + rejection = false, + rejectionMessage = '' +) => { + return new Promise((resolve, reject) => { + setTimeout( + () => + rejection === true + ? reject(new Error(rejectionMessage)) + : resolve(data), + ms + ) + }) +} - static generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) { - if (max < min || max < 0 || min < 0) { - throw new RangeError('Invalid interval') - } - max = Math.floor(max) - if (min != null && min !== 0) { - min = Math.ceil(min) - return Math.floor(Math.random() * (max - min + 1)) + min - } - return Math.floor(Math.random() * (max + 1)) +const generateRandomInteger = (max = Number.MAX_SAFE_INTEGER, min = 0) => { + if (max < min || max < 0 || min < 0) { + throw new RangeError('Invalid interval') } + max = Math.floor(max) + if (min != null && min !== 0) { + min = Math.ceil(min) + return Math.floor(Math.random() * (max - min + 1)) + min + } + return Math.floor(Math.random() * (max + 1)) +} - static jsonIntegerSerialization (n) { - for (let i = 0; i < n; i++) { - const o = { - a: i - } - JSON.stringify(o) +const jsonIntegerSerialization = n => { + for (let i = 0; i < n; i++) { + const o = { + a: i } + JSON.stringify(o) } +} - /** - * Intentionally inefficient implementation. - * @param {number} n - The number of fibonacci numbers to generate. - * @returns {number} - The nth fibonacci number. - */ - static fibonacci (n) { - if (n <= 1) return n - return TestUtils.fibonacci(n - 1) + TestUtils.fibonacci(n - 2) - } +/** + * Intentionally inefficient implementation. + * @param {number} n - The number of fibonacci numbers to generate. + * @returns {number} - The nth fibonacci number. + */ +const fibonacci = n => { + if (n <= 1) return n + return fibonacci(n - 1) + fibonacci(n - 2) +} - /** - * Intentionally inefficient implementation. - * @param {number} n - The number to calculate the factorial of. - * @returns {number} - The factorial of n. - */ - static factorial (n) { - if (n === 0) { - return 1 - } - return TestUtils.factorial(n - 1) * n +/** + * Intentionally inefficient implementation. + * @param {number} n - The number to calculate the factorial of. + * @returns {number} - The factorial of n. + */ +const factorial = n => { + if (n === 0) { + return 1 } + return factorial(n - 1) * n +} - static executeWorkerFunction (data) { - switch (data.function) { - case WorkerFunctions.jsonIntegerSerialization: - return TestUtils.jsonIntegerSerialization(data.n || 100) - case WorkerFunctions.fibonacci: - return TestUtils.fibonacci(data.n || 25) - case WorkerFunctions.factorial: - return TestUtils.factorial(data.n || 100) - default: - throw new Error('Unknown worker function') - } +const executeWorkerFunction = data => { + switch (data.function) { + case WorkerFunctions.jsonIntegerSerialization: + return jsonIntegerSerialization(data.n || 100) + case WorkerFunctions.fibonacci: + return fibonacci(data.n || 25) + case WorkerFunctions.factorial: + return factorial(data.n || 100) + default: + throw new Error('Unknown worker function') } } -module.exports = TestUtils +module.exports = { + executeWorkerFunction, + factorial, + fibonacci, + generateRandomInteger, + jsonIntegerSerialization, + sleep, + sleepWorkerFunction, + waitWorkerEvents, + waitPoolEvents +} diff --git a/tests/worker-files/cluster/asyncErrorWorker.js b/tests/worker-files/cluster/asyncErrorWorker.js index fba8423f..0536e83b 100644 --- a/tests/worker-files/cluster/asyncErrorWorker.js +++ b/tests/worker-files/cluster/asyncErrorWorker.js @@ -1,9 +1,9 @@ 'use strict' const { ClusterWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function error (data) { - return TestUtils.sleepWorkerFunction( + return sleepWorkerFunction( data, 2000, true, diff --git a/tests/worker-files/cluster/asyncWorker.js b/tests/worker-files/cluster/asyncWorker.js index c9bcc892..2460c20d 100644 --- a/tests/worker-files/cluster/asyncWorker.js +++ b/tests/worker-files/cluster/asyncWorker.js @@ -1,9 +1,9 @@ 'use strict' const { ClusterWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 2000) + return sleepWorkerFunction(data, 2000) } module.exports = new ClusterWorker(sleep, { diff --git a/tests/worker-files/cluster/longRunningWorkerHardBehavior.js b/tests/worker-files/cluster/longRunningWorkerHardBehavior.js index cb92fcaf..e308eb5c 100644 --- a/tests/worker-files/cluster/longRunningWorkerHardBehavior.js +++ b/tests/worker-files/cluster/longRunningWorkerHardBehavior.js @@ -1,9 +1,9 @@ 'use strict' const { ClusterWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 50000) + return sleepWorkerFunction(data, 50000) } module.exports = new ClusterWorker(sleep, { diff --git a/tests/worker-files/cluster/longRunningWorkerSoftBehavior.js b/tests/worker-files/cluster/longRunningWorkerSoftBehavior.js index c9515a33..208e5ba2 100644 --- a/tests/worker-files/cluster/longRunningWorkerSoftBehavior.js +++ b/tests/worker-files/cluster/longRunningWorkerSoftBehavior.js @@ -1,9 +1,9 @@ 'use strict' const { ClusterWorker } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 50000) + return sleepWorkerFunction(data, 50000) } module.exports = new ClusterWorker(sleep, { diff --git a/tests/worker-files/cluster/testWorker.js b/tests/worker-files/cluster/testWorker.js index 0d0611d0..e79a2102 100644 --- a/tests/worker-files/cluster/testWorker.js +++ b/tests/worker-files/cluster/testWorker.js @@ -1,13 +1,13 @@ 'use strict' const { isMaster } = require('cluster') const { ClusterWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { executeWorkerFunction } = require('../../test-utils') const { WorkerFunctions } = require('../../test-types') function test (data) { data = data || {} data.function = data.function || WorkerFunctions.jsonIntegerSerialization - const result = TestUtils.executeWorkerFunction(data) + const result = executeWorkerFunction(data) if (result == null) { return isMaster } diff --git a/tests/worker-files/thread/asyncErrorWorker.js b/tests/worker-files/thread/asyncErrorWorker.js index 10789823..6bc0ae6b 100644 --- a/tests/worker-files/thread/asyncErrorWorker.js +++ b/tests/worker-files/thread/asyncErrorWorker.js @@ -1,9 +1,9 @@ 'use strict' const { ThreadWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function error (data) { - return TestUtils.sleepWorkerFunction( + return sleepWorkerFunction( data, 2000, true, diff --git a/tests/worker-files/thread/asyncWorker.js b/tests/worker-files/thread/asyncWorker.js index d5d9b310..5e3ec257 100644 --- a/tests/worker-files/thread/asyncWorker.js +++ b/tests/worker-files/thread/asyncWorker.js @@ -1,9 +1,9 @@ 'use strict' const { ThreadWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 2000) + return sleepWorkerFunction(data, 2000) } module.exports = new ThreadWorker(sleep, { diff --git a/tests/worker-files/thread/longRunningWorkerHardBehavior.js b/tests/worker-files/thread/longRunningWorkerHardBehavior.js index 791853e3..d81f7f90 100644 --- a/tests/worker-files/thread/longRunningWorkerHardBehavior.js +++ b/tests/worker-files/thread/longRunningWorkerHardBehavior.js @@ -1,9 +1,9 @@ 'use strict' const { ThreadWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 50000) + return sleepWorkerFunction(data, 50000) } module.exports = new ThreadWorker(sleep, { diff --git a/tests/worker-files/thread/longRunningWorkerSoftBehavior.js b/tests/worker-files/thread/longRunningWorkerSoftBehavior.js index 8adb43a7..eda5a405 100644 --- a/tests/worker-files/thread/longRunningWorkerSoftBehavior.js +++ b/tests/worker-files/thread/longRunningWorkerSoftBehavior.js @@ -1,9 +1,9 @@ 'use strict' const { ThreadWorker } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { sleepWorkerFunction } = require('../../test-utils') async function sleep (data) { - return TestUtils.sleepWorkerFunction(data, 50000) + return sleepWorkerFunction(data, 50000) } module.exports = new ThreadWorker(sleep, { diff --git a/tests/worker-files/thread/testWorker.js b/tests/worker-files/thread/testWorker.js index 668587db..349336e5 100644 --- a/tests/worker-files/thread/testWorker.js +++ b/tests/worker-files/thread/testWorker.js @@ -1,13 +1,13 @@ 'use strict' const { isMainThread } = require('worker_threads') const { ThreadWorker, KillBehaviors } = require('../../../lib') -const TestUtils = require('../../test-utils') +const { executeWorkerFunction } = require('../../test-utils') const { WorkerFunctions } = require('../../test-types') function test (data) { data = data || {} data.function = data.function || WorkerFunctions.jsonIntegerSerialization - const result = TestUtils.executeWorkerFunction(data) + const result = executeWorkerFunction(data) if (result == null) { return isMainThread }