1'use strict'; 2 3// Tests that --heap-prof outputs heap profile when event loop is drained. 4 5const common = require('../common'); 6 7const fixtures = require('../common/fixtures'); 8common.skipIfInspectorDisabled(); 9 10const assert = require('assert'); 11const { spawnSync } = require('child_process'); 12 13const tmpdir = require('../common/tmpdir'); 14 15const { 16 getHeapProfiles, 17 verifyFrames, 18 kHeapProfInterval, 19 env, 20} = require('../common/prof'); 21 22{ 23 tmpdir.refresh(); 24 const output = spawnSync(process.execPath, [ 25 '--heap-prof', 26 '--heap-prof-interval', 27 kHeapProfInterval, 28 fixtures.path('workload', 'allocation.js'), 29 ], { 30 cwd: tmpdir.path, 31 env 32 }); 33 if (output.status !== 0) { 34 console.log(output.stderr.toString()); 35 console.log(output); 36 } 37 assert.strictEqual(output.status, 0); 38 const profiles = getHeapProfiles(tmpdir.path); 39 assert.strictEqual(profiles.length, 1); 40 verifyFrames(output, profiles[0], 'runAllocation'); 41} 42