mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 10:20:09 +00:00
reworked part of the arg handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9b48c797c9
commit
a2664b5dd8
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-test",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "experimental test runner....",
|
||||
"main": "test.js",
|
||||
"scripts": {
|
||||
@ -23,7 +23,7 @@
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"glob": "^7.1.6",
|
||||
"ig-argv": "^2.12.0",
|
||||
"ig-argv": "^2.13.0",
|
||||
"ig-object": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,12 +36,6 @@ tests.Test('dummy',
|
||||
assert(true, 'dummy: assert')
|
||||
})
|
||||
|
||||
console.log('>>>>', tests.Tests.members)
|
||||
console.log('>>>>', tests.Tests.keys())
|
||||
// XXX this does not call the Merged.length for some reason...
|
||||
console.log('>>>>', tests.Tests.size)
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
38
test.js
38
test.js
@ -420,11 +420,21 @@ argv.Parser({
|
||||
],
|
||||
|
||||
|
||||
// options...
|
||||
default_files: undefined,
|
||||
|
||||
'-l': '-list',
|
||||
'-list': {
|
||||
doc: 'list available tests.',
|
||||
handler: function(){
|
||||
doc: ['list available tests.',
|
||||
'note that if passing files via -f explicitly they',
|
||||
'must precede the -list flag.'],
|
||||
arg: 'PATH',
|
||||
handler: function(args, key, path){
|
||||
path = path || this.default_files
|
||||
// load path or the defaults if nothing loaded...
|
||||
;(path != this.default_files
|
||||
|| this.test_modules == null)
|
||||
&& this.handle('-f', [], key, path)
|
||||
// get key value...
|
||||
var keys = function(s){
|
||||
return object.parentOf(Merged, s) ?
|
||||
s.keys()
|
||||
@ -441,11 +451,15 @@ argv.Parser({
|
||||
') }
|
||||
|
||||
Modifiers:
|
||||
${ keys(this.modifiers).join('\n\
|
||||
${ keys(this.modifiers)
|
||||
.filter(function(e){ return e != '-' })
|
||||
.join('\n\
|
||||
') }
|
||||
|
||||
Tests:
|
||||
${ keys(this.tests).join('\n\
|
||||
${ keys(this.tests)
|
||||
.filter(function(e){ return e != '-' })
|
||||
.join('\n\
|
||||
') }
|
||||
|
||||
Standalone test cases:
|
||||
@ -455,18 +469,17 @@ argv.Parser({
|
||||
process.exit() }},
|
||||
|
||||
|
||||
default_files: undefined,
|
||||
test_modules: undefined,
|
||||
|
||||
// XXX revise error handling...
|
||||
'-f': '-test-file',
|
||||
'-test-file': {
|
||||
doc: ['test script or filename patter, supports glob.',
|
||||
'this flag can be given multiple times for',
|
||||
'multiple paths/patterns'],
|
||||
arg: 'PATH',
|
||||
|
||||
default: function(){
|
||||
return this.default_files },
|
||||
|
||||
handler: function(args, key, path){
|
||||
var that = this
|
||||
this.test_modules = this.test_modules || {}
|
||||
@ -482,9 +495,12 @@ argv.Parser({
|
||||
// load the modules...
|
||||
.forEach(function(path){
|
||||
// only load .js files...
|
||||
/.*\.js$/.test(path)
|
||||
&& (that.test_modules[path] =
|
||||
require('./' + path.slice(0, -3))) }) }) }},
|
||||
if(!/.*\.js$/.test(path)){
|
||||
throw argv.ParserError(
|
||||
`${key}: only support .js modules, got: "${path}"`) }
|
||||
// XXX should we handle the load error here???
|
||||
that.test_modules[path] =
|
||||
require('./' + path.slice(0, -3)) }) }) }},
|
||||
|
||||
|
||||
'-verbose': {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user