• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// This tests that --heap-prof, --heap-prof-dir and --heap-prof-name works.
4
5const common = require('../common');
6
7const fixtures = require('../common/fixtures');
8common.skipIfInspectorDisabled();
9
10const assert = require('assert');
11const fs = require('fs');
12const path = require('path');
13const { spawnSync } = require('child_process');
14
15const tmpdir = require('../common/tmpdir');
16
17const {
18  getHeapProfiles,
19  verifyFrames,
20  kHeapProfInterval,
21  env
22} = require('../common/prof');
23
24// Tests absolute --heap-prof-dir
25{
26  tmpdir.refresh();
27  const dir = path.join(tmpdir.path, 'prof');
28  const output = spawnSync(process.execPath, [
29    '--heap-prof',
30    '--heap-prof-dir',
31    dir,
32    '--heap-prof-interval',
33    kHeapProfInterval,
34    fixtures.path('workload', 'allocation.js'),
35  ], {
36    cwd: tmpdir.path,
37    env
38  });
39  if (output.status !== 0) {
40    console.log(output.stderr.toString());
41  }
42  assert.strictEqual(output.status, 0);
43  assert(fs.existsSync(dir));
44  const profiles = getHeapProfiles(dir);
45  assert.strictEqual(profiles.length, 1);
46  verifyFrames(output, profiles[0], 'runAllocation');
47}
48