From e5375a97e03c8d44c8329a0a89073db82ad8d238 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 27 Jun 2017 21:46:50 -0300 Subject: [PATCH] test: add check on an addon that does not register MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit calls require on a shared library that is not declared as a node module, and therefore does not register properly. PR-URL: https://github.com/nodejs/node/pull/13954 Signed-off-by: Ezequiel Garcia Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: Michael Dawson --- test/addons/not-a-binding/binding.gyp | 8 ++++++++ test/addons/not-a-binding/not_a_binding.c | 3 +++ test/addons/not-a-binding/test.js | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 test/addons/not-a-binding/binding.gyp create mode 100644 test/addons/not-a-binding/not_a_binding.c create mode 100644 test/addons/not-a-binding/test.js diff --git a/test/addons/not-a-binding/binding.gyp b/test/addons/not-a-binding/binding.gyp new file mode 100644 index 00000000000000..7ddad59c1d1683 --- /dev/null +++ b/test/addons/not-a-binding/binding.gyp @@ -0,0 +1,8 @@ +{ + 'targets': [ + { + 'target_name': 'binding', + 'sources': [ 'not_a_binding.c' ] + } + ] +} diff --git a/test/addons/not-a-binding/not_a_binding.c b/test/addons/not-a-binding/not_a_binding.c new file mode 100644 index 00000000000000..af8791a1e3479c --- /dev/null +++ b/test/addons/not-a-binding/not_a_binding.c @@ -0,0 +1,3 @@ +int foo(void) { + return 0; +} diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js new file mode 100644 index 00000000000000..a0ce2d0629ac1d --- /dev/null +++ b/test/addons/not-a-binding/test.js @@ -0,0 +1,6 @@ +'use strict'; +const common = require('../../common'); +const assert = require('assert'); + +const re = /^Error: Module did not self-register\.$/; +assert.throws(() => require(`./build/${common.buildType}/binding`), re);