1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const cp = require('child_process'); 5const fs = require('fs'); 6const path = require('path'); 7 8const CODE = 9 'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)'; 10 11const tmpdir = require('../common/tmpdir'); 12tmpdir.refresh(); 13const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); 14 15const proc_no_categories = cp.spawn( 16 process.execPath, 17 [ '--trace-event-categories', '""', '-e', CODE ], 18 { cwd: tmpdir.path } 19); 20 21proc_no_categories.once('exit', common.mustCall(() => { 22 assert(fs.existsSync(FILE_NAME)); 23 // Only __metadata categories should have been emitted. 24 fs.readFile(FILE_NAME, common.mustCall((err, data) => { 25 assert.ok(JSON.parse(data.toString()).traceEvents.every( 26 (trace) => trace.cat === '__metadata')); 27 })); 28})); 29