Repository navigation
Expand file tree
/
Copy pathmocha
More file actions
executable file
·94 lines (84 loc) · 2.28 KB
/
Copy pathmocha
File metadata and controls
executable file
·94 lines (84 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env node
/**
* This tiny wrapper file checks for known node flags and appends them
* when found, before invoking the "real" _mocha(1) executable.
*/
var spawn = require('child_process').spawn,
path = require('path'),
fs = require('fs'),
args = [path.join(__dirname, '_mocha')];
// --opts
var optsPath = process.argv.indexOf('--opts') !== -1
? process.argv[process.argv.indexOf('--opts') + 1]
: 'test/mocha.opts';
try {
var opts = fs.readFileSync(optsPath, 'utf8')
.trim()
.split(/\s+/)
.filter(function(value) {
return value ? true : false;
});
process.argv = process.argv
.slice(0, 2)
.concat(opts.concat(process.argv.slice(2)));
} catch (err) {
// ignore
}
process.argv.slice(2).forEach(function(arg){
var flag = arg.split('=')[0];
switch (flag) {
case '-d':
args.unshift('--debug');
args.push('--no-timeouts');
break;
case 'debug':
case '--debug':
case '--debug-brk':
args.unshift(arg);
args.push('--no-timeouts');
break;
case '-gc':
case '--expose-gc':
args.unshift('--expose-gc');
break;
case '--gc-global':
case '--harmony':
case '--es_staging':
case '--harmony-proxies':
case '--harmony_proxies':
case '--harmony-collections':
case '--harmony_collections':
case '--harmony-generators':
case '--harmony_generators':
case '--harmony_shipping':
case '--harmony_arrow_functions':
case '--harmony_proxies':
case '--harmony_classes':
case '--no-deprecation':
case '--prof':
case '--throw-deprecation':
case '--trace-deprecation':
args.unshift(arg);
break;
default:
if (0 == arg.indexOf('--trace')) args.unshift(arg);
else args.push(arg);
break;
}
});
var proc = spawn(process.execPath, args, { stdio: 'inherit' });
proc.on('exit', function (code, signal) {
process.on('exit', function(){
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
});
});
// terminate children.
process.on('SIGINT', function () {
proc.kill('SIGINT'); // calls runner.abort()
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
process.kill(process.pid, 'SIGINT');
});