Skip to content

Commit

Permalink
improve node runner of compat data tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 30, 2022
1 parent 3a11070 commit c65106c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"check-modules-by-versions": "zx scripts/check-compat-data-modules-by-versions.mjs",
"check-unused-modules": "zx scripts/check-unused-modules.mjs",
"check": "run-s check-unused-modules check-compat-tests check-modules-by-versions check-mapping check-dependencies",
"compat": "node tests/compat/node-runner",
"generate-indexes": "zx scripts/generate-indexes.mjs",
"lint": "run-s init test-lint",
"test-lint": "eslint --ext .js,.mjs,.json ./",
Expand Down
20 changes: 13 additions & 7 deletions tests/compat/node-runner.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
/* eslint-disable no-console -- output */
require('./tests');
var tests = global.tests;
var result = {};

for (var key in tests) {
var test = tests[key];
for (var name in tests) {
var test = tests[name];
try {
if (typeof test == 'function') {
result[key] = !!test();
} else result[key] = test.reduce(function (accumulator, $test) {
result[name] = !!test();
} else result[name] = test.reduce(function (accumulator, $test) {
return accumulator && !!$test();
}, true);
} catch (error) {
result[key] = false;
result[name] = false;
}
}

// eslint-disable-next-line no-console -- output
console.log(JSON.stringify(result, null, ' '));
if (process.argv.indexOf('--mode=JSON') !== -1) {
console.log(JSON.stringify(result, null, ' '));
} else for (var name in result) {
var filled = name + ' | '.slice(name.length);
if (result[name]) console.log('\u001B[32m' + filled + 'not required\u001B[0m');
else console.log('\u001B[31m' + filled + 'required\u001B[0m');
}

0 comments on commit c65106c

Please sign in to comment.