node/test/parallel/test-trace-events-none.js
Ali Ijaz Sheikh 3ff723f940 src: trace_events: support for metadata events
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>
2018-05-18 10:42:35 -07:00

28 lines
814 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
process.chdir(tmpdir.path);
const proc_no_categories = cp.spawn(
process.execPath,
[ '--trace-event-categories', '""', '-e', CODE ]
);
proc_no_categories.once('exit', common.mustCall(() => {
assert(common.fileExists(FILE_NAME));
// Only __metadata categories should have been emitted.
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
assert.ok(JSON.parse(data.toString()).traceEvents.every(
(trace) => trace.cat === '__metadata'));
}));
}));