1'use strict';
2
3// Tests --heap-prof generates a heap profile from worker
4// when execArgv is set.
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} = require('../common/prof');
20
21{
22  tmpdir.refresh();
23  const output = spawnSync(process.execPath, [
24    fixtures.path('workload', 'allocation-worker-argv.js'),
25  ], {
26    cwd: tmpdir.path,
27    env: {
28      ...process.env,
29      HEAP_PROF_INTERVAL: '128'
30    }
31  });
32  if (output.status !== 0) {
33    console.log(output.stderr.toString());
34  }
35  assert.strictEqual(output.status, 0);
36  const profiles = getHeapProfiles(tmpdir.path);
37  assert.strictEqual(profiles.length, 1);
38  verifyFrames(output, profiles[0], 'runAllocation');
39}
40