diff --git a/package.json b/package.json index 8c443ac..45c8dd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-test", - "version": "1.5.0", + "version": "1.5.1", "description": "experimental test runner....", "main": "test.js", "bin": { diff --git a/test-test.js b/test-test.js index 785b297..316988b 100644 --- a/test-test.js +++ b/test-test.js @@ -28,10 +28,9 @@ tests.Setups({ return {setup: 'setup2'} }, async: async function(assert){ assert(true, 'setup') - return {setup: 'async'} }, + return await {setup: 'async'} }, }) - tests.Modifiers({ sync: function(assert, setup){ assert(setup, 'modifier') @@ -40,7 +39,14 @@ tests.Modifiers({ async: async function(assert, setup){ assert(setup, 'modifier') setup.mod = 'async' - return setup }, + return await setup }, +}) + +tests.Tests({ + async: async function(assert, setup){ + assert(setup, 'test') + await setup + assert.log(setup) }, }) @@ -55,12 +61,6 @@ tests.Test('basic', assert.log(setup) }) -tests.Tests({ - async: async function(assert, setup){ - assert(setup, 'test') - assert.log(setup) - }, -}) // a nested test set... tests.Case('nested', diff --git a/test.js b/test.js index a5afdee..4f7f321 100644 --- a/test.js +++ b/test.js @@ -621,55 +621,66 @@ async function(spec, chain, stats){ var started = Date.now() // tests... + var queue = + 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 == '-' + && test != t + && l.length > 1) ? + false + : (test == '*' + || test == t) ) }) + .map(function(t){ + // modifiers... + return object.deepKeys(modifiers) + .filter(function(m){ + return typeof(modifiers[m]) == 'function' + && (mod == '*' || mod == m) }) + .map(function(m){ + // setups... + return object.deepKeys(setups) + .filter(function(s){ + return typeof(setups[s]) == 'function' + && (setup == '*' || setup == s) }) + .map(function(s){ + return [s, m, t] }) }) }) + .flat(2) + : [] + // run the test queue... + // NOTE: we are not running these via .map(..) to keep things in + // sequence... var assert = Assert('[TEST]', stats, module.VERBOSE) - chain_length != 1 - && await Promise.all(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 == '-' - && test != t - && l.length > 1) ? - false - : (test == '*' - || test == t) ) }) - .map(function(t){ - // modifiers... - return object.deepKeys(modifiers) - .filter(function(m){ - return typeof(modifiers[m]) == 'function' - && (mod == '*' || mod == m) }) - .map(function(m){ - // setups... - return object.deepKeys(setups) - .filter(function(s){ - return typeof(setups[s]) == 'function' - && (setup == '*' || setup == s) }) - .map(async function(s){ - // run the test... - stats.tests += 1 - var _assert = assert.push( - [s, m, t] - // do not print blank pass-through ('-') - // components... - .filter(function(e){ return e != '-' }) ) - return tests[t]( - _assert, - await modifiers[m]( - _assert, - await setups[s](_assert))) }) }) }) - .flat(Infinity)) + for(var [s, m, t] of queue){ + // run the test... + stats.tests += 1 + var _assert = assert.push( + [s, m, t] + // do not print blank pass-through ('-') + // components... + .filter(function(e){ return e != '-' }) ) + await tests[t]( + _assert, + await modifiers[m]( + _assert, + await setups[s](_assert))) } + // cases... + var queue = + chain_length <= 1 ? + Object.keys(cases) + .filter(function(s){ + return typeof(cases[s]) == 'function' + && (setup == '*' || setup == s) }) + : [] var assert = Assert('[CASE]', stats, module.VERBOSE) - chain_length <= 1 - && await Promise.all(Object.keys(cases) - .filter(function(s){ - return typeof(cases[s]) == 'function' - && (setup == '*' || setup == s) }) - .map(function(c){ - stats.tests += 1 - return cases[c]( assert.push(c) ) })) + for(var c of queue){ + stats.tests += 1 + await cases[c]( assert.push(c) ) } + // runtime... stats.time += Date.now() - started return stats }