-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-trace-gc-flag.js
More file actions
36 lines (28 loc) · 831 Bytes
/
test-trace-gc-flag.js
File metadata and controls
36 lines (28 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'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/);
}