11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst cp = require('child_process'); 51cb0ef41Sopenharmony_ciconst fs = require('fs'); 61cb0ef41Sopenharmony_ciconst path = require('path'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst CODE = 91cb0ef41Sopenharmony_ci 'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)'; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 121cb0ef41Sopenharmony_citmpdir.refresh(); 131cb0ef41Sopenharmony_ciconst FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst proc_no_categories = cp.spawn( 161cb0ef41Sopenharmony_ci process.execPath, 171cb0ef41Sopenharmony_ci [ '--trace-event-categories', '""', '-e', CODE ], 181cb0ef41Sopenharmony_ci { cwd: tmpdir.path } 191cb0ef41Sopenharmony_ci); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciproc_no_categories.once('exit', common.mustCall(() => { 221cb0ef41Sopenharmony_ci assert(fs.existsSync(FILE_NAME)); 231cb0ef41Sopenharmony_ci // Only __metadata categories should have been emitted. 241cb0ef41Sopenharmony_ci fs.readFile(FILE_NAME, common.mustCall((err, data) => { 251cb0ef41Sopenharmony_ci assert.ok(JSON.parse(data.toString()).traceEvents.every( 261cb0ef41Sopenharmony_ci (trace) => trace.cat === '__metadata')); 271cb0ef41Sopenharmony_ci })); 281cb0ef41Sopenharmony_ci})); 29