• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests --heap-prof-dir and --heap-prof-name work together.
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{
25  tmpdir.refresh();
26  const dir = path.join(tmpdir.path, 'prof');
27  const file = path.join(dir, 'test.heapprofile');
28  const output = spawnSync(process.execPath, [
29    '--heap-prof',
30    '--heap-prof-name',
31    'test.heapprofile',
32    '--heap-prof-dir',
33    dir,
34    '--heap-prof-interval',
35    kHeapProfInterval,
36    fixtures.path('workload', 'allocation.js'),
37  ], {
38    cwd: tmpdir.path,
39    env
40  });
41  if (output.status !== 0) {
42    console.log(output.stderr.toString());
43  }
44  assert.strictEqual(output.status, 0);
45  assert(fs.existsSync(dir));
46  const profiles = getHeapProfiles(dir);
47  assert.deepStrictEqual(profiles, [file]);
48  verifyFrames(output, file, 'runAllocation');
49}
50