mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 10:20:09 +00:00
added glob support -- now mostly feature-complete...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
77252676dc
commit
2fbe88e476
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-test",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "experimental test runner....",
|
||||
"main": "test.js",
|
||||
"scripts": {
|
||||
@ -22,7 +22,8 @@
|
||||
"homepage": "https://github.com/flynx/test.js#readme",
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"ig-argv": "^2.11.5",
|
||||
"glob": "^7.1.6",
|
||||
"ig-argv": "^2.12.0",
|
||||
"ig-object": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
25
test.js
25
test.js
@ -23,7 +23,7 @@
|
||||
/*********************************************************************/
|
||||
|
||||
var colors = require('colors')
|
||||
//var glob = require('glob')
|
||||
var glob = require('glob')
|
||||
|
||||
var object = require('ig-object')
|
||||
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:
|
||||
@ -449,20 +448,28 @@ argv.Parser({
|
||||
|
||||
'-f': '-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',
|
||||
|
||||
default: function(){
|
||||
return this.default_files },
|
||||
|
||||
handler: function(args, key, path){
|
||||
var that = this
|
||||
this.test_modules = this.test_modules || {}
|
||||
|
||||
// load the test modules...
|
||||
// XXX expand glob and do this for each expanded file...
|
||||
;(/.*\.js$/.test(path))
|
||||
&& (this.test_modules[path] = require('./' + path.replace(/\.js$/, '')))
|
||||
}},
|
||||
;(path.includes('*') ?
|
||||
// search...
|
||||
glob.sync(path, {})
|
||||
: [path])
|
||||
// load the modules...
|
||||
.forEach(function(path){
|
||||
// only load .js files...
|
||||
;(/.*\.js$/.test(path))
|
||||
&& (that.test_modules[path] =
|
||||
require('./' + path.slice(0, -3))) }) }},
|
||||
|
||||
|
||||
'-verbose': {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user