2016-12-04 10:38:35 -08:00
|
|
|
'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');
|
2017-10-06 10:17:00 -07:00
|
|
|
const fixtures = require('../common/fixtures');
|
2016-12-04 10:38:35 -08:00
|
|
|
const fs = require('fs');
|
|
|
|
const fork = require('child_process').fork;
|
|
|
|
const assert = require('assert');
|
|
|
|
|
2017-12-24 22:38:11 -08:00
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
tmpdir.refresh();
|
2016-12-04 10:38:35 -08:00
|
|
|
|
2017-10-06 10:17:00 -07:00
|
|
|
const warnmod = fixtures.path('warnings.js');
|
2023-08-15 22:45:44 +09:00
|
|
|
const warnpath = tmpdir.resolve('warnings.txt');
|
2016-12-04 10:38:35 -08:00
|
|
|
|
2017-07-10 20:55:21 -04:00
|
|
|
fork(warnmod, { execArgv: [`--redirect-warnings=${warnpath}`] })
|
2016-12-04 10:38:35 -08:00
|
|
|
.on('exit', common.mustCall(() => {
|
2020-09-06 22:27:07 +02:00
|
|
|
fs.readFile(warnpath, 'utf8', common.mustSucceed((data) => {
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(data, /\(node:\d+\) Warning: a bad practice warning/);
|
2016-12-04 10:38:35 -08:00
|
|
|
}));
|
|
|
|
}));
|