From 1db783690bdb13eee1f58bd18c129bc6bfb846f0 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 doesn't register This commit calls require on a shared library that is not declared as a node module, and therefore does not register properly. Signed-off-by: Ezequiel Garcia --- 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);