Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5752ee

Browse filesBrowse files
TirielMylesBorins
authored andcommitted
test: fix require-deps-deprecation for installed deps
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. Also changed the deprecation test for v9.x: common.expectWarning was failing because the required deps now throw ReferenceErrors when not properly called internally in the right order. Bacport-PR-URL: #18077 PR-URL: #17848 Fixes: #17148 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d89f310 commit b5752ee
Copy full SHA for b5752ee

File tree

Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Open diff view settings
Collapse file
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
// The v8 modules when imported leak globals. Disable global check.
6+
common.globalCheck = false;
7+
8+
// Newly added deps that do not have a deprecation wrapper around it would
9+
// throw an error, but no warning would be emitted.
10+
const deps = [
11+
'acorn/dist/acorn',
12+
'acorn/dist/walk'
13+
];
14+
15+
// Instead of checking require, check that resolve isn't pointing toward a
16+
// built-in module, as user might already have node installed with acorn in
17+
// require.resolve range.
18+
// Ref: https://github.com/nodejs/node/issues/17148
19+
for (const m of deps) {
20+
let path;
21+
try {
22+
path = require.resolve(m);
23+
} catch (err) {
24+
assert.ok(err.toString().startsWith('Error: Cannot find module '));
25+
continue;
26+
}
27+
assert.notStrictEqual(path, m);
28+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.