mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 18:30:08 +00:00
better test sequencing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c139365cff
commit
7f1ead5c7c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-test",
|
"name": "ig-test",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"description": "experimental test runner....",
|
"description": "experimental test runner....",
|
||||||
"main": "test.js",
|
"main": "test.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
18
test-test.js
18
test-test.js
@ -28,10 +28,9 @@ tests.Setups({
|
|||||||
return {setup: 'setup2'} },
|
return {setup: 'setup2'} },
|
||||||
async: async function(assert){
|
async: async function(assert){
|
||||||
assert(true, 'setup')
|
assert(true, 'setup')
|
||||||
return {setup: 'async'} },
|
return await {setup: 'async'} },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tests.Modifiers({
|
tests.Modifiers({
|
||||||
sync: function(assert, setup){
|
sync: function(assert, setup){
|
||||||
assert(setup, 'modifier')
|
assert(setup, 'modifier')
|
||||||
@ -40,7 +39,14 @@ tests.Modifiers({
|
|||||||
async: async function(assert, setup){
|
async: async function(assert, setup){
|
||||||
assert(setup, 'modifier')
|
assert(setup, 'modifier')
|
||||||
setup.mod = 'async'
|
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)
|
assert.log(setup)
|
||||||
})
|
})
|
||||||
|
|
||||||
tests.Tests({
|
|
||||||
async: async function(assert, setup){
|
|
||||||
assert(setup, 'test')
|
|
||||||
assert.log(setup)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// a nested test set...
|
// a nested test set...
|
||||||
tests.Case('nested',
|
tests.Case('nested',
|
||||||
|
|||||||
103
test.js
103
test.js
@ -621,55 +621,66 @@ async function(spec, chain, stats){
|
|||||||
|
|
||||||
var started = Date.now()
|
var started = Date.now()
|
||||||
// tests...
|
// 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)
|
var assert = Assert('[TEST]', stats, module.VERBOSE)
|
||||||
chain_length != 1
|
for(var [s, m, t] of queue){
|
||||||
&& await Promise.all(object.deepKeys(tests)
|
// run the test...
|
||||||
.filter(function(t, i, l){
|
stats.tests += 1
|
||||||
return typeof(tests[t]) == 'function'
|
var _assert = assert.push(
|
||||||
// skip blank tests if we have other tests unless
|
[s, m, t]
|
||||||
// explicitly specified...
|
// do not print blank pass-through ('-')
|
||||||
&& ((t == '-'
|
// components...
|
||||||
&& test != t
|
.filter(function(e){ return e != '-' }) )
|
||||||
&& l.length > 1) ?
|
await tests[t](
|
||||||
false
|
_assert,
|
||||||
: (test == '*'
|
await modifiers[m](
|
||||||
|| test == t) ) })
|
_assert,
|
||||||
.map(function(t){
|
await setups[s](_assert))) }
|
||||||
// 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))
|
|
||||||
// cases...
|
// 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)
|
var assert = Assert('[CASE]', stats, module.VERBOSE)
|
||||||
chain_length <= 1
|
for(var c of queue){
|
||||||
&& await Promise.all(Object.keys(cases)
|
stats.tests += 1
|
||||||
.filter(function(s){
|
await cases[c]( assert.push(c) ) }
|
||||||
return typeof(cases[s]) == 'function'
|
|
||||||
&& (setup == '*' || setup == s) })
|
|
||||||
.map(function(c){
|
|
||||||
stats.tests += 1
|
|
||||||
return cases[c]( assert.push(c) ) }))
|
|
||||||
// runtime...
|
// runtime...
|
||||||
stats.time += Date.now() - started
|
stats.time += Date.now() - started
|
||||||
return stats }
|
return stats }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user