mirror of
https://github.com/nodejs/node.git
synced 2025-05-11 01:27:14 +00:00

Move tmpdir functionality to its own module (common/tmpdir). PR-URL: https://github.com/nodejs/node/pull/17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
25 lines
665 B
JavaScript
25 lines
665 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
const FILE_NAME = 'node_trace.1.log';
|
|
|
|
tmpdir.refresh();
|
|
process.chdir(tmpdir.path);
|
|
|
|
const proc = cp.spawn(process.execPath,
|
|
[ '--trace-events-enabled',
|
|
'-e', 'process.exit()' ]);
|
|
|
|
proc.once('exit', common.mustCall(() => {
|
|
assert(common.fileExists(FILE_NAME));
|
|
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
|
|
const traces = JSON.parse(data.toString()).traceEvents;
|
|
assert(traces.length > 0);
|
|
}));
|
|
}));
|