Skip to content

Commit

Permalink
test: formalize exposure of internal bindings
Browse files Browse the repository at this point in the history
moves exposed internalBindings to a single location with short
guidelines on how to expose them and a warning for users should they
come across it

PR-URL: nodejs#18698
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
devsnek authored and BridgeAR committed Apr 30, 2018
1 parent 1350802 commit bef6b16
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
6 changes: 0 additions & 6 deletions lib/internal/modules/esm/ModuleWrap.js

This file was deleted.

15 changes: 15 additions & 0 deletions lib/internal/test/binding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

process.emitWarning(
'These APIs are exposed only for testing and are not ' +
'tracked by any versioning system or deprecation process.',
'internal/test/binding');

// These exports should be scoped as specifically as possible
// to avoid exposing APIs because even with that warning and
// this file being internal people will still try to abuse it.

const { internalBinding } = require('internal/bootstrap/loaders');
module.exports = {
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
};
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
'lib/internal/modules/esm/DefaultResolve.js',
'lib/internal/modules/esm/ModuleJob.js',
'lib/internal/modules/esm/ModuleMap.js',
'lib/internal/modules/esm/ModuleWrap.js',
'lib/internal/modules/esm/Translators.js',
'lib/internal/safe_globals.js',
'lib/internal/net.js',
Expand All @@ -128,6 +127,7 @@
'lib/internal/readline.js',
'lib/internal/repl.js',
'lib/internal/socket_list.js',
'lib/internal/test/binding.js',
'lib/internal/test/unicode.js',
'lib/internal/tls.js',
'lib/internal/trace_events_async_hooks.js',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-module-wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');

const ModuleWrap = require('internal/modules/esm/ModuleWrap');
const { ModuleWrap } = require('internal/test/binding');
const { getPromiseDetails, isPromise } = process.binding('util');
const setTimeoutAsync = require('util').promisify(setTimeout);

Expand Down

0 comments on commit bef6b16

Please sign in to comment.