diff --git a/package.json b/package.json index f8c682f..eba505d 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test.js b/test.js index 97c1ca1..7736076 100644 --- a/test.js +++ b/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': {