tweaking and fixing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-06-05 23:23:24 +03:00
parent 7f1ead5c7c
commit 2b599e0dbe
3 changed files with 41 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ig-test",
"version": "1.5.1",
"version": "1.5.3",
"description": "experimental test runner....",
"main": "test.js",
"bin": {

View File

@ -46,7 +46,9 @@ tests.Tests({
async: async function(assert, setup){
assert(setup, 'test')
await setup
assert.log(setup) },
assert.log(setup)
assert(setup, 'done')
},
})
@ -61,12 +63,33 @@ tests.Test('basic',
assert.log(setup)
})
tests.Case('async-completion',
async function(assert){
assert(true, 'start')
await assert(true, '1')
await assert(true, '2')
await assert(true, '3')
assert(true, 'done')
})
// a nested test set...
tests.Case('nested',
tests.TestSet(function(){
this.Case('moo', function(assert){
assert(true, 'nested dummy: assert') })
// XXX these can behave in an odd manner...
// $ ./test.js nested --verbose
// will prin the output of the sunc test while the async
// is waiting...
// ...not yet sure how to sequence these in a more predictable
// manner...
// ...this only affects output sequencing and not the actual
// execution flow...
this.Case('async', async function(assert){
assert(true, 'nested async: assert')
await 123
assert(true, 'nested async: done') })
this.Case('sync', function(assert){
assert(true, 'nested sync: assert') })
}))

26
test.js
View File

@ -559,12 +559,12 @@ module.merge =
//
// runner(spec)
// runner(spec, '*')
// -> stats
// -> promise(stats)
//
// runner(spec, 'case')
// runner(spec, 'setup:test')
// runner(spec, 'setup:mod:test')
// -> stats
// -> promise(stats)
//
//
// This will run
@ -650,7 +650,6 @@ async function(spec, chain, stats){
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)
@ -661,7 +660,8 @@ async function(spec, chain, stats){
[s, m, t]
// do not print blank pass-through ('-')
// components...
.filter(function(e){ return e != '-' }) )
.filter(function(e){
return e != '-' }) )
await tests[t](
_assert,
await modifiers[m](
@ -674,7 +674,8 @@ async function(spec, chain, stats){
Object.keys(cases)
.filter(function(s){
return typeof(cases[s]) == 'function'
&& (setup == '*' || setup == s) })
&& (setup == '*'
|| setup == s) })
: []
var assert = Assert('[CASE]', stats, module.VERBOSE)
for(var c of queue){
@ -952,7 +953,7 @@ argv.Parser({
//
var run =
module.run =
async function(default_files, tests){
function(default_files, tests){
// parse args -- run(tests)...
if(!(default_files instanceof Array
|| typeof(default_files) == typeof('str'))){
@ -988,11 +989,11 @@ async function(default_files, tests){
// XXX should this be generic???
.then(async function(chains){
// run the tests...
await (chains.length > 0 ?
Promise.all(chains
.map(function(chain){
return runner(tests, chain, stats) }))
: runner(tests, '*', stats))
if(chains.length > 0){
for(var chain of chains){
await runner(tests, chain, stats) }
} else {
await runner(tests, '*', stats) }
// print stats...
console.log(
@ -1002,8 +1003,7 @@ async function(default_files, tests){
` (${stats.time}ms)`.bold.black)
// report error status to the OS...
process.exit(stats.failures)
})
process.exit(stats.failures) })
.call() }