forked from alexwarth/ometa-js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added jasmine-node test framework and a test runner
- Loading branch information
Showing
21 changed files
with
3,007 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
#!/usr/bin/env node | |||
|
|||
var spawn = require( 'child_process' ).spawn; | |||
var logly = require( 'logly' ); | |||
|
|||
logly.name( 'ometajsnode_test_runner' ); | |||
|
|||
var usage = "Usage: ometajsnode_test_runner [options]"; | |||
var help = [ | |||
usage, | |||
"", | |||
"Options:", | |||
" -d <directory[,directory...]> Specifies the spec directories to test, ", | |||
" directories are relative to project root", | |||
" -h, --help Displays this information", | |||
"" | |||
].join( '\n' ); | |||
|
|||
// Retrieve command-line parameters | |||
var arg, args = [], argv = process.argv.slice( 2 ); | |||
var options = {}; | |||
|
|||
// Parse command-line parameters | |||
while ( arg = argv.shift() ) { | |||
if ( arg === __filename ) continue; | |||
|
|||
arg = arg.match( /^--?(.+)/ )[ 1 ]; | |||
|
|||
switch ( arg ) { | |||
case 'd': | |||
options.dirs = argv.shift(); | |||
options.dirs = options.dirs.split( ',' ); | |||
break; | |||
case 'help': | |||
case 'h': | |||
process.stdout.write( help ); | |||
process.exit( 0 ); | |||
break; | |||
} | |||
} | |||
|
|||
/* | |||
* Run all specs | |||
* | |||
* This is provided as a wrapper so that we don't have to do crazy | |||
* gymnastics figuring out what current working directory is and such. | |||
* We set runners working directory to project root | |||
*/ | |||
var childProcessCount = 0; | |||
|
|||
if ( options.dirs ) { | |||
|
|||
for ( var i = 0; i < options.dirs.length; i++ ) { | |||
var runner = spawn( | |||
'node', ['node_modules/jasmine-node/lib/jasmine-node/cli.js', options.dirs[ i ] ], | |||
{ cwd: process.cwd() + '/..' }); | |||
|
|||
childProcessCount++; | |||
|
|||
runner.stdout.on( 'data', function( data ) { | |||
process.stdout.write( data ); | |||
}); | |||
|
|||
runner.stderr.on( 'data', function( data ) { | |||
process.stderr.write( data ); | |||
}); | |||
|
|||
runner.on( 'exit', function( code ) { | |||
childProcessCount--; | |||
if ( childProcessCount <= 0 ) { | |||
process.exit( code ); | |||
} | |||
}); | |||
} | |||
} else { | |||
var runner = spawn( | |||
'node', ['node_modules/jasmine-node/lib/jasmine-node/cli.js', 'spec'], | |||
{ cwd: process.cwd() + '/..' }); | |||
|
|||
childProcessCount++; | |||
|
|||
runner.stdout.on( 'data', function( data ) { | |||
process.stdout.write( data ); | |||
}); | |||
|
|||
runner.stderr.on( 'data', function( data ) { | |||
process.stderr.write( data ); | |||
}); | |||
|
|||
runner.on( 'exit', function( code ) { | |||
childProcessCount--; | |||
if ( childProcessCount <= 0 ) { | |||
process.exit( code ); | |||
} | |||
}); | |||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.