1 | #!/usr/bin/env node
|
2 | // vim: set filetype=javascript:
|
3 |
|
4 | // this is a simple wrapper around the mocha executable, with the test
|
5 | // files location (and coffeescript support) automatically provided.
|
6 |
|
7 | var spawn = require('child_process').spawn,
|
8 | path = require('path');
|
9 |
|
10 | // TODO: handle -h/--help
|
11 | var args = [path.resolve(__dirname, '../test/*.coffee'),
|
12 | '--reporter', 'spec',
|
13 | '--compilers', 'coffee:coffee-script/register'];
|
14 | args = args.concat(process.argv.slice(2));
|
15 |
|
16 | // code below is taken from the mocha executable:
|
17 | var proc = spawn('_mocha', args, { stdio: 'inherit' });
|
18 | proc.on('exit', function (code, signal) {
|
19 | process.on('exit', function(){
|
20 | if (signal) {
|
21 | process.kill(process.pid, signal);
|
22 | } else {
|
23 | process.exit(code);
|
24 | }
|
25 | });
|
26 | });
|
27 |
|
28 | // terminate children.
|
29 | process.on('SIGINT', function () {
|
30 | proc.kill('SIGINT'); // calls runner.abort()
|
31 | proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
|
32 | process.kill(process.pid, 'SIGINT');
|
33 | });
|