From b81a214172a77ca7c162f6ec124aa7b958b20acf Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 30 Dec 2025 00:29:17 +0300 Subject: [PATCH] refactoring and cleanup -- added support for '**' to explicitly indicate all tests... Signed-off-by: Alex A. Naanou --- package-lock.json | 173 ++++++++++++---------------------------------- package.json | 2 +- test.js | 90 ++++++++++++++++-------- 3 files changed, 108 insertions(+), 157 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7bc687..f250804 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ig-test", - "version": "1.5.9", - "lockfileVersion": 2, + "version": "1.6.3", + "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ig-test", - "version": "1.5.9", + "version": "1.6.3", "license": "BSD-3-Clause", "dependencies": { "colors": "1.4.0", @@ -19,14 +19,16 @@ } }, "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -36,6 +38,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "license": "MIT", "engines": { "node": ">=0.1.90" } @@ -43,22 +46,26 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "license": "MIT" }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "license": "ISC" }, "node_modules/glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -70,22 +77,26 @@ } }, "node_modules/ig-argv": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.16.3.tgz", - "integrity": "sha512-58WBfqqXNL6KV4CaSVmFAizqYd0ymGANe0F+d/Zue2JHXOpolB6jwY0glrzU09THZjipnNnB+LlUxYwcwDeTwA==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.17.2.tgz", + "integrity": "sha512-EGm3Sx1vo9gnQKh2CJKdyNyY0IsKljz2zTUt1SV3BrErtRvFz3WuH5ltoD0ErSEUmyY5mtOklTrFSmXqA2joLQ==", + "license": "BSD-3-Clause", "dependencies": { - "ig-object": "^5.2.6" + "ig-object": "^5.4.16" } }, "node_modules/ig-object": { - "version": "5.4.16", - "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.16.tgz", - "integrity": "sha512-qxAWSFdwE0PeBh5Ws+pyX3SxJrwqratEIDrSg5odcHdUVFTzATMJImH2L8bMaDhxaQJj5ogoZc+lx56UIpXJ1g==" + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.6.0.tgz", + "integrity": "sha512-5MAUWSwfHKQNrgLroXxBHjlhrhVbhzlVqvUcfMDjUeK/ufWQ9THE0HDcvhfu+YrPfRjTR2QpD2Ygp+2H4O0C6g==", + "license": "BSD-3-Clause" }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "license": "ISC", "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -94,12 +105,14 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -110,7 +123,8 @@ "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", "dependencies": { "wrappy": "1" } @@ -118,7 +132,8 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -126,104 +141,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - } - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "ig-argv": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.16.3.tgz", - "integrity": "sha512-58WBfqqXNL6KV4CaSVmFAizqYd0ymGANe0F+d/Zue2JHXOpolB6jwY0glrzU09THZjipnNnB+LlUxYwcwDeTwA==", - "requires": { - "ig-object": "^5.2.6" - } - }, - "ig-object": { - "version": "5.4.16", - "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.16.tgz", - "integrity": "sha512-qxAWSFdwE0PeBh5Ws+pyX3SxJrwqratEIDrSg5odcHdUVFTzATMJImH2L8bMaDhxaQJj5ogoZc+lx56UIpXJ1g==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" } } } diff --git a/package.json b/package.json index 95cdf02..8a60e66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-test", - "version": "1.6.3", + "version": "1.6.4", "description": "experimental test runner....", "main": "test.js", "bin": { diff --git a/test.js b/test.js index 82ceed0..637f88a 100644 --- a/test.js +++ b/test.js @@ -262,7 +262,8 @@ object.Constructor('Assert', { //--------------------------------------------------------------------- // XXX -var mergeIter = function(iter){ +var mergeIter = +function(iter){ return function(c){ c = c || this return (c.members || []) @@ -431,21 +432,31 @@ function(spec){ var parseChain = module.parseChain = function(chain){ + if(chain == '**' + || chain == null){ + return '**' } + // parse chain... - chain = (chain == '*' || chain == null) ? - [] - : chain chain = chain instanceof Array ? chain : chain.split(/:/) + + // test-case... + if(chain.length == 1){ + return { + test_case: chain[0], + length: 1, + } } + + // test chain... var length = chain.length var setup = chain.shift() || '*' var test = chain.pop() || '*' var mod = chain || '*' mod = length == 2 ? 'as-is' - : mod.length == 1 - && mod[0] == '*' ? + : mod.length == 0 + || mod[0] == '*' ? '*' : mod @@ -477,14 +488,15 @@ function(spec, chain, mod_chain_length=1){ object.deepKeys(tests) .filter(function(t, i, l){ return typeof(tests[t]) == 'function' - // skip blank tests if we have other tests unless - // explicitly specified... - && ((t == '-' - && chain.test != t - && l.length > 1) ? - false - : (chain.test == '*' - || chain.test == t) ) }) + // skip blank tests if we have other tests unless + // explicitly specified... + && ((t == '-' + && chain.test != t + && l.length > 1) ? + false + : (chain == '**' + || chain.test == '*' + || chain.test == t) ) }) var mod_queue = [] if(mod_chain_length > 0){ if(chain.mod instanceof Array){ @@ -493,7 +505,9 @@ function(spec, chain, mod_chain_length=1){ mod_queue = object.deepKeys(modifiers) .filter(function(m){ return typeof(modifiers[m]) == 'function' - && (chain.mod == '*' || chain.mod == m) }) + && (chain == '**' + || chain.mod == '*' + || chain.mod == m) }) .map(function(m){ return [m] }) // modifier chains... @@ -509,11 +523,14 @@ function(spec, chain, mod_chain_length=1){ var setup_queue = object.deepKeys(setups) .filter(function(s){ return typeof(setups[s]) == 'function' - && (chain.setup == '*' || chain.setup == s) }) + && (chain == '**' + || chain.setup == '*' + || chain.setup == s) }) return { chain, - tests: chain.length != 1 ? + tests: (chain == '**' + || chain.length != 1) ? test_queue .map(function(t){ return mod_queue.length == 0 ? @@ -527,11 +544,13 @@ function(spec, chain, mod_chain_length=1){ return [s, m, t] }) }) }) .flat(2) : [], - cases: chain.length == 1 ? + cases: (chain == '**' + || chain.length == 1) ? Object.keys(cases) .filter(function(s){ return typeof(cases[s]) == 'function' - && (chain.setup == '*' + && (chain == '**' + || chain.setup == '*' || chain.setup == s) }) : [], } } @@ -558,11 +577,9 @@ function(spec, chain, mod_chain_length=1){ // for each case in spec.cases // // -// XXX make Assert optional... -// XXX is this a good name??? var runTests = module.runTests = -async function(spec, chain, stats, mod_chain_length=1, Assert=module.Assert){ +async function(spec, chain, stats, mod_chain_length=1, assert){ var {setups, modifiers, tests, cases} = getTests(spec) // setup stats... @@ -580,11 +597,14 @@ async function(spec, chain, stats, mod_chain_length=1, Assert=module.Assert){ // NOTE: we are not running these via .map(..) to keep things in // sequence... - assert = Assert('[TEST]', stats, module.VERBOSE) + var test_assert = assert == null ? + module.Assert('[TEST]', stats, module.VERBOSE) + // XXX is this a good indicator??? + : assert.push('[TEST]') for(var [s, m, t] of queue.tests){ // run the test... stats.tests += 1 - var _assert = assert.push( + var _assert = test_assert.push( [s, ...m, t] // do not print blank pass-through ('-') // components... @@ -596,10 +616,13 @@ async function(spec, chain, stats, mod_chain_length=1, Assert=module.Assert){ await tests[t](_assert, d) } // cases... - assert = Assert('[CASE]', stats, module.VERBOSE) + var case_assert = assert == null ? + module.Assert('[CASE]', stats, module.VERBOSE) + // XXX is this a good indicator??? + : assert.push('[CASE]') for(var c of queue.cases){ stats.tests += 1 - await cases[c](assert.push(c)) } + await cases[c](case_assert.push(c)) } // runtime... stats.time += Date.now() - started @@ -629,7 +652,7 @@ object.Constructor('TestSet', { __assert__: Assert, // XXX nested assert(..) need to report nestedness correctly... - __call__: async function(chain, stats, mod_chain_length=1){ + __call__: async function(_, chain, stats, mod_chain_length=1){ var assert = this.__assert__ // running nested... if(typeof(chain) == 'function'){ @@ -722,7 +745,15 @@ argv.Parser({ Zero or more sets of tests can be specified. - When no tests specified $SCRIPTNAME will run all tests. + If no tests are specified or '**' is given $SCRIPTNAME will run + all found tests: + + $ ./$SCRIPTNAME + or: + $ ./$SCRIPTNAME '**' + + Note that using '*' or '**' may require escaping as they may + get expanded by the shell. `, examples: [ ['$ ./$SCRIPTNAME', @@ -923,6 +954,7 @@ argv.Parser({ || [] } }, + '-v': '-verbose', '-verbose': { doc: 'verbose mode', env: 'VERBOSE', @@ -1010,7 +1042,7 @@ function(default_files, tests){ await runTests(tests, chain, stats, this.mod_chain_length) } //await module.BASE_TEST_SET(tests, chain, stats) } } else { - await runTests(tests, '*', stats, this.mod_chain_length) } + await runTests(tests, '**', stats, this.mod_chain_length) } //await module.BASE_TEST_SET(tests, '*', stats) } // XXX BUG for some reason we can get here BEFORE all the