Skip to content

Commit

Permalink
Added jasmine-node test framework and a test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanls committed Jun 30, 2011
1 parent af476d6 commit e9546e8
Show file tree
Hide file tree
Showing 21 changed files with 3,007 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/ometajsnode
Expand Up @@ -2,7 +2,7 @@


var logly = require( 'logly' ); var logly = require( 'logly' );


logly.name('ometajsnode'); logly.name( 'ometajsnode' );


var usage = "Usage: ometajsnode <-C|-I|-P> <-g|--grammar grammar_file> [options] input_file"; var usage = "Usage: ometajsnode <-C|-I|-P> <-g|--grammar grammar_file> [options] input_file";
var help1 = [ var help1 = [
Expand Down
96 changes: 96 additions & 0 deletions bin/ometajsnode_test_runner
@@ -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 );
}
});
}
22 changes: 22 additions & 0 deletions node_modules/jasmine-node/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions node_modules/jasmine-node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions node_modules/jasmine-node/bin/jasmine-node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions node_modules/jasmine-node/lib/jasmine-node/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9546e8

Please sign in to comment.