Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable unit tests #1078

Closed
wants to merge 1 commit into from
Closed

Conversation

deepakrkris
Copy link
Contributor

@deepakrkris deepakrkris commented Sep 23, 2021

Enable running tests with specific filter conditions:

Example:

  • compile ad run only tests on objectwrap.cc and objectwrap.js
    npm run unit --filter=objectwrap

Wildcards are also possible:

Example:

  • compile and run all tests files ending with reference -> function_reference.cc object_reference.cc reference.cc
    npm run unit --filter=*reference

Multiple filter conditions are also allowed

Example:

  • compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the objectwrap.cc file
    npm run unit --filter='*function objectwrap'

@deepakrkris
Copy link
Contributor Author

@mhdawson @KevinEady @gabrielschulhof PR is ready for review

package.json Outdated
@@ -378,7 +378,9 @@
"dev:incremental": "node test",
"doc": "doxygen doc/Doxyfile",
"lint": "eslint $(git diff --name-only refs/remotes/origin/main '**/*.js' | xargs) && node tools/clang-format",
"lint:fix": "node tools/clang-format --fix && eslint --fix $(git diff --cached --name-only '**/*.js' | xargs && git diff --name-only '**/*.js' | xargs)"
"lint:fix": "node tools/clang-format --fix && eslint --fix $(git diff --cached --name-only '**/*.js' | xargs && git diff --name-only '**/*.js' | xargs)",
"preunit": "filter=\"$npm_config_filter\" node-gyp rebuild -C unit-test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to copy $npm_config_filter into $filter? You can process $npm_config_filter directly in binding.gyp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabrielschulhof , I wanted to refer to the passed in argument "filter" by it's original name, because npm translates it into npm_config_filter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I understand. Still, I think for the simplicity of the command line it would be better to move this assignment into the JS file. So, like

// npm prepends "npm_config_" to all environment variables created from npm command line parameters.
let filter = process.env.npm_config_filter;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop "filter=\"$npm_config_filter\" because you're using process.env.npm_config_filter inside the script now.

test/index.js Outdated
@@ -29,9 +29,23 @@ if (typeof global.gc !== 'function') {

const fs = require('fs');
const path = require('path');
process.env.filter = require('../unit-test/matchModules').matchWildCards(process.env.filter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could easily be process.env.npm_config_filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabrielschulhof IMO using npm_config_filter seems slightly misleading, that is why I translated to "filter" , But I am open to changing this

@@ -0,0 +1,3 @@
/node_modules
/build
/generated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure there are newlines at the ends of files!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'dependencies': [ 'generateBindingCC' ]
},
],
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabrielschulhof thanks, agreed

@@ -0,0 +1,64 @@
{
'target_defaults': {
'includes': ['common.gypi'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ../common.gypi and then you don't need to copy the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 44 to 50
*
* Test cases
* @fires only when run directly from terminal with TEST=true
*
*
*
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the blank lines surrounding the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Comment on lines 11 to 17
*
* @returns : list of files to compile by node-gyp
* @param : none
* @requires : picks `filter` parameter from process.env
* This function is used as an utility method to inject a list of files to compile into binding.gyp
*
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Do we need the first and trailing blank lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabrielschulhof agreed , removing blank lines

* @param : none
* @requires : picks `filter` parameter from process.env
* This function is used as an utility method by the generateBindingCC step in binding.gyp
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Comment on lines 75 to 77
*
*
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these blank lines? Here and in all these comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

/*
* spawns a child process to run a given node.js script
*/
module.exports.runChildProcess = async function (scriptName, options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function doesn't need to be async if it returns a promise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be used from an async function without itself being marked as async.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@KevinEady KevinEady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

test/index.js Outdated
@@ -87,7 +108,7 @@ if (napiVersion < 3) {
testModules.splice(testModules.indexOf('version_management'), 1);
}

if (napiVersion < 4) {
if (napiVersion < 4 && !filterConditionFiles.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to check for !filterConditionFiles.length here (and in the lines below as well)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinEady I am using the array filterConditionFiles as a flag to, Not apply versioning for filtered tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinEady suppose I specifically run tests for only 'asyncprogressqueueworker', I would expect the tests to run even if it does not satisfy node version criteria (the tests would fail which is ok, I can upgrade local node version and try again)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't treat .length as a boolean!

Comment on lines +18 to +24
threadsafe: 'threadSafe',
objectwrap: 'objectWrap'
},
exportNames: {
AsyncWorkerPersistent: 'PersistentAsyncWorker'
},
propertyNames: {
async_worker_persistent: 'persistentasyncworker',
objectwrap_constructor_exception: 'objectwrapConstructorException'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we discuss standardizing the test files themselves so this sort of manual checks aren't needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinEady in some cases the exception from the standard form seems to be valid,
eg: persistentasyncworker is a good name to export from the test file async_worker_persistent

const workingDir = path.join(__dirname, '../');
const relativeBuildPath = path.join('../', 'unit-test');
const buildPath = path.join(__dirname, './unit-test');
const envVars = { ...process.env, REL_BUILD_PATH: relativeBuildPath, BUILD_PATH: buildPath };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed to have both REL_BUILD_PATH and BUILD_PATH ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinEady yes, the relative build path is required in a specific case in test/index.js where it determines the target build configuration (DEBUG or RELEASE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build path is necessary to import the test modules and run tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still a little confused as to why you can't you also use the relative path instead of introducing more variables?

Copy link
Contributor Author

@deepakrkris deepakrkris Oct 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinEady in

.readdirSync(path.join(__dirname, process.env.REL_BUILD_PATH || '', 'build'))
, a relative path from the test folder is required to a build folder :

              -----> ./build
test ----
              -----> ../unit/ -> /build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that path reference is different from the path reference in

exports.runTest = async function (test, buildType, buildPathRoot = process.env.BUILD_PATH || '') {

where we need the complete root to a build path

Comment on lines 20 to 25
// content.push("Object InitName(Env env);");
inits.forEach(init => content.push(init));

content.push('Object Init(Env env, Object exports) {');

// content.push("exports.Set(\"name\", InitName(env));");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

generateBindingConfigurations().then(generateFileContent).then(writeToBindingFile);

/**
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also at the end of this comment as well

@deepakrkris
Copy link
Contributor Author

@gabrielschulhof @KevinEady I have responded to all comments, please let me know your feedback

@mhdawson
Copy link
Member

@gabrielschulhof @KevinEady do you want to have another look before this lands?

package.json Outdated
@@ -378,7 +378,9 @@
"dev:incremental": "node test",
"doc": "doxygen doc/Doxyfile",
"lint": "eslint $(git diff --name-only refs/remotes/origin/main '**/*.js' | xargs) && node tools/clang-format",
"lint:fix": "node tools/clang-format --fix && eslint --fix $(git diff --cached --name-only '**/*.js' | xargs && git diff --name-only '**/*.js' | xargs)"
"lint:fix": "node tools/clang-format --fix && eslint --fix $(git diff --cached --name-only '**/*.js' | xargs && git diff --name-only '**/*.js' | xargs)",
"preunit": "filter=\"$npm_config_filter\" node-gyp rebuild -C unit-test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I understand. Still, I think for the simplicity of the command line it would be better to move this assignment into the JS file. So, like

// npm prepends "npm_config_" to all environment variables created from npm command line parameters.
let filter = process.env.npm_config_filter;

exports.mustNotCall = function(msg) {
return function mustNotCall() {
exports.mustNotCall = function (msg) {
return function mustNotCall () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of whitespace changes that inflate the diff. Are they the result of running a linter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the result of running the linter ☺

@deepakrkris
Copy link
Contributor Author

@gabrielschulhof I have changed the npm_config_filter refererence now.

#1078 (comment)

@KevinEady
Copy link
Contributor

So, some of the addons don't run correctly in unit-test mode. I think we can tackle that at a later date. However, I think there is a bigger issue in that a failed unit test exits the npm run unit --filter=<filter> process successfully:

➜  node-addon-api git:(b398038) ✗ npm run unit --filter=addon ; echo "Return code: $?"


> [email protected] preunit /Users/kevineady/Documents/Projects/node-addon-api
> filter="$npm_config_filter" node-gyp rebuild -C unit-test

  ACTION Generating binding cc file generated/binding.cc
test modules to bind:  [ 'addon' ]
generated binding file  /Users/kevineady/Documents/Projects/node-addon-api/unit-test/generated/binding.cc 2021-12-03T15:40:16.308Z
  TOUCH Release/obj.target/generateBindingCC.stamp
  CXX(target) Release/obj.target/binding/generated/binding.o
  CXX(target) Release/obj.target/binding/../test/addon.o
  SOLINK_MODULE(target) Release/binding.node
  CXX(target) Release/obj.target/binding_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept.node
  CXX(target) Release/obj.target/binding_noexcept_maybe/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept_maybe/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept_maybe.node
  CXX(target) Release/obj.target/binding_swallowexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept.node
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept_noexcept.node

> [email protected] unit /Users/kevineady/Documents/Projects/node-addon-api
> filter="$npm_config_filter" node unit-test/test

Starting to run tests in  /Users/kevineady/Documents/Projects/node-addon-api/unit-test/unit-test 2021-12-03T15:40:22.515Z
napiVersion:5

Testing with Node-API Version '5'.

Starting test suite
 [ 'addon' ]

Running test 'addon'

error: dyld: lazy symbol binding failed: Symbol not found: __Z9InitAddonN4Napi3EnvE
  Referenced from: /Users/kevineady/Documents/Projects/node-addon-api/unit-test/build/Release/binding.node
  Expected in: flat namespace

dyld: Symbol not found: __Z9InitAddonN4Napi3EnvE
  Referenced from: /Users/kevineady/Documents/Projects/node-addon-api/unit-test
error: /build/Release/binding.node
  Expected in: flat namespace


error: Tests aborted with SIGABRT

child process exited with code 1
Completed running tests 2021-12-03T15:40:24.973Z
Return code: 0

I think this is a blocker for merging the PR, as the return value should signify if the test passes or not.

@gabrielschulhof
Copy link
Contributor

@deepakrkris please also remove the aliasing of npm_config_filter to filter from the command lines in package.json.

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as Request changes per @KevinEady's comment about returning success even on error. Please dismiss when the problem is fixed!

@deepakrkris
Copy link
Contributor Author

@deepakrkris please also remove the aliasing of npm_config_filter to filter from the command lines in package.json.

@gabrielschulhof I have fixed this now

@deepakrkris
Copy link
Contributor Author

Marking as Request changes per @KevinEady's comment about returning success even on error. Please dismiss when the problem is fixed!

@KevinEady @gabrielschulhof I have fixed this now

@deepakrkris
Copy link
Contributor Author

@KevinEady I am able verify the fix as below

SFOC02CC4L3MD6T:node-addon-api t_rajad$ npm run unit --filter=addon ; echo "Return code: $?"

> [email protected] preunit /Users/t_rajad/projects/AA-NAPI/node-addon-api
> node-gyp rebuild -C unit-test

  ACTION Generating binding cc file generated/binding.cc
test modules to bind:  [ 'addon' ]
generated binding file  /Users/t_rajad/projects/AA-NAPI/node-addon-api/unit-test/generated/binding.cc 2021-12-10T15:48:28.973Z
  TOUCH Release/obj.target/generateBindingCC.stamp
  CXX(target) Release/obj.target/binding/generated/binding.o
  CXX(target) Release/obj.target/binding/../test/addon.o
  SOLINK_MODULE(target) Release/binding.node
  CXX(target) Release/obj.target/binding_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept.node
  CXX(target) Release/obj.target/binding_noexcept_maybe/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept_maybe/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept_maybe.node
  CXX(target) Release/obj.target/binding_swallowexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept.node
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept_noexcept.node

> [email protected] unit /Users/t_rajad/projects/AA-NAPI/node-addon-api
> node unit-test/test

Starting to run tests in  /Users/t_rajad/projects/AA-NAPI/node-addon-api/unit-test/unit-test 2021-12-10T15:48:38.701Z
napiVersion:7

Testing with Node-API Version '7'.

Starting test suite
 [ 'addon' ]
Running test 'addon'

TypeError: binding.addon.increment1 is not a function
    at test (/Users/t_rajad/projects/AA-NAPI/node-addon-api/test/addon.js:8:36)
    at Object.exports.runTest (/Users/t_rajad/projects/AA-NAPI/node-addon-api/test/common/index.js:88:27)
    at Object.<anonymous> (/Users/t_rajad/projects/AA-NAPI/node-addon-api/test/addon.js:5:38)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /Users/t_rajad/projects/AA-NAPI/node-addon-api/test/index.js:150:11

child process exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] unit: `node unit-test/test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/t_rajad/.npm/_logs/2021-12-10T15_48_39_018Z-debug.log
Return code: 1

@KevinEady KevinEady self-requested a review December 10, 2021 16:04
Copy link
Contributor

@KevinEady KevinEady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We should figure out why individual unit tests fail, but I think that can come at a different time.

I have verified the return code is now non-zero for failed unit tests:

➜  node-addon-api git:(bc7622e) ✗ npm run unit --filter=addon ; echo "Return code: $?"


> [email protected] preunit /Users/kevineady/Documents/Projects/node-addon-api
> node-gyp rebuild -C unit-test

  ACTION Generating binding cc file generated/binding.cc
test modules to bind:  [ 'addon' ]
generated binding file  /Users/kevineady/Documents/Projects/node-addon-api/unit-test/generated/binding.cc 2021-12-10T16:03:38.620Z
  TOUCH Release/obj.target/generateBindingCC.stamp
  CXX(target) Release/obj.target/binding/generated/binding.o
  CXX(target) Release/obj.target/binding/../test/addon.o
  SOLINK_MODULE(target) Release/binding.node
  CXX(target) Release/obj.target/binding_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept.node
  CXX(target) Release/obj.target/binding_noexcept_maybe/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept_maybe/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept_maybe.node
  CXX(target) Release/obj.target/binding_swallowexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept.node
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept_noexcept.node

> [email protected] unit /Users/kevineady/Documents/Projects/node-addon-api
> node unit-test/test

Starting to run tests in  /Users/kevineady/Documents/Projects/node-addon-api/unit-test/unit-test 2021-12-10T16:03:49.692Z
napiVersion:5

Testing with Node-API Version '5'.

Starting test suite
 [ 'addon' ]

Running test 'addon'

error: dyld: lazy symbol binding failed: Symbol not found: __Z9InitAddonN4Napi3EnvE
  Referenced from: /Users/kevineady/Documents/Projects/node-addon-api/unit-test/build/Release/binding.node
  Expected in: flat namespace

dyld: Symbol not found: __Z9InitAddonN4Napi3EnvE
  Referenced from: /Users/kevineady/Documents/Projects/node-addon-api/unit-test/build/Release/binding.node
  Expected in: flat namespace


error: Tests aborted with SIGABRT

child process exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] unit: `node unit-test/test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kevineady/.npm/_logs/2021-12-10T16_03_50_458Z-debug.log

Return code: 1

@deepakrkris
Copy link
Contributor Author

@KevinEady I cloned the repo (from my fork) freshly and the unit test with filter=addon runs good


> [email protected] preunit /Users/t_rajad/projects/AA-NAPI/node-addon-api
> node-gyp rebuild -C unit-test

  ACTION Generating binding cc file generated/binding.cc
test modules to bind:  [ 'addon' ]
generated binding file  /Users/t_rajad/projects/AA-NAPI/node-addon-api/unit-test/generated/binding.cc 2021-12-17T15:54:59.530Z
  TOUCH Release/obj.target/generateBindingCC.stamp
  CXX(target) Release/obj.target/binding/generated/binding.o
  CXX(target) Release/obj.target/binding/../test/addon.o
  SOLINK_MODULE(target) Release/binding.node
  CXX(target) Release/obj.target/binding_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept.node
  CXX(target) Release/obj.target/binding_noexcept_maybe/generated/binding.o
  CXX(target) Release/obj.target/binding_noexcept_maybe/../test/addon.o
  SOLINK_MODULE(target) Release/binding_noexcept_maybe.node
  CXX(target) Release/obj.target/binding_swallowexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept.node
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/generated/binding.o
  CXX(target) Release/obj.target/binding_swallowexcept_noexcept/../test/addon.o
  SOLINK_MODULE(target) Release/binding_swallowexcept_noexcept.node

> [email protected] unit /Users/t_rajad/projects/AA-NAPI/node-addon-api
> node unit-test/test

Starting to run tests in  /Users/t_rajad/projects/AA-NAPI/node-addon-api/unit-test/unit-test 2021-12-17T15:55:08.468Z
napiVersion:7

Testing with Node-API Version '7'.

Starting test suite
 [ 'addon' ]
Running test 'addon'


All tests passed!

child process exited with code 0
SFOC02CC4L3MD6T:node-addon-api t_rajad$ 

@deepakrkris
Copy link
Contributor Author

@KevinEady I cloned the forked branch and worked on it. Is there another way you have cloned the repo like say cloning the root repo and then checking out to a forked branch ? I can try that as well.

test/index.js Outdated
let filterCondition = process.env.npm_config_filter || '';
let filterConditionFiles = [];

if (process.env.npm_config_filter !== null && process.env.npm_config_filter !== undefined && process.env.npm_config_filter.trim() !== '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not if (filterCondition != null && ...), accounting for the fact that the default is '' and not null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

test/index.js Outdated

if (process.env.npm_config_filter !== null && process.env.npm_config_filter !== undefined && process.env.npm_config_filter.trim() !== '') {
filterCondition = require('../unit-test/matchModules').matchWildCards(process.env.npm_config_filter);
filterConditionFiles = filterCondition.split(' ').length ? filterCondition.split(' ') : [filterCondition];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make this check explicitly > 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

test/index.js Outdated
function checkFilterCondition (fileName, parsedFilepath) {
let result = false;

if (!filterConditionFiles.length) result = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (> 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

test/index.js Outdated
@@ -87,7 +108,7 @@ if (napiVersion < 3) {
testModules.splice(testModules.indexOf('version_management'), 1);
}

if (napiVersion < 4) {
if (napiVersion < 4 && !filterConditionFiles.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't treat .length as a boolean!

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawson
Copy link
Member

@deepakrkris I see there are a few final comments from @gabrielschulhof . If you can address those I'll land.

@mhdawson
Copy link
Member

@deepakrkris if you can squash down to 1 commit that would also make it much easier for me to land and it seems individual commits have conflicts.

@mhdawson
Copy link
Member

@deepakrkris ran the ci jobs https://ci.nodejs.org/job/node-test-node-addon-api-new/ for latest branch and 12.x and all seems ok so we should be good once you update the last few comments. If you can email me once you do that that will help me get to sooner.

@deepakrkris
Copy link
Contributor Author

@deepakrkris I see there are a few final comments from @gabrielschulhof . If you can address those I'll land.

@mhdawson sure, I will fix the comments and ping here in a few hours, thank you

@deepakrkris
Copy link
Contributor Author

@deepakrkris if you can squash down to 1 commit that would also make it much easier for me to land and it seems individual commits have conflicts.

@mhdawson I have fixed comments from Gabriel and squashed the commits

@deepakrkris
Copy link
Contributor Author

deepakrkris commented Jan 28, 2022

#1078 (comment) , @gabrielschulhof agreed, fixed the comments now

@mhdawson
Copy link
Member

Landed as 744c8d2

@mhdawson mhdawson closed this Jan 31, 2022
deepakrkris added a commit to deepakrkris/node-addon-api that referenced this pull request Aug 19, 2022
Document all possible filter conditions added in nodejs#1078
mhdawson pushed a commit that referenced this pull request Aug 19, 2022
* Update Readme for filter conditions in unit tests

Document all possible filter conditions added in #1078

PR-URL:#1199
Reviewed-By: Michael Dawson <[email protected]>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
* Update Readme for filter conditions in unit tests

Document all possible filter conditions added in nodejs/node-addon-api#1078

PR-URL:nodejs/node-addon-api#1199
Reviewed-By: Michael Dawson <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
* Update Readme for filter conditions in unit tests

Document all possible filter conditions added in nodejs/node-addon-api#1078

PR-URL:nodejs/node-addon-api#1199
Reviewed-By: Michael Dawson <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
* Update Readme for filter conditions in unit tests

Document all possible filter conditions added in nodejs/node-addon-api#1078

PR-URL:nodejs/node-addon-api#1199
Reviewed-By: Michael Dawson <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
* Update Readme for filter conditions in unit tests

Document all possible filter conditions added in nodejs/node-addon-api#1078

PR-URL:nodejs/node-addon-api#1199
Reviewed-By: Michael Dawson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants