|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Refs: https://github.com/nodejs/node/issues/39555 |
| 5 | + |
| 6 | +// After this issue is fixed, this can perhaps be integrated into |
| 7 | +// test/sequential/test-debugger-heap-profiler.js as it shares almost all |
| 8 | +// the same code. |
| 9 | + |
| 10 | +// These skips should be uncommented once the issue is fixed. |
| 11 | +// common.skipIfInspectorDisabled(); |
| 12 | + |
| 13 | +// if (!common.isMainThread) { |
| 14 | +// common.skip('process.chdir() is not available in workers'); |
| 15 | +// } |
| 16 | + |
| 17 | +// This assert.fail() can be removed once the issue is fixed. |
| 18 | +if (!common.hasCrypto || !process.features.inspector) { |
| 19 | + require('assert').fail('crypto is not available'); |
| 20 | +} |
| 21 | + |
| 22 | +const fixtures = require('../common/fixtures'); |
| 23 | +const startCLI = require('../common/debugger'); |
| 24 | +const tmpdir = require('../common/tmpdir'); |
| 25 | + |
| 26 | +tmpdir.refresh(); |
| 27 | +process.chdir(tmpdir.path); |
| 28 | + |
| 29 | +const { readFileSync } = require('fs'); |
| 30 | + |
| 31 | +const filename = 'node.heapsnapshot'; |
| 32 | + |
| 33 | +// Check that two simultaneous snapshots don't step all over each other. |
| 34 | +{ |
| 35 | + const cli = startCLI([fixtures.path('debugger/empty.js')]); |
| 36 | + |
| 37 | + function onFatal(error) { |
| 38 | + cli.quit(); |
| 39 | + throw error; |
| 40 | + } |
| 41 | + |
| 42 | + return cli.waitForInitialBreak() |
| 43 | + .then(() => cli.waitForPrompt()) |
| 44 | + .then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()')) |
| 45 | + .then(() => JSON.parse(readFileSync(filename, 'utf8'))) |
| 46 | + .then(() => cli.quit()) |
| 47 | + .then(null, onFatal); |
| 48 | +} |
0 commit comments