added glob support -- now mostly feature-complete...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-10 23:19:12 +03:00
parent 77252676dc
commit 2fbe88e476
2 changed files with 19 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-test", "name": "ig-test",
"version": "1.0.0", "version": "1.1.0",
"description": "experimental test runner....", "description": "experimental test runner....",
"main": "test.js", "main": "test.js",
"scripts": { "scripts": {
@ -22,7 +22,8 @@
"homepage": "https://github.com/flynx/test.js#readme", "homepage": "https://github.com/flynx/test.js#readme",
"dependencies": { "dependencies": {
"colors": "^1.4.0", "colors": "^1.4.0",
"ig-argv": "^2.11.5", "glob": "^7.1.6",
"ig-argv": "^2.12.0",
"ig-object": "^5.2.2" "ig-object": "^5.2.2"
} }
} }

23
test.js
View File

@ -23,7 +23,7 @@
/*********************************************************************/ /*********************************************************************/
var colors = require('colors') var colors = require('colors')
//var glob = require('glob') var glob = require('glob')
var object = require('ig-object') var object = require('ig-object')
var argv = require('ig-argv') var argv = require('ig-argv')
@ -32,8 +32,7 @@ var argv = require('ig-argv')
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX needs glob... module.DEFAULT_TEST_FILES = '**/?(*-)test.js'
//module.DEFAULT_TEST_FILES = '**/test.js'
// NOTE: to test in verbose mode do: // NOTE: to test in verbose mode do:
@ -449,20 +448,28 @@ argv.Parser({
'-f': '-test-file', '-f': '-test-file',
'-test-file': { '-test-file': {
doc: 'test script', doc: ['test script or filename patter, supports glob.',
'this flag can be given multiple times for',
'multiple paths/patterns'],
arg: 'PATH', arg: 'PATH',
default: function(){ default: function(){
return this.default_files }, return this.default_files },
handler: function(args, key, path){ handler: function(args, key, path){
var that = this
this.test_modules = this.test_modules || {} this.test_modules = this.test_modules || {}
// load the test modules... ;(path.includes('*') ?
// XXX expand glob and do this for each expanded file... // search...
glob.sync(path, {})
: [path])
// load the modules...
.forEach(function(path){
// only load .js files...
;(/.*\.js$/.test(path)) ;(/.*\.js$/.test(path))
&& (this.test_modules[path] = require('./' + path.replace(/\.js$/, ''))) && (that.test_modules[path] =
}}, require('./' + path.slice(0, -3))) }) }},
'-verbose': { '-verbose': {