• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests --heap-prof generates a heap profile when
4// process.kill(process.pid, "SIGINT"); exits 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-sigint.js'),
30  ], {
31    cwd: tmpdir.path,
32    env
33  });
34  if (!common.isWindows) {
35    if (output.signal !== 'SIGINT') {
36      console.log(output.stderr.toString());
37    }
38    assert.strictEqual(output.signal, 'SIGINT');
39  }
40  const profiles = getHeapProfiles(tmpdir.path);
41  assert.strictEqual(profiles.length, 1);
42  verifyFrames(output, profiles[0], 'runAllocation');
43}
44