Skip to content

Commit 56f165c

Browse files
committed
Merge branch 'master' of https://github.com/nodejs/node into http_compat
2 parents 058a029 + 0bf7d41 commit 56f165c

File tree

12 files changed

+271
-68
lines changed

12 files changed

+271
-68
lines changed

doc/api/util.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,6 @@ changes:
449449
* `showProxy` {boolean} If `true`, then objects and functions that are
450450
`Proxy` objects will be introspected to show their `target` and `handler`
451451
objects. **Default:** `false`.
452-
<!--
453-
TODO(BridgeAR): Deprecate `maxArrayLength` and replace it with
454-
`maxEntries`.
455-
-->
456452
* `maxArrayLength` {integer} Specifies the maximum number of `Array`,
457453
[`TypedArray`][], [`WeakMap`][] and [`WeakSet`][] elements to include when
458454
formatting. Set to `null` or `Infinity` to show all elements. Set to `0` or

lib/buffer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ const {
4848
isArrayBufferView,
4949
isUint8Array
5050
} = require('internal/util/types');
51-
const {
52-
pendingDeprecation
53-
} = internalBinding('config');
51+
5452
const {
5553
ERR_BUFFER_OUT_OF_BOUNDS,
5654
ERR_OUT_OF_RANGE,
@@ -138,7 +136,7 @@ const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
138136
function showFlaggedDeprecation() {
139137
if (bufferWarningAlreadyEmitted ||
140138
++nodeModulesCheckCounter > 10000 ||
141-
(!pendingDeprecation &&
139+
(!require('internal/options').getOptionValue('--pending-deprecation') &&
142140
isInsideNodeModules())) {
143141
// We don't emit a warning, because we either:
144142
// - Already did so, or

lib/internal/bootstrap/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function startup() {
176176
{
177177
// Install legacy getters on the `util` binding for typechecking.
178178
// TODO(addaleax): Turn into a full runtime deprecation.
179-
const { pendingDeprecation } = internalBinding('config');
179+
const pendingDeprecation = getOptionValue('--pending-deprecation');
180180
const utilBinding = internalBinding('util');
181181
const types = internalBinding('types');
182182
for (const name of [

lib/internal/util/inspect.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ function inspect(value, opts) {
163163
colors: inspectDefaultOptions.colors,
164164
customInspect: inspectDefaultOptions.customInspect,
165165
showProxy: inspectDefaultOptions.showProxy,
166-
// TODO(BridgeAR): Deprecate `maxArrayLength` and replace it with
167-
// `maxEntries`.
168166
maxArrayLength: inspectDefaultOptions.maxArrayLength,
169167
breakLength: inspectDefaultOptions.breakLength,
170168
compact: inspectDefaultOptions.compact,

src/node_config.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ static void Initialize(Local<Object> target,
7777
if (env->options()->experimental_repl_await)
7878
READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");
7979

80-
if (env->options()->pending_deprecation)
81-
READONLY_TRUE_PROPERTY(target, "pendingDeprecation");
82-
8380
if (env->options()->expose_internals)
8481
READONLY_TRUE_PROPERTY(target, "exposeInternals");
8582

test/common/wpt.js

Lines changed: 99 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,92 @@ class ResourceLoader {
6666
}
6767
}
6868

69+
class StatusRule {
70+
constructor(key, value, pattern = undefined) {
71+
this.key = key;
72+
this.requires = value.requires || [];
73+
this.fail = value.fail;
74+
this.skip = value.skip;
75+
if (pattern) {
76+
this.pattern = this.transformPattern(pattern);
77+
}
78+
// TODO(joyeecheung): implement this
79+
this.scope = value.scope;
80+
this.comment = value.comment;
81+
}
82+
83+
/**
84+
* Transform a filename pattern into a RegExp
85+
* @param {string} pattern
86+
* @returns {RegExp}
87+
*/
88+
transformPattern(pattern) {
89+
const result = pattern.replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&');
90+
return new RegExp(result.replace('*', '.*'));
91+
}
92+
}
93+
94+
class StatusRuleSet {
95+
constructor() {
96+
// We use two sets of rules to speed up matching
97+
this.exactMatch = {};
98+
this.patternMatch = [];
99+
}
100+
101+
/**
102+
* @param {object} rules
103+
*/
104+
addRules(rules) {
105+
for (const key of Object.keys(rules)) {
106+
if (key.includes('*')) {
107+
this.patternMatch.push(new StatusRule(key, rules[key], key));
108+
} else {
109+
this.exactMatch[key] = new StatusRule(key, rules[key]);
110+
}
111+
}
112+
}
113+
114+
match(file) {
115+
const result = [];
116+
const exact = this.exactMatch[file];
117+
if (exact) {
118+
result.push(exact);
119+
}
120+
for (const item of this.patternMatch) {
121+
if (item.pattern.test(file)) {
122+
result.push(item);
123+
}
124+
}
125+
return result;
126+
}
127+
}
128+
69129
class WPTTest {
70130
/**
71131
* @param {string} mod
72132
* @param {string} filename
73-
* @param {string[]} requires
74-
* @param {string | undefined} failReason
75-
* @param {string | undefined} skipReason
133+
* @param {StatusRule[]} rules
76134
*/
77-
constructor(mod, filename, requires, failReason, skipReason) {
135+
constructor(mod, filename, rules) {
78136
this.module = mod; // name of the WPT module, e.g. 'url'
79137
this.filename = filename; // name of the test file
80-
this.requires = requires;
81-
this.failReason = failReason;
82-
this.skipReason = skipReason;
138+
139+
this.requires = new Set();
140+
this.failReasons = [];
141+
this.skipReasons = [];
142+
for (const item of rules) {
143+
if (item.requires.length) {
144+
for (const req of item.requires) {
145+
this.requires.add(req);
146+
}
147+
}
148+
if (item.fail) {
149+
this.failReasons.push(item.fail);
150+
}
151+
if (item.skip) {
152+
this.skipReasons.push(item.skip);
153+
}
154+
}
83155
}
84156

85157
getAbsolutePath() {
@@ -90,54 +162,37 @@ class WPTTest {
90162
return fs.readFileSync(this.getAbsolutePath(), 'utf8');
91163
}
92164

93-
shouldSkip() {
94-
return this.failReason || this.skipReason;
95-
}
96-
97165
requireIntl() {
98-
return this.requires.includes('intl');
166+
return this.requires.has('intl');
99167
}
100168
}
101169

102170
class StatusLoader {
103171
constructor(path) {
104172
this.path = path;
105173
this.loaded = false;
106-
this.status = null;
174+
this.rules = new StatusRuleSet();
107175
/** @type {WPTTest[]} */
108176
this.tests = [];
109177
}
110178

111-
loadTest(file) {
112-
let requires = [];
113-
let failReason;
114-
let skipReason;
115-
if (this.status[file]) {
116-
requires = this.status[file].requires || [];
117-
failReason = this.status[file].fail;
118-
skipReason = this.status[file].skip;
119-
}
120-
return new WPTTest(this.path, file, requires,
121-
failReason, skipReason);
122-
}
123-
124179
load() {
125180
const dir = path.join(__dirname, '..', 'wpt');
126181
const statusFile = path.join(dir, 'status', `${this.path}.json`);
127182
const result = JSON.parse(fs.readFileSync(statusFile, 'utf8'));
128-
this.status = result;
183+
this.rules.addRules(result);
129184

130185
const list = fs.readdirSync(fixtures.path('wpt', this.path));
131186

132187
for (const file of list) {
133-
this.tests.push(this.loadTest(file));
188+
if (!(/\.\w+\.js$/.test(file))) {
189+
continue;
190+
}
191+
const match = this.rules.match(file);
192+
this.tests.push(new WPTTest(this.path, file, match));
134193
}
135194
this.loaded = true;
136195
}
137-
138-
get jsTests() {
139-
return this.tests.filter((test) => test.filename.endsWith('.js'));
140-
}
141196
}
142197

143198
const PASSED = 1;
@@ -156,7 +211,7 @@ class WPTRunner {
156211
this.status = new StatusLoader(path);
157212
this.status.load();
158213
this.tests = new Map(
159-
this.status.jsTests.map((item) => [item.filename, item])
214+
this.status.tests.map((item) => [item.filename, item])
160215
);
161216

162217
this.results = new Map();
@@ -171,7 +226,10 @@ class WPTRunner {
171226
*/
172227
copyGlobalsFromObject(obj, names) {
173228
for (const name of names) {
174-
const desc = Object.getOwnPropertyDescriptor(global, name);
229+
const desc = Object.getOwnPropertyDescriptor(obj, name);
230+
if (!desc) {
231+
assert.fail(`${name} does not exist on the object`);
232+
}
175233
this.globals.set(name, desc);
176234
}
177235
}
@@ -328,8 +386,9 @@ class WPTRunner {
328386
for (const item of items) {
329387
switch (item.type) {
330388
case FAILED: {
331-
if (test.failReason) {
389+
if (test.failReasons.length) {
332390
console.log(`[EXPECTED_FAILURE] ${item.test.name}`);
391+
console.log(test.failReasons.join('; '));
333392
} else {
334393
console.log(`[UNEXPECTED_FAILURE] ${item.test.name}`);
335394
unexpectedFailures.push([title, filename, item]);
@@ -386,10 +445,10 @@ class WPTRunner {
386445
});
387446
}
388447

389-
skip(filename, reason) {
448+
skip(filename, reasons) {
390449
this.addResult(filename, {
391450
type: SKIPPED,
392-
reason
451+
reason: reasons.join('; ')
393452
});
394453
}
395454

@@ -435,13 +494,13 @@ class WPTRunner {
435494
const queue = [];
436495
for (const test of this.tests.values()) {
437496
const filename = test.filename;
438-
if (test.skipReason) {
439-
this.skip(filename, test.skipReason);
497+
if (test.skipReasons.length > 0) {
498+
this.skip(filename, test.skipReasons);
440499
continue;
441500
}
442501

443502
if (!common.hasIntl && test.requireIntl()) {
444-
this.skip(filename, 'missing Intl');
503+
this.skip(filename, [ 'missing Intl' ]);
445504
continue;
446505
}
447506

test/parallel/parallel.status

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ prefix parallel
55
# sample-test : PASS,FLAKY
66

77
[true] # This section applies to all platforms
8+
# https://github.com/nodejs/node/issues/25029
9+
test-child-process-execfile: PASS,FLAKY
810
# https://github.com/nodejs/node/issues/23207
911
test-net-connect-options-port: PASS,FLAKY
12+
# https://github.com/nodejs/node/issues/25033
13+
test-child-process-exit-code: PASS,FLAKY
1014

1115
[$system==win32]
1216
test-http2-pipe: PASS,FLAKY
1317
test-worker-syntax-error: PASS,FLAKY
1418
test-worker-syntax-error-file: PASS,FLAKY
19+
# https://github.com/nodejs/node/issues/23277
20+
test-worker-memory: PASS,FLAKY
1521

1622
[$system==linux]
1723

test/parallel/test-pending-deprecation.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
11
'use strict';
22

3-
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both
4-
// set the process.binding('config').pendingDeprecation flag that is
5-
// used to determine if pending deprecation messages should be shown.
6-
// The test is performed by launching two child processes that run
3+
// Flags: --expose-internals
4+
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both set the
5+
// `require('internal/options').getOptionValue('--pending-deprecation')`
6+
// flag that is used to determine if pending deprecation messages should be
7+
// shown. The test is performed by launching two child processes that run
78
// this same test script with different arguments. If those exit with
89
// code 0, then the test passes. If they don't, it fails.
910

11+
// TODO(joyeecheung): instead of testing internals, test the actual features
12+
// pending deprecations.
13+
1014
const common = require('../common');
1115

1216
const assert = require('assert');
13-
const config = process.binding('config');
1417
const fork = require('child_process').fork;
18+
const { getOptionValue } = require('internal/options');
1519

1620
function message(name) {
17-
return `${name} did not set the process.binding('config').` +
18-
'pendingDeprecation flag.';
21+
return `${name} did not affect getOptionValue('--pending-deprecation')`;
1922
}
2023

2124
switch (process.argv[2]) {
2225
case 'env':
2326
case 'switch':
24-
assert.strictEqual(config.pendingDeprecation, true);
27+
assert.strictEqual(
28+
getOptionValue('--pending-deprecation'),
29+
true
30+
);
2531
break;
2632
default:
2733
// Verify that the flag is off by default.
2834
const envvar = process.env.NODE_PENDING_DEPRECATION;
29-
assert.strictEqual(config.pendingDeprecation, envvar && envvar[0] === '1');
35+
assert.strictEqual(
36+
getOptionValue('--pending-deprecation'),
37+
!!(envvar && envvar[0] === '1')
38+
);
3039

3140
// Test the --pending-deprecation command line switch.
3241
fork(__filename, ['switch'], {
33-
execArgv: ['--pending-deprecation'],
42+
execArgv: ['--pending-deprecation', '--expose-internals'],
3443
silent: true
3544
}).on('exit', common.mustCall((code) => {
3645
assert.strictEqual(code, 0, message('--pending-deprecation'));
3746
}));
3847

3948
// Test the --pending_deprecation command line switch.
4049
fork(__filename, ['switch'], {
41-
execArgv: ['--pending_deprecation'],
50+
execArgv: ['--pending_deprecation', '--expose-internals'],
4251
silent: true
4352
}).on('exit', common.mustCall((code) => {
4453
assert.strictEqual(code, 0, message('--pending_deprecation'));
@@ -47,6 +56,7 @@ switch (process.argv[2]) {
4756
// Test the NODE_PENDING_DEPRECATION environment var.
4857
fork(__filename, ['env'], {
4958
env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }),
59+
execArgv: ['--expose-internals'],
5060
silent: true
5161
}).on('exit', common.mustCall((code) => {
5262
assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));

0 commit comments

Comments
 (0)