1'use strict'; 2 3// This test verifies that `--trace-gc` flag is well integrated. 4// We'll check here, that the console outputs gc events properly. 5require('../common'); 6 7const assert = require('assert'); 8const { spawnSync } = require('child_process'); 9 10const fixtures = require('../common/fixtures'); 11 12{ 13 const childProcess = spawnSync(process.execPath, [ 14 '--trace-gc', 15 '--expose-gc', 16 fixtures.path('gc.js'), 17 ]); 18 const output = childProcess.stdout.toString().trim(); 19 const lines = splitByLine(output); 20 21 const scavengeRegex = /\bScavenge\b/; 22 const expectedOutput = [ 23 scavengeRegex, 24 scavengeRegex, 25 scavengeRegex, 26 scavengeRegex, 27 /\bMark-sweep\b/, 28 ]; 29 lines.forEach((line, index) => { 30 assert.match(line, expectedOutput[index]); 31 }); 32} 33 34/** 35 * HELPERS 36 */ 37 38function splitByLine(str) { 39 return str.split(/\n/); 40} 41