From 602fe4e83a572359c08c3a28fe054addb4252153 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 0c8327a64f3c85..86eb9d9d0d232f 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/debugger'); 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();