2022-03-28 20:15:08 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// This test verifies that `--trace-gc` flag is well integrated.
|
|
|
|
// We'll check here, that the console outputs gc events properly.
|
|
|
|
require('../common');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const { spawnSync } = require('child_process');
|
|
|
|
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
|
|
|
|
{
|
|
|
|
const childProcess = spawnSync(process.execPath, [
|
|
|
|
'--trace-gc',
|
|
|
|
'--expose-gc',
|
|
|
|
fixtures.path('gc.js'),
|
|
|
|
]);
|
|
|
|
const output = childProcess.stdout.toString().trim();
|
|
|
|
const lines = splitByLine(output);
|
|
|
|
|
|
|
|
const scavengeRegex = /\bScavenge\b/;
|
2022-11-26 21:33:00 +00:00
|
|
|
const eofRegex = /\bMark-Compact\b/;
|
|
|
|
|
2022-03-28 20:15:08 +00:00
|
|
|
lines.forEach((line, index) => {
|
2022-11-26 21:33:00 +00:00
|
|
|
const expected = index !== lines.length - 1 ? scavengeRegex : eofRegex;
|
|
|
|
assert.match(line, expected);
|
2022-03-28 20:15:08 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HELPERS
|
|
|
|
*/
|
|
|
|
|
|
|
|
function splitByLine(str) {
|
|
|
|
return str.split(/\n/);
|
|
|
|
}
|