moving to new argv parser in test.js (not done yet)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-06-29 01:14:21 +03:00
parent e6014f3c98
commit 2b4f6a6514
2 changed files with 88 additions and 101 deletions

View File

@ -26,8 +26,8 @@
},
"homepage": "https://github.com/flynx/object.js#readme",
"devDependencies": {
"colors": "^1.4.0",
"c8": "*",
"ig-argv": "*"
"colors": "^1.4.0",
"ig-argv": "^2.0.0"
}
}

63
test.js
View File

@ -67,11 +67,6 @@ module.VERBOSE = process ?
//---------------------------------------------------------------------
// helpers...
Object.defineProperty(String.prototype, 'raw', {
get: function(){
return this.replace(/\x1b\[..?m/g, '') }, })
// compare two arrays by items...
var arrayCmp = function(a, b){
var ka = Object.keys(a)
@ -178,6 +173,9 @@ module.setups = {
assert(object.parentProperty(C.prototype, 'prop').get() == 'A.prop',
'get parent property')
assert(object.parentProperty(C.prototype, 'does-not-exist') === undefined,
'get non-existent property')
return 'C'
},
}), `inherit (gen3)`),
@ -894,15 +892,16 @@ function(chain, stats){
if(typeof(__filename) != 'undefined'
&& __filename == (require.main || {}).filename){
var stats = {}
// parse args...
var chains =
argv.ArgvParser({
argv.Parser({
// doc...
__usage__: `$scriptname [OPTIONS] [CHAIN] ...`,
__doc__: object.normalizeTextIndent(
usage: `$SCRIPTNAME [OPTIONS] [CHAIN] ...`,
doc: object.normalizeTextIndent(
`Run tests on object.js module.
Tests run by $scriptname can be specified in one of the
Tests run by $SCRIPTNAME can be specified in one of the
following formats:
<case>
@ -912,28 +911,29 @@ if(typeof(__filename) != 'undefined'
Each of the items in the test spec can be a "*" indicating
that all relevant items should be used, for example:
${ '$ ./$scriptname basic:*:*' }
${ '$ ./$SCRIPTNAME basic:*:*' }
Here $scriptname is instructed to run all tests and modifiers
Here $SCRIPTNAME is instructed to run all tests and modifiers
only on the basic setup.
Zero or more sets of tests can be specified.
When no tests specified $scriptname will run all tests.
When no tests specified $SCRIPTNAME will run all tests.
`),
__examples__: [
['$ ./$scriptname',
examples: [
['$ ./$SCRIPTNAME',
'run all tests.'.gray],
['$ ./$scriptname basic:*:*',
['$ ./$SCRIPTNAME basic:*:*',
'run all tests and modifiers on "basic" setup.'.gray,
'(see $scriptname -l for more info)'.gray],
['$ ./$scriptname -v example',
'(see $SCRIPTNAME -l for more info)'.gray],
['$ ./$SCRIPTNAME -v example',
'run "example" test in verbose mode.'.gray],
['$ ./$scriptname native:gen3:methods init:gen3:methods',
['$ ./$SCRIPTNAME native:gen3:methods init:gen3:methods',
'run two tests/patterns.'.gray],
['$ export VERBOSE=1 && ./$scriptname',
['$ export VERBOSE=1 && ./$SCRIPTNAME',
'set verbose mode globally and run tests.'.gray],
],
// options...
'-l': '-list',
'-list': {
@ -961,30 +961,15 @@ if(typeof(__filename) != 'undefined'
Standalone test cases:
${ Object.keys(cases).join('\n\
') }
`), this.scriptname)
`), this.scriptName)
process.exit() }},
'-v': '-verbose',
'-verbose': {
doc: 'verbose mode (defaults to: $VERBOSE).',
handler: function(){
module.VERBOSE = true }},
// XXX commands...
'-foo': 'moo',
'moo': 'moue',
'moue': Object.assign(
function(){
console.log('MOO!!!!!!')
process.exit() },
{
doc: 'test command...'
}),
// XXX need to make this nestable...
'nested': argv.ArgvParser({ }),
})(process.argv)
})
.then(function(chains){
// run the tests...
var stats = {}
chains.length > 0 ?
chains
.forEach(function(chain){
@ -999,6 +984,8 @@ if(typeof(__filename) != 'undefined'
// report error status to the OS...
process.exit(stats.failures)
})
(process.argv)
}