mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 03:31:35 +00:00

Add support for metadata events. At this point they are added to the main buffer. Emit a metadata event for the main thread. PR-URL: https://github.com/nodejs/node/pull/20757 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
const names = [
|
|
'ContextifyScript::New',
|
|
'RunInThisContext',
|
|
'RunInContext'
|
|
];
|
|
|
|
if (process.argv[2] === 'child') {
|
|
const vm = require('vm');
|
|
vm.runInNewContext('1 + 1');
|
|
} else {
|
|
tmpdir.refresh();
|
|
process.chdir(tmpdir.path);
|
|
|
|
const proc = cp.fork(__filename,
|
|
[ 'child' ], {
|
|
execArgv: [
|
|
'--trace-event-categories',
|
|
'node.vm.script'
|
|
]
|
|
});
|
|
|
|
proc.once('exit', common.mustCall(() => {
|
|
const file = path.join(tmpdir.path, 'node_trace.1.log');
|
|
|
|
assert(common.fileExists(file));
|
|
fs.readFile(file, common.mustCall((err, data) => {
|
|
const traces = JSON.parse(data.toString()).traceEvents
|
|
.filter((trace) => trace.cat !== '__metadata');
|
|
traces.forEach((trace) => {
|
|
assert.strictEqual(trace.pid, proc.pid);
|
|
assert(names.includes(trace.name));
|
|
});
|
|
}));
|
|
}));
|
|
}
|