1'use strict'; 2 3require('../common'); 4const fixtures = require('../common/fixtures'); 5const assert = require('assert'); 6const execFile = require('child_process').execFile; 7const warnmod = require.resolve(fixtures.path('warnings.js')); 8const node = process.execPath; 9 10const normal = [warnmod]; 11const noWarn = ['--no-warnings', warnmod]; 12const traceWarn = ['--trace-warnings', warnmod]; 13 14const warningMessage = /^\(.+\)\sWarning: a bad practice warning/; 15 16execFile(node, normal, function(er, stdout, stderr) { 17 // Show Process Warnings 18 assert.strictEqual(er, null); 19 assert.strictEqual(stdout, ''); 20 assert.match(stderr, warningMessage); 21}); 22 23execFile(node, noWarn, function(er, stdout, stderr) { 24 // Hide Process Warnings 25 assert.strictEqual(er, null); 26 assert.strictEqual(stdout, ''); 27 assert.doesNotMatch(stderr, warningMessage); 28}); 29 30execFile(node, traceWarn, function(er, stdout, stderr) { 31 // Show Warning Trace 32 assert.strictEqual(er, null); 33 assert.strictEqual(stdout, ''); 34 assert.match(stderr, warningMessage); 35 assert.match(stderr, /at Object\.<anonymous>\s\(.+warnings\.js:3:9\)/); 36}); 37