node/test/sequential/test-process-warnings.js
Teddy Katz b1b1978ec5
tools: add additional ESLint rules
PR-URL: https://github.com/nodejs/node/pull/8643
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@keybase.io>
2016-09-20 23:21:10 -04:00

34 lines
1.0 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const execFile = require('child_process').execFile;
const warnmod = require.resolve(common.fixturesDir + '/warnings.js');
const node = process.execPath;
const normal = [warnmod];
const noWarn = ['--no-warnings', warnmod];
const traceWarn = ['--trace-warnings', warnmod];
execFile(node, normal, function(er, stdout, stderr) {
// Show Process Warnings
assert.equal(er, null);
assert.equal(stdout, '');
assert(/^\(.+\)\sWarning: a bad practice warning/.test(stderr));
});
execFile(node, noWarn, function(er, stdout, stderr) {
// Hide Process Warnings
assert.equal(er, null);
assert.equal(stdout, '');
assert(!/^\(.+\)\sWarning: a bad practice warning/.test(stderr));
});
execFile(node, traceWarn, function(er, stdout, stderr) {
// Show Warning Trace
assert.equal(er, null);
assert.equal(stdout, '');
assert(/^\(.+\)\sWarning: a bad practice warning/.test(stderr));
assert(/at Object\.<anonymous>\s\(.+warnings.js:3:9\)/.test(stderr));
});