Skip to content

Commit

Permalink
test: consolidate n-api test addons
Browse files Browse the repository at this point in the history
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.

Backport-PR-URL: #19447
PR-URL: #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>
  • Loading branch information
mhdawson authored and MylesBorins committed Apr 16, 2018
1 parent 919556f commit 06cf948
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 72 deletions.
Expand Up @@ -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);
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions test/addons-napi/test_general/test_general.c
Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions test/addons-napi/test_globals/binding.gyp

This file was deleted.

26 changes: 0 additions & 26 deletions test/addons-napi/test_globals/test_globals.c

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_instanceof/binding.gyp

This file was deleted.

28 changes: 0 additions & 28 deletions test/addons-napi/test_instanceof/test_instanceof.c

This file was deleted.

0 comments on commit 06cf948

Please sign in to comment.