mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 09:52:21 +00:00

PR-URL: https://github.com/nodejs/node/pull/35086 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
27 lines
896 B
JavaScript
27 lines
896 B
JavaScript
'use strict';
|
|
|
|
// Tests the --redirect-warnings command line flag by spawning
|
|
// a new child node process that emits a warning into a temporary
|
|
// warnings file. Once the process completes, the warning file is
|
|
// opened and the contents are validated
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const fs = require('fs');
|
|
const fork = require('child_process').fork;
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const warnmod = fixtures.path('warnings.js');
|
|
const warnpath = path.join(tmpdir.path, 'warnings.txt');
|
|
|
|
fork(warnmod, { execArgv: [`--redirect-warnings=${warnpath}`] })
|
|
.on('exit', common.mustCall(() => {
|
|
fs.readFile(warnpath, 'utf8', common.mustSucceed((data) => {
|
|
assert(/\(node:\d+\) Warning: a bad practice warning/.test(data));
|
|
}));
|
|
}));
|