-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ethan Arrowood
committed
Nov 10, 2023
1 parent
609cd7f
commit 37ae57e
Showing
6 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const sys = require('sys'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
try { | ||
assert.fail('a', 'b'); | ||
} catch (e) {} | ||
|
||
vm.measureMemory(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { spawnPromisified } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import { describe, it } from 'node:test'; | ||
import { strictEqual, match, doesNotMatch } from 'node:assert'; | ||
|
||
const fixturePath = fixtures.path('disable-warnings.js'); | ||
const dep0025Message = /\(node:\d+\) \[DEP0025\] DeprecationWarning: sys is deprecated\. Use util instead\./; | ||
const dep0094Message = /\(node:\d+\) \[DEP0094\] DeprecationWarning: assert\.fail\(\) with more than one argument is deprecated\. Please use assert\.strictEqual\(\) instead or only pass a message\./; | ||
const experimentalWarningMessage = /\(node:\d+\) ExperimentalWarning: vm\.measureMemory is an experimental feature and might change at any time/; | ||
|
||
describe('process warnings', { concurrency: true }, () => { | ||
|
||
it('should emit all warnings by default', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
fixturePath, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
match(stderr, dep0025Message); | ||
match(stderr, dep0094Message); | ||
match(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
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, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
doesNotMatch(stderr, dep0025Message); | ||
doesNotMatch(stderr, dep0094Message); | ||
doesNotMatch(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
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, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
doesNotMatch(stderr, dep0025Message); | ||
doesNotMatch(stderr, dep0094Message); | ||
match(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
}); | ||
|
||
describe('--disable-warnings', { concurrency: true }, () => { | ||
it('should silence deprecation warning DEP0025', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-warnings=DEP0025', | ||
fixturePath, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
doesNotMatch(stderr, dep0025Message); | ||
match(stderr, dep0094Message); | ||
match(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
|
||
it('should silence deprecation warnings DEP0025 and DEP0094', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-warnings=DEP0025', | ||
'--disable-warnings=DEP0094', | ||
fixturePath, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
doesNotMatch(stderr, dep0025Message); | ||
doesNotMatch(stderr, dep0094Message); | ||
match(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
|
||
it('should silence all deprecation warnings using type DeprecationWarning', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-warnings=DeprecationWarning', | ||
fixturePath, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
doesNotMatch(stderr, dep0025Message); | ||
doesNotMatch(stderr, dep0094Message); | ||
match(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
|
||
it('should silence all experimental warnings using type ExperimentalWarning', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-warnings=ExperimentalWarning', | ||
fixturePath, | ||
]); | ||
|
||
strictEqual(stdout, ''); | ||
match(stderr, dep0025Message); | ||
match(stderr, dep0094Message); | ||
doesNotMatch(stderr, experimentalWarningMessage); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
}); | ||
}); |