Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: https://github.com/nodejs/node/pull/50661 Fixes: https://github.com/nodejs/node/issues/30810 Fixes: https://github.com/nodejs/node/issues/47478 Fixes: https://github.com/nodejs/node/issues/46862 Fixes: https://github.com/nodejs/node/issues/40940 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
163 lines
5.7 KiB
JavaScript
163 lines
5.7 KiB
JavaScript
import { spawnPromisified } from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert';
|
|
|
|
const fixturePath = fixtures.path('disable-warning.js');
|
|
const fixturePathWorker = fixtures.path('disable-warning-worker.js');
|
|
const dep1Message = /\(node:\d+\) \[DEP1\] DeprecationWarning/;
|
|
const dep2Message = /\(node:\d+\) \[DEP2\] DeprecationWarning/;
|
|
const experimentalWarningMessage = /\(node:\d+\) ExperimentalWarning/;
|
|
|
|
describe('process warnings', { concurrency: true }, () => {
|
|
|
|
it('should emit all warnings by default', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.match(stderr, dep1Message);
|
|
assert.match(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
describe('--no-warnings', { concurrency: true }, () => {
|
|
it('should silence all warnings by default', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--no-warnings',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.doesNotMatch(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.doesNotMatch(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
});
|
|
|
|
describe('--no-deprecation', { concurrency: true }, () => {
|
|
it('should silence all deprecation warnings', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--no-deprecation',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.doesNotMatch(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
});
|
|
|
|
describe('--disable-warning', { concurrency: true }, () => {
|
|
it('should silence deprecation warning DEP1', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=DEP1',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.doesNotMatch(stderr, dep1Message);
|
|
assert.match(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should silence deprecation warnings DEP1 and DEP2', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=DEP1',
|
|
'--disable-warning=DEP2',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.doesNotMatch(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should silence all deprecation warnings using type DeprecationWarning', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=DeprecationWarning',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.doesNotMatch(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should silence all experimental warnings using type ExperimentalWarning', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=ExperimentalWarning',
|
|
fixturePath,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.match(stderr, dep1Message);
|
|
assert.match(stderr, dep2Message);
|
|
assert.doesNotMatch(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should pass down option to worker', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=DEP2',
|
|
fixturePathWorker,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.match(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should not support a comma separated list', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
'--disable-warning=DEP1,DEP2',
|
|
fixturePathWorker,
|
|
]);
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.match(stderr, dep1Message);
|
|
assert.match(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
|
|
it('should be specifiable in NODE_OPTIONS', async () => {
|
|
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
|
fixturePath,
|
|
], {
|
|
env: {
|
|
...process.env,
|
|
NODE_OPTIONS: '--disable-warning=DEP2'
|
|
}
|
|
});
|
|
|
|
assert.strictEqual(stdout, '');
|
|
assert.match(stderr, dep1Message);
|
|
assert.doesNotMatch(stderr, dep2Message);
|
|
assert.match(stderr, experimentalWarningMessage);
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
});
|
|
});
|