GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: remove usage of `process.binding()` · nodejs/node@71a4b24

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • abort
      • test-zlib-invalid-internals-usage.js
    • async-hooks
      • test-zlib.zlib-binding.deflate.js
    • common
      • index.js
      • inspector-helper.js
    • fixtures/es-module-loaders
      • builtin-named-exports-loader.mjs
      • example-loader.mjs
      • js-loader.mjs
    • parallel
      • test-trace-events-api.js
      • test-trace-events-async-hooks-dynamic.js
      • test-trace-events-async-hooks-worker.js
    • sequential
      • test-inspector-async-call-stack-abort.js
      • test-inspector-async-hook-setup-at-signal.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/abort/test-zlib-invalid-internals-usage.js‎

Copy file name to clipboardExpand all lines: test/abort/test-zlib-invalid-internals-usage.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ const os = require('os');
55
const cp = require('child_process');
66

77
if (process.argv[2] === 'child') {
8+
const { internalBinding } = require('internal/test/binding');
89
// This is the heart of the test.
9-
new (process.binding('zlib').Zlib)(0).init(1, 2, 3, 4, 5);
10+
new (internalBinding('zlib').Zlib)(0).init(1, 2, 3, 4, 5);
1011
} else {
11-
const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
12+
const child = cp.spawnSync(
13+
`${process.execPath}`, ['--expose-internals', `${__filename}`, 'child']);
1214

1315
assert.strictEqual(child.stdout.toString(), '');
1416
assert.ok(child.stderr.includes(
Collapse file

‎test/async-hooks/test-zlib.zlib-binding.deflate.js‎

Copy file name to clipboardExpand all lines: test/async-hooks/test-zlib.zlib-binding.deflate.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const hooks = initHooks();
1111
hooks.enable();
1212
const { internalBinding } = require('internal/test/binding');
1313
const { Zlib } = internalBinding('zlib');
14-
const constants = internalBinding('constants').zlib;
14+
const constants = require('zlib').constants;
1515

1616
const handle = new Zlib(constants.DEFLATE);
1717

Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const os = require('os');
2929
const { exec, execSync, spawnSync } = require('child_process');
3030
const util = require('util');
3131
const tmpdir = require('./tmpdir');
32-
const {
33-
bits,
34-
hasIntl
35-
} = process.binding('config');
32+
const bits = ['arm64', 'mips', 'mipsel', 'ppc64', 's390x', 'x64']
33+
.includes(process.arch) ? 64 : 32;
34+
const hasIntl = !!process.config.variables.v8_enable_i18n_support;
3635
const { isMainThread } = require('worker_threads');
3736

3837
// Some tests assume a umask of 0o022 so set that up front. Tests that need a
Collapse file

‎test/common/inspector-helper.js‎

Copy file name to clipboardExpand all lines: test/common/inspector-helper.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class InspectorSession {
314314
}
315315

316316
class NodeInstance extends EventEmitter {
317-
constructor(inspectorFlags = ['--inspect-brk=0'],
317+
constructor(inspectorFlags = ['--inspect-brk=0', '--expose-internals'],
318318
scriptContents = '',
319319
scriptFile = _MAINSCRIPT) {
320320
super();
@@ -348,7 +348,8 @@ class NodeInstance extends EventEmitter {
348348

349349
static async startViaSignal(scriptContents) {
350350
const instance = new NodeInstance(
351-
[], `${scriptContents}\nprocess._rawDebug('started');`, undefined);
351+
['--expose-internals'],
352+
`${scriptContents}\nprocess._rawDebug('started');`, undefined);
352353
const msg = 'Timed out waiting for process to start';
353354
while (await fires(instance.nextStderrString(), msg, TIMEOUT) !==
354355
'started') {}
Collapse file

‎test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import module from 'module';
22

3-
const builtins = new Set(
4-
Object.keys(process.binding('natives')).filter(str =>
5-
/^(?!(?:internal|node|v8)\/)/.test(str))
6-
);
7-
83
export function dynamicInstantiate(url) {
94
const builtinInstance = module._load(url.substr(5));
105
const builtinExports = ['default', ...Object.keys(builtinInstance)];
@@ -19,7 +14,7 @@ export function dynamicInstantiate(url) {
1914
}
2015

2116
export function resolve(specifier, base, defaultResolver) {
22-
if (builtins.has(specifier)) {
17+
if (module.builtinModules.includes(specifier)) {
2318
return {
2419
url: `node:${specifier}`,
2520
format: 'dynamic'
Collapse file

‎test/fixtures/es-module-loaders/example-loader.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/es-module-loaders/example-loader.mjs
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import url from 'url';
22
import path from 'path';
33
import process from 'process';
4+
import { builtinModules } from 'module';
45

5-
const builtins = new Set(
6-
Object.keys(process.binding('natives')).filter((str) =>
7-
/^(?!(?:internal|node|v8)\/)/.test(str))
8-
);
96
const JS_EXTENSIONS = new Set(['.js', '.mjs']);
107

118
const baseURL = new url.URL('file://');
129
baseURL.pathname = process.cwd() + '/';
1310

1411
export function resolve(specifier, parentModuleURL = baseURL /*, defaultResolve */) {
15-
if (builtins.has(specifier)) {
12+
if (builtinModules.includes(specifier)) {
1613
return {
1714
url: specifier,
1815
format: 'builtin'
Collapse file

‎test/fixtures/es-module-loaders/js-loader.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/es-module-loaders/js-loader.mjs
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { URL } from 'url';
2-
3-
const builtins = new Set(
4-
Object.keys(process.binding('natives')).filter(str =>
5-
/^(?!(?:internal|node|v8)\/)/.test(str))
6-
)
2+
import { builtinModules } from 'module';
73

84
const baseURL = new URL('file://');
95
baseURL.pathname = process.cwd() + '/';
106

117
export function resolve (specifier, base = baseURL) {
12-
if (builtins.has(specifier)) {
8+
if (builtinModules.includes(specifier)) {
139
return {
1410
url: specifier,
1511
format: 'builtin'
Collapse file

‎test/parallel/test-trace-events-api.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-api.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33

44
const common = require('../common');
55

6-
if (!process.binding('config').hasTracing)
6+
try {
7+
require('trace_events');
8+
} catch {
79
common.skip('missing trace events');
10+
}
11+
812
common.skipIfWorker(); // https://github.com/nodejs/node/issues/22767
913

1014
const assert = require('assert');
Collapse file

‎test/parallel/test-trace-events-async-hooks-dynamic.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-async-hooks-dynamic.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (!process.binding('config').hasTracing)
4+
try {
5+
require('trace_events');
6+
} catch {
57
common.skip('missing trace events');
8+
}
69

710
const assert = require('assert');
811
const cp = require('child_process');
Collapse file

‎test/parallel/test-trace-events-async-hooks-worker.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-async-hooks-worker.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (!process.binding('config').hasTracing)
4+
try {
5+
require('trace_events');
6+
} catch {
57
common.skip('missing trace events');
8+
}
69

710
const assert = require('assert');
811
const cp = require('child_process');

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.