test: formalize exposure of internal bindings

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: https://github.com/nodejs/node/pull/18698
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Gus Caplan committed 2018-02-10 14:50:43 -06:00
1 parent 01d049165c
commit 3e8af961b3
4 files changed
+15 -7

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
'use strict';
// exposes ModuleWrap for testing
module.exports = internalBinding('module_wrap').ModuleWrap;
+13
View File
@@ -0,0 +1,13 @@
'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.
module.exports = {
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
};
+1 -1
View File
@@ -107,7 +107,6 @@
'lib/internal/loader/DefaultResolve.js',
'lib/internal/loader/ModuleJob.js',
'lib/internal/loader/ModuleMap.js',
'lib/internal/loader/ModuleWrap.js',
'lib/internal/loader/Translators.js',
'lib/internal/safe_globals.js',
'lib/internal/net.js',
@@ -125,6 +124,7 @@
'lib/internal/repl.js',
'lib/internal/repl/await.js',
'lib/internal/socket_list.js',
'lib/internal/test/binding.js',
'lib/internal/test/unicode.js',
'lib/internal/timers.js',
'lib/internal/tls.js',
+1 -1
View File
@@ -6,7 +6,7 @@ const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');
const ModuleWrap = require('internal/loader/ModuleWrap');
const { ModuleWrap } = require('internal/test/binding');
const { getPromiseDetails, isPromise } = process.binding('util');
const setTimeoutAsync = require('util').promisify(setTimeout);