From 88f3be7bd4461a17f55d8a316038f080dfaea713 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Fri, 28 Jan 2022 22:49:15 +0200 Subject: [PATCH] test: tmpdir include build id --- test/common/tmpdir.js | 1 + .../sequential/test-debugger-heap-profiler.js | 38 ------------------- .../test-debugger-heap-profiler.mjs | 36 ++++++++++++++++++ 3 files changed, 37 insertions(+), 38 deletions(-) delete mode 100644 test/sequential/test-debugger-heap-profiler.js create mode 100644 test/sequential/test-debugger-heap-profiler.mjs diff --git a/test/common/tmpdir.js b/test/common/tmpdir.js index 0bafea1582b38d..cd78373f2be45e 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -14,6 +14,7 @@ const testRoot = process.env.NODE_TEST_DIR ? // Using a `.` prefixed name, which is the convention for "hidden" on POSIX, // gets tools to ignore it by default or by simple rules, especially eslint. const tmpdirName = '.tmp.' + + (process.env.BUILD_ID || process.pid + '.') + (process.env.TEST_SERIAL_ID || process.env.TEST_THREAD_ID || '0'); const tmpPath = path.join(testRoot, tmpdirName); diff --git a/test/sequential/test-debugger-heap-profiler.js b/test/sequential/test-debugger-heap-profiler.js deleted file mode 100644 index 86eb9d9d0d232f..00000000000000 --- a/test/sequential/test-debugger-heap-profiler.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; -const common = require('../common'); - -common.skipIfInspectorDisabled(); - -const fixtures = require('../common/fixtures'); -const startCLI = require('../common/debugger'); -const tmpdir = require('../common/tmpdir'); -const path = require('path'); - -tmpdir.refresh(); - -const { readFileSync } = require('fs'); - -const filename = path.join(tmpdir.path, 'node.heapsnapshot'); - -// Heap profiler take snapshot. -{ - const opts = { cwd: tmpdir.path }; - const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts); - - function onFatal(error) { - cli.quit(); - throw error; - } - - // Check that the snapshot is valid JSON. - return cli.waitForInitialBreak() - .then(() => cli.waitForPrompt()) - .then(() => cli.command('takeHeapSnapshot()')) - .then(() => JSON.parse(readFileSync(filename, 'utf8'))) - // Check that two simultaneous snapshots don't step all over each other. - // Refs: https://github.com/nodejs/node/issues/39555 - .then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()')) - .then(() => JSON.parse(readFileSync(filename, 'utf8'))) - .then(() => cli.quit()) - .then(null, onFatal); -} diff --git a/test/sequential/test-debugger-heap-profiler.mjs b/test/sequential/test-debugger-heap-profiler.mjs new file mode 100644 index 00000000000000..1e798b1beb6b4f --- /dev/null +++ b/test/sequential/test-debugger-heap-profiler.mjs @@ -0,0 +1,36 @@ +import { skipIfInspectorDisabled } from '../common/index.mjs'; +import { createRequire } from 'module'; +import path from 'path'; + +const require = createRequire(import.meta.url); +const fixtures = require('../common/fixtures'); +const startCLI = require('../common/debugger'); +const tmpdir = require('../common/tmpdir'); + +skipIfInspectorDisabled(); + +tmpdir.refresh(); + +const { readFileSync } = require('fs'); + +const filename = path.join(tmpdir.path, 'node.heapsnapshot'); + +// Heap profiler take snapshot. +const opts = { cwd: tmpdir.path }; +const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts); + +try { + // Check that the snapshot is valid JSON. + await cli.waitForInitialBreak(); + await cli.waitForPrompt(); + await cli.command('takeHeapSnapshot()'); + await JSON.parse(readFileSync(filename, 'utf8')); + // Check that two simultaneous snapshots don't step all over each other. + // Refs: https://github.com/nodejs/node/issues/39555 + await cli.command('takeHeapSnapshot(); takeHeapSnapshot()'); + await JSON.parse(readFileSync(filename, 'utf8')); + await cli.quit(); +} catch (e) { + cli.quit(); + throw e; +}