From e12164e88da6d6b3d644625502b7397e88dd91b4 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 6 Aug 2021 12:59:28 -0400 Subject: [PATCH] test: fix test-debugger-heap-profiler for workers Fix `sequential/test-debugger-heap-profiler` so that it can be run in a worker thread. `process.chdir()` is not allowed in worker threads but passing a current working directory into a spawned child process is allowed. PR-URL: https://github.com/nodejs/node/pull/39687 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/sequential/test-debugger-heap-profiler.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/sequential/test-debugger-heap-profiler.js b/test/sequential/test-debugger-heap-profiler.js index 69be07a6f9c517..d69869a78db1b8 100644 --- a/test/sequential/test-debugger-heap-profiler.js +++ b/test/sequential/test-debugger-heap-profiler.js @@ -3,24 +3,21 @@ const common = require('../common'); common.skipIfInspectorDisabled(); -if (!common.isMainThread) { - common.skip('process.chdir() is not available in workers'); -} - const fixtures = require('../common/fixtures'); const startCLI = require('../common/inspector-cli'); const tmpdir = require('../common/tmpdir'); +const path = require('path'); tmpdir.refresh(); -process.chdir(tmpdir.path); const { readFileSync } = require('fs'); -const filename = 'node.heapsnapshot'; +const filename = path.join(tmpdir.path, 'node.heapsnapshot'); // Heap profiler take snapshot. { - const cli = startCLI([fixtures.path('debugger/empty.js')]); + const opts = { cwd: tmpdir.path }; + const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts); function onFatal(error) { cli.quit();