mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 10:20:09 +00:00
tweaking and fixing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7f1ead5c7c
commit
2b599e0dbe
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-test",
|
||||
"version": "1.5.1",
|
||||
"version": "1.5.3",
|
||||
"description": "experimental test runner....",
|
||||
"main": "test.js",
|
||||
"bin": {
|
||||
|
||||
29
test-test.js
29
test-test.js
@ -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') })
|
||||
}))
|
||||
|
||||
|
||||
|
||||
28
test.js
28
test.js
@ -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,12 +674,13 @@ 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){
|
||||
stats.tests += 1
|
||||
await cases[c]( assert.push(c) ) }
|
||||
await cases[c](assert.push(c)) }
|
||||
|
||||
// runtime...
|
||||
stats.time += Date.now() - started
|
||||
@ -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() }
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user