Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Rajamohan committed Jan 28, 2022
1 parent bc7622e commit 8dcdcc6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ const path = require('path');
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() !== '') {
if (filterCondition !== '') {
filterCondition = require('../unit-test/matchModules').matchWildCards(process.env.npm_config_filter);
filterConditionFiles = filterCondition.split(' ').length ? filterCondition.split(' ') : [filterCondition];
filterConditionFiles = filterCondition.split(' ').length > 0 ? filterCondition.split(' ') : [filterCondition];
}

const filterConditionsProvided = filterConditionFiles.length > 0;

function checkFilterCondition (fileName, parsedFilepath) {
let result = false;

if (!filterConditionFiles.length) result = true;
if (!filterConditionsProvided) return true;
if (filterConditionFiles.includes(parsedFilepath)) result = true;
if (filterConditionFiles.includes(fileName)) result = true;
return result;
Expand Down Expand Up @@ -108,7 +110,7 @@ if (napiVersion < 3) {
testModules.splice(testModules.indexOf('version_management'), 1);
}

if (napiVersion < 4 && !filterConditionFiles.length) {
if (napiVersion < 4 && !filterConditionsProvided) {
testModules.splice(testModules.indexOf('asyncprogressqueueworker'), 1);
testModules.splice(testModules.indexOf('asyncprogressworker'), 1);
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function_ctx'), 1);
Expand All @@ -119,30 +121,30 @@ if (napiVersion < 4 && !filterConditionFiles.length) {
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function'), 1);
}

if (napiVersion < 5 && !filterConditionFiles.length) {
if (napiVersion < 5 && !filterConditionsProvided) {
testModules.splice(testModules.indexOf('date'), 1);
}

if (napiVersion < 6 && !filterConditionFiles.length) {
if (napiVersion < 6 && !filterConditionsProvided) {
testModules.splice(testModules.indexOf('addon'), 1);
testModules.splice(testModules.indexOf('addon_data'), 1);
testModules.splice(testModules.indexOf('bigint'), 1);
testModules.splice(testModules.indexOf('typedarray-bigint'), 1);
}

if (majorNodeVersion < 12 && !filterConditionFiles.length) {
if (majorNodeVersion < 12 && !filterConditionsProvided) {
testModules.splice(testModules.indexOf('objectwrap_worker_thread'), 1);
testModules.splice(testModules.indexOf('error_terminating_environment'), 1);
}

if (napiVersion < 8 && !filterConditionFiles.length) {
if (napiVersion < 8 && !filterConditionsProvided) {
testModules.splice(testModules.indexOf('object/object_freeze_seal'), 1);
}

(async function () {
console.log(`Testing with Node-API Version '${napiVersion}'.`);

if (filterConditionFiles.length) { console.log('Starting test suite\n', testModules); } else { console.log('Starting test suite\n'); }
if (filterConditionsProvided) { console.log('Starting test suite\n', testModules); } else { console.log('Starting test suite\n'); }

// Requiring each module runs tests in the module.
for (const name of testModules) {
Expand Down

0 comments on commit 8dcdcc6

Please sign in to comment.