mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
99e0d0d218
PR-URL: https://github.com/nodejs/node/pull/55125 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
process.emitWarning('foo');
|
|
} else {
|
|
function test(newEnv) {
|
|
const [cmd, opts] = common.escapePOSIXShell`"${process.execPath}" "${__filename}" child`;
|
|
|
|
cp.exec(cmd, { ...opts, env: { ...opts?.env, ...newEnv } }, common.mustCall((err, stdout, stderr) => {
|
|
assert.strictEqual(err, null);
|
|
assert.strictEqual(stdout, '');
|
|
|
|
if (newEnv.NODE_NO_WARNINGS === '1')
|
|
assert.strictEqual(stderr, '');
|
|
else
|
|
assert.match(stderr.trim(), /Warning: foo\n/);
|
|
}));
|
|
}
|
|
|
|
test({});
|
|
test(process.env);
|
|
test({ NODE_NO_WARNINGS: undefined });
|
|
test({ NODE_NO_WARNINGS: null });
|
|
test({ NODE_NO_WARNINGS: 'foo' });
|
|
test({ NODE_NO_WARNINGS: true });
|
|
test({ NODE_NO_WARNINGS: false });
|
|
test({ NODE_NO_WARNINGS: {} });
|
|
test({ NODE_NO_WARNINGS: [] });
|
|
test({ NODE_NO_WARNINGS: function() {} });
|
|
test({ NODE_NO_WARNINGS: 0 });
|
|
test({ NODE_NO_WARNINGS: -1 });
|
|
test({ NODE_NO_WARNINGS: '0' });
|
|
test({ NODE_NO_WARNINGS: '01' });
|
|
test({ NODE_NO_WARNINGS: '2' });
|
|
// Don't test the number 1 because it will come through as a string in the
|
|
// child process environment.
|
|
test({ NODE_NO_WARNINGS: '1' });
|
|
}
|