node/test/sequential/test-process-warnings.js
Bryan English cc2a88a2f3 test: use common.fixturesDir almost everywhere
Updating tests to use `common.fixturesDir` whenever possible/reasonable.
Left out things like tests for `path` and `require.resolve`.

PR-URL: https://github.com/nodejs/node/pull/6997
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-06-06 15:28:52 -07: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));
});