2016-01-20 20:38:35 +01:00
|
|
|
'use strict';
|
|
|
|
|
2017-10-06 18:47:22 +02:00
|
|
|
require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
2016-01-20 20:38:35 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const execFile = require('child_process').execFile;
|
2017-10-06 18:47:22 +02:00
|
|
|
const warnmod = require.resolve(fixtures.path('warnings.js'));
|
2016-01-20 20:38:35 +01:00
|
|
|
const node = process.execPath;
|
|
|
|
|
|
|
|
const normal = [warnmod];
|
|
|
|
const noWarn = ['--no-warnings', warnmod];
|
|
|
|
const traceWarn = ['--trace-warnings', warnmod];
|
|
|
|
|
2017-06-18 15:22:32 +02:00
|
|
|
const warningMessage = /^\(.+\)\sWarning: a bad practice warning/;
|
|
|
|
|
2016-01-20 20:38:35 +01:00
|
|
|
execFile(node, normal, function(er, stdout, stderr) {
|
|
|
|
// Show Process Warnings
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2017-06-18 15:22:32 +02:00
|
|
|
assert(warningMessage.test(stderr));
|
2016-01-20 20:38:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
execFile(node, noWarn, function(er, stdout, stderr) {
|
|
|
|
// Hide Process Warnings
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2017-06-18 15:22:32 +02:00
|
|
|
assert(!warningMessage.test(stderr));
|
2016-01-20 20:38:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
execFile(node, traceWarn, function(er, stdout, stderr) {
|
|
|
|
// Show Warning Trace
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2017-06-18 15:22:32 +02:00
|
|
|
assert(warningMessage.test(stderr));
|
2017-03-13 19:50:57 +01:00
|
|
|
assert(/at Object\.<anonymous>\s\(.+warnings\.js:3:9\)/.test(stderr));
|
2016-01-20 20:38:35 +01:00
|
|
|
});
|