11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// This test verifies that `--trace-gc` flag is well integrated. 41cb0ef41Sopenharmony_ci// We'll check here, that the console outputs gc events properly. 51cb0ef41Sopenharmony_cirequire('../common'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci{ 131cb0ef41Sopenharmony_ci const childProcess = spawnSync(process.execPath, [ 141cb0ef41Sopenharmony_ci '--trace-gc', 151cb0ef41Sopenharmony_ci '--expose-gc', 161cb0ef41Sopenharmony_ci fixtures.path('gc.js'), 171cb0ef41Sopenharmony_ci ]); 181cb0ef41Sopenharmony_ci const output = childProcess.stdout.toString().trim(); 191cb0ef41Sopenharmony_ci const lines = splitByLine(output); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci const scavengeRegex = /\bScavenge\b/; 221cb0ef41Sopenharmony_ci const expectedOutput = [ 231cb0ef41Sopenharmony_ci scavengeRegex, 241cb0ef41Sopenharmony_ci scavengeRegex, 251cb0ef41Sopenharmony_ci scavengeRegex, 261cb0ef41Sopenharmony_ci scavengeRegex, 271cb0ef41Sopenharmony_ci /\bMark-sweep\b/, 281cb0ef41Sopenharmony_ci ]; 291cb0ef41Sopenharmony_ci lines.forEach((line, index) => { 301cb0ef41Sopenharmony_ci assert.match(line, expectedOutput[index]); 311cb0ef41Sopenharmony_ci }); 321cb0ef41Sopenharmony_ci} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci/** 351cb0ef41Sopenharmony_ci * HELPERS 361cb0ef41Sopenharmony_ci */ 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cifunction splitByLine(str) { 391cb0ef41Sopenharmony_ci return str.split(/\n/); 401cb0ef41Sopenharmony_ci} 41