diff options
author | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-05-30 17:47:05 -0400 |
---|---|---|
committer | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-06-01 17:50:14 -0400 |
commit | 7a7ac1c6dbc88b84b0821c56b5bae0d2b52e37b3 (patch) | |
tree | 07fcc716f348cd187d325d85d65a436e7a6c697e /test | |
parent | 8440777553e456d93e7dc136b12ffa51154e6a60 (diff) | |
download | android-node-v8-7a7ac1c6dbc88b84b0821c56b5bae0d2b52e37b3.tar.gz android-node-v8-7a7ac1c6dbc88b84b0821c56b5bae0d2b52e37b3.tar.bz2 android-node-v8-7a7ac1c6dbc88b84b0821c56b5bae0d2b52e37b3.zip |
test: consolidate n-api test addons
It takes time to build each of the addons used to test n-api.
Consolidate a few of the smaller ones to save build time.
PR-URL: https://github.com/nodejs/node/pull/13317
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/addons-napi/test_general/testGlobals.js (renamed from test/addons-napi/test_globals/test.js) | 2 | ||||
-rw-r--r-- | test/addons-napi/test_general/testInstanceOf.js (renamed from test/addons-napi/test_instanceof/test.js) | 2 | ||||
-rw-r--r-- | test/addons-napi/test_general/test_general.c | 29 | ||||
-rw-r--r-- | test/addons-napi/test_globals/binding.gyp | 8 | ||||
-rw-r--r-- | test/addons-napi/test_globals/test_globals.c | 26 | ||||
-rw-r--r-- | test/addons-napi/test_instanceof/binding.gyp | 8 | ||||
-rw-r--r-- | test/addons-napi/test_instanceof/test_instanceof.c | 28 |
7 files changed, 31 insertions, 72 deletions
diff --git a/test/addons-napi/test_globals/test.js b/test/addons-napi/test_general/testGlobals.js index a6e5f722cb..38cf3f3edb 100644 --- a/test/addons-napi/test_globals/test.js +++ b/test/addons-napi/test_general/testGlobals.js @@ -2,7 +2,7 @@ const common = require('../../common'); const assert = require('assert'); -const test_globals = require(`./build/${common.buildType}/test_globals`); +const test_globals = require(`./build/${common.buildType}/test_general`); assert.strictEqual(test_globals.getUndefined(), undefined); assert.strictEqual(test_globals.getNull(), null); diff --git a/test/addons-napi/test_instanceof/test.js b/test/addons-napi/test_general/testInstanceOf.js index 418149d190..3279979719 100644 --- a/test/addons-napi/test_instanceof/test.js +++ b/test/addons-napi/test_general/testInstanceOf.js @@ -6,7 +6,7 @@ const assert = require('assert'); // addon is referenced through the eval expression in testFile // eslint-disable-next-line no-unused-vars -const addon = require(`./build/${common.buildType}/test_instanceof`); +const addon = require(`./build/${common.buildType}/test_general`); const path = require('path'); // The following assert functions are referenced by v8's unit tests diff --git a/test/addons-napi/test_general/test_general.c b/test/addons-napi/test_general/test_general.c index 585a3bf2b3..5d974081a4 100644 --- a/test/addons-napi/test_general/test_general.c +++ b/test/addons-napi/test_general/test_general.c @@ -33,11 +33,40 @@ napi_value testGetVersion(napi_env env, napi_callback_info info) { return result; } +napi_value doInstanceOf(napi_env env, napi_callback_info info) { + size_t argc = 2; + napi_value args[2]; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); + + bool instanceof; + NAPI_CALL(env, napi_instanceof(env, args[0], args[1], &instanceof)); + + napi_value result; + NAPI_CALL(env, napi_get_boolean(env, instanceof, &result)); + + return result; +} + +napi_value getNull(napi_env env, napi_callback_info info) { + napi_value result; + NAPI_CALL(env, napi_get_null(env, &result)); + return result; +} + +napi_value getUndefined(napi_env env, napi_callback_info info) { + napi_value result; + NAPI_CALL(env, napi_get_undefined(env, &result)); + return result; +} + void Init(napi_env env, napi_value exports, napi_value module, void* priv) { napi_property_descriptor descriptors[] = { DECLARE_NAPI_PROPERTY("testStrictEquals", testStrictEquals), DECLARE_NAPI_PROPERTY("testGetPrototype", testGetPrototype), DECLARE_NAPI_PROPERTY("testGetVersion", testGetVersion), + DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf), + DECLARE_NAPI_PROPERTY("getUndefined", getUndefined), + DECLARE_NAPI_PROPERTY("getNull", getNull), }; NAPI_CALL_RETURN_VOID(env, napi_define_properties( diff --git a/test/addons-napi/test_globals/binding.gyp b/test/addons-napi/test_globals/binding.gyp deleted file mode 100644 index 0160dc72e1..0000000000 --- a/test/addons-napi/test_globals/binding.gyp +++ /dev/null @@ -1,8 +0,0 @@ -{ - "targets": [ - { - "target_name": "test_globals", - "sources": [ "test_globals.c" ] - } - ] -} diff --git a/test/addons-napi/test_globals/test_globals.c b/test/addons-napi/test_globals/test_globals.c deleted file mode 100644 index 709e42a2e0..0000000000 --- a/test/addons-napi/test_globals/test_globals.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <node_api.h> -#include "../common.h" - -napi_value getNull(napi_env env, napi_callback_info info) { - napi_value result; - NAPI_CALL(env, napi_get_null(env, &result)); - return result; -} - -napi_value getUndefined(napi_env env, napi_callback_info info) { - napi_value result; - NAPI_CALL(env, napi_get_undefined(env, &result)); - return result; -} - -void Init(napi_env env, napi_value exports, napi_value module, void* priv) { - napi_property_descriptor descriptors[] = { - DECLARE_NAPI_PROPERTY("getUndefined", getUndefined), - DECLARE_NAPI_PROPERTY("getNull", getNull), - }; - - NAPI_CALL_RETURN_VOID(env, napi_define_properties( - env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors)); -} - -NAPI_MODULE(addon, Init) diff --git a/test/addons-napi/test_instanceof/binding.gyp b/test/addons-napi/test_instanceof/binding.gyp deleted file mode 100644 index 7fca7e0736..0000000000 --- a/test/addons-napi/test_instanceof/binding.gyp +++ /dev/null @@ -1,8 +0,0 @@ -{ - "targets": [ - { - "target_name": "test_instanceof", - "sources": [ "test_instanceof.c" ] - } - ] -} diff --git a/test/addons-napi/test_instanceof/test_instanceof.c b/test/addons-napi/test_instanceof/test_instanceof.c deleted file mode 100644 index 76a6542830..0000000000 --- a/test/addons-napi/test_instanceof/test_instanceof.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <node_api.h> -#include <stdio.h> -#include "../common.h" - -napi_value doInstanceOf(napi_env env, napi_callback_info info) { - size_t argc = 2; - napi_value args[2]; - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); - - bool instanceof; - NAPI_CALL(env, napi_instanceof(env, args[0], args[1], &instanceof)); - - napi_value result; - NAPI_CALL(env, napi_get_boolean(env, instanceof, &result)); - - return result; -} - -void Init(napi_env env, napi_value exports, napi_value module, void* priv) { - napi_property_descriptor descriptors[] = { - DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf), - }; - - NAPI_CALL_RETURN_VOID(env, napi_define_properties( - env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors)); -} - -NAPI_MODULE(addon, Init) |