mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 14:33:11 +01:00
fb91ee4f26
PR-URL: https://github.com/nodejs/node/pull/45579 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
831 B
JavaScript
37 lines
831 B
JavaScript
'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/;
|
|
const eofRegex = /\bMark-Compact\b/;
|
|
|
|
lines.forEach((line, index) => {
|
|
const expected = index !== lines.length - 1 ? scavengeRegex : eofRegex;
|
|
assert.match(line, expected);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* HELPERS
|
|
*/
|
|
|
|
function splitByLine(str) {
|
|
return str.split(/\n/);
|
|
}
|