mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 02:10:08 +00:00
bugfix -- now seems to be working...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2b599e0dbe
commit
f4c7e9b5e3
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-test",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"description": "experimental test runner....",
|
||||
"main": "test.js",
|
||||
"bin": {
|
||||
|
||||
23
test-test.js
23
test-test.js
@ -64,13 +64,32 @@ tests.Test('basic',
|
||||
})
|
||||
|
||||
tests.Case('async-completion',
|
||||
async function(assert){
|
||||
async function(assert){
|
||||
assert(true, 'start')
|
||||
await assert(true, '1')
|
||||
await assert(true, '2')
|
||||
await assert(true, '3')
|
||||
assert(true, 'done')
|
||||
})
|
||||
})
|
||||
|
||||
tests.Case('async-completion-nested',
|
||||
tests.TestSet(function(){
|
||||
this.Setup({
|
||||
empty: function(){
|
||||
return true
|
||||
},
|
||||
})
|
||||
// XXX if this is the last test we will not do all the assertions...
|
||||
this.Test('test', async function(assert){
|
||||
assert(true, 'start')
|
||||
await assert(true, '1')
|
||||
await assert(true, '2')
|
||||
await assert(true, '3')
|
||||
await assert(true, '4')
|
||||
await assert(true, '5')
|
||||
assert(true, 'done')
|
||||
})
|
||||
}))
|
||||
|
||||
// a nested test set...
|
||||
tests.Case('nested',
|
||||
|
||||
101
test.js
101
test.js
@ -400,7 +400,8 @@ object.Constructor('TestSet', {
|
||||
// XXX nested assert(..) need to report nestedness correctly...
|
||||
// XXX should/can this return a meaningfull result for it to be used
|
||||
// as a setup/mod???
|
||||
__call__: function(context, chain, stats){
|
||||
// XXX this is very similar to runner(..)...
|
||||
__call__: async function(context, chain, stats){
|
||||
var assert
|
||||
// running nested...
|
||||
if(typeof(chain) == 'function'){
|
||||
@ -446,53 +447,58 @@ object.Constructor('TestSet', {
|
||||
// XXX revise nested assert...
|
||||
var assert = assert
|
||||
|| this.__assert__('[TEST]', stats, module.VERBOSE)
|
||||
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) ) })
|
||||
.forEach(function(t){
|
||||
// modifiers...
|
||||
object.deepKeys(modifiers)
|
||||
.filter(function(m){
|
||||
return typeof(modifiers[m]) == 'function'
|
||||
&& (mod == '*' || mod == m) })
|
||||
.forEach(function(m){
|
||||
// setups...
|
||||
object.deepKeys(setups)
|
||||
.filter(function(s){
|
||||
return typeof(setups[s]) == 'function'
|
||||
&& (setup == '*' || setup == s) })
|
||||
.forEach(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 != '-' }) )
|
||||
tests[t](_assert,
|
||||
modifiers[m](_assert,
|
||||
setups[s](_assert))) }) }) })
|
||||
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)
|
||||
: []
|
||||
for(var [s, m, t] of queue){
|
||||
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...
|
||||
// XXX revise nested assert...
|
||||
assert = assert
|
||||
|| this.__assert__('[CASE]', stats, module.VERBOSE)
|
||||
chain_length <= 1
|
||||
&& Object.keys(cases)
|
||||
.filter(function(s){
|
||||
return typeof(cases[s]) == 'function'
|
||||
&& (setup == '*' || setup == s) })
|
||||
.forEach(function(c){
|
||||
stats.tests += 1
|
||||
cases[c]( assert.push(c) ) })
|
||||
var queue =
|
||||
chain_length <= 1 ?
|
||||
Object.keys(cases)
|
||||
.filter(function(s){
|
||||
return typeof(cases[s]) == 'function'
|
||||
&& (setup == '*' || setup == s) })
|
||||
: []
|
||||
for(var c of queue){
|
||||
stats.tests += 1
|
||||
cases[c](assert.push(c)) }
|
||||
// runtime...
|
||||
stats.time += Date.now() - started
|
||||
return stats },
|
||||
@ -610,7 +616,7 @@ async function(spec, chain, stats){
|
||||
e.toObject()
|
||||
: (e || {}) })
|
||||
|
||||
// stats...
|
||||
// setup stats...
|
||||
stats = stats || {}
|
||||
Object.assign(stats, {
|
||||
tests: stats.tests || 0,
|
||||
@ -995,6 +1001,9 @@ function(default_files, tests){
|
||||
} else {
|
||||
await runner(tests, '*', stats) }
|
||||
|
||||
// XXX BUG for some reason we can get here BEFORE all the
|
||||
// tests are finished -- forgot to await'ing something???
|
||||
|
||||
// print stats...
|
||||
console.log(
|
||||
'Tests run:', stats.tests,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user