1'use strict'; 2 3// Tests --heap-prof-name works. 4 5const common = require('../common'); 6 7const fixtures = require('../common/fixtures'); 8common.skipIfInspectorDisabled(); 9 10const assert = require('assert'); 11const path = require('path'); 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 file = path.join(tmpdir.path, 'test.heapprofile'); 26 const output = spawnSync(process.execPath, [ 27 '--heap-prof', 28 '--heap-prof-name', 29 'test.heapprofile', 30 '--heap-prof-interval', 31 kHeapProfInterval, 32 fixtures.path('workload', 'allocation.js'), 33 ], { 34 cwd: tmpdir.path, 35 env 36 }); 37 if (output.status !== 0) { 38 console.log(output.stderr.toString()); 39 } 40 assert.strictEqual(output.status, 0); 41 const profiles = getHeapProfiles(tmpdir.path); 42 assert.deepStrictEqual(profiles, [file]); 43 verifyFrames(output, file, 'runAllocation'); 44} 45