1'use strict';
2
3// Tests --heap-prof generates a heap profile when process.exit(55) exits
4// process.
5
6const common = require('../common');
7
8const fixtures = require('../common/fixtures');
9common.skipIfInspectorDisabled();
10
11const assert = require('assert');
12const { spawnSync } = require('child_process');
13
14const tmpdir = require('../common/tmpdir');
15
16const {
17  getHeapProfiles,
18  verifyFrames,
19  kHeapProfInterval,
20  env
21} = require('../common/prof');
22
23{
24  tmpdir.refresh();
25  const output = spawnSync(process.execPath, [
26    '--heap-prof',
27    '--heap-prof-interval',
28    kHeapProfInterval,
29    fixtures.path('workload', 'allocation-exit.js'),
30  ], {
31    cwd: tmpdir.path,
32    env
33  });
34  if (output.status !== 55) {
35    console.log(output.stderr.toString());
36  }
37  assert.strictEqual(output.status, 55);
38  const profiles = getHeapProfiles(tmpdir.path);
39  assert.strictEqual(profiles.length, 1);
40  verifyFrames(output, profiles[0], 'runAllocation');
41}
42