mocha-compat 3.6.4 → 10.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +61 -110
  3. package/bin/_mocha +10 -0
  4. package/bin/mocha.js +142 -0
  5. package/browser-entry.js +61 -22
  6. package/lib/browser/highlight-tags.js +39 -0
  7. package/lib/browser/parse-query.js +24 -0
  8. package/lib/{template.html → browser/template.html} +7 -5
  9. package/lib/cli/cli.js +89 -0
  10. package/lib/cli/collect-files.js +137 -0
  11. package/lib/cli/commands.js +14 -0
  12. package/lib/cli/config.js +100 -0
  13. package/lib/cli/index.js +3 -0
  14. package/lib/cli/init.js +36 -0
  15. package/lib/cli/lookup-files.js +150 -0
  16. package/lib/cli/node-flags.js +85 -0
  17. package/lib/cli/one-and-dones.js +69 -0
  18. package/lib/cli/options.js +284 -0
  19. package/lib/cli/run-helpers.js +304 -0
  20. package/lib/cli/run-option-metadata.js +116 -0
  21. package/lib/cli/run.js +380 -0
  22. package/lib/cli/watch-run.js +377 -0
  23. package/lib/context.js +16 -42
  24. package/lib/errors.js +563 -0
  25. package/lib/hook.js +50 -9
  26. package/lib/interfaces/bdd.js +28 -29
  27. package/lib/interfaces/common.js +56 -21
  28. package/lib/interfaces/exports.js +4 -7
  29. package/lib/interfaces/qunit.js +10 -11
  30. package/lib/interfaces/tdd.js +15 -15
  31. package/lib/mocha.js +1073 -292
  32. package/lib/mocharc.json +10 -0
  33. package/lib/nodejs/buffered-worker-pool.js +188 -0
  34. package/lib/nodejs/esm-utils.js +106 -0
  35. package/lib/nodejs/file-unloader.js +15 -0
  36. package/lib/nodejs/parallel-buffered-runner.js +433 -0
  37. package/lib/nodejs/reporters/parallel-buffered.js +165 -0
  38. package/lib/nodejs/serializer.js +414 -0
  39. package/lib/nodejs/worker.js +151 -0
  40. package/lib/pending.js +3 -3
  41. package/lib/plugin-loader.js +286 -0
  42. package/lib/reporters/base.js +305 -205
  43. package/lib/reporters/doc.js +52 -21
  44. package/lib/reporters/dot.js +31 -18
  45. package/lib/reporters/html.js +153 -81
  46. package/lib/reporters/json-stream.js +53 -24
  47. package/lib/reporters/json.js +88 -18
  48. package/lib/reporters/landing.js +38 -16
  49. package/lib/reporters/list.js +34 -19
  50. package/lib/reporters/markdown.js +28 -15
  51. package/lib/reporters/min.js +22 -8
  52. package/lib/reporters/nyan.js +62 -58
  53. package/lib/reporters/progress.js +32 -19
  54. package/lib/reporters/spec.js +41 -23
  55. package/lib/reporters/tap.js +255 -32
  56. package/lib/reporters/xunit.js +89 -39
  57. package/lib/runnable.js +233 -148
  58. package/lib/runner.js +679 -380
  59. package/lib/stats-collector.js +83 -0
  60. package/lib/suite.js +376 -112
  61. package/lib/test.js +82 -21
  62. package/lib/utils.js +364 -477
  63. package/mocha.css +183 -54
  64. package/mocha.js +19840 -15846
  65. package/mocha.js.map +1 -0
  66. package/package.json +163 -336
  67. package/{lib/to-iso-string → vendor/serialize-javascript}/LICENSE +8 -6
  68. package/vendor/serialize-javascript/README.md +10 -0
  69. package/vendor/serialize-javascript/index.js +349 -0
  70. package/bin/_mocha-compat +0 -572
  71. package/bin/mocha-compat +0 -87
  72. package/bin/options.js +0 -41
  73. package/bower.json +0 -38
  74. package/images/error.png +0 -0
  75. package/images/ok.png +0 -0
  76. package/lib/browser/.eslintrc.yaml +0 -4
  77. package/lib/browser/debug.js +0 -7
  78. package/lib/browser/events.js +0 -195
  79. package/lib/browser/progress.js +0 -119
  80. package/lib/browser/tty.js +0 -13
  81. package/lib/ms.js +0 -130
  82. package/lib/to-iso-string/index.js +0 -37
  83. package/vendor/glob/LICENSE +0 -15
  84. package/vendor/glob/README.md +0 -399
  85. package/vendor/glob/common.js +0 -244
  86. package/vendor/glob/glob.js +0 -788
  87. package/vendor/glob/package.json +0 -55
  88. package/vendor/glob/sync.js +0 -486
  89. package/vendor/inflight/LICENSE +0 -15
  90. package/vendor/inflight/README.md +0 -37
  91. package/vendor/inflight/inflight.js +0 -54
  92. package/vendor/inflight/package.json +0 -29
package/bin/_mocha-compat DELETED
@@ -1,572 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /* eslint no-unused-vars: off */
5
-
6
- /**
7
- * Module dependencies.
8
- */
9
-
10
- var program = require('commander');
11
- var path = require('path');
12
- var fs = require('fs');
13
- var resolve = path.resolve;
14
- var exists = fs.existsSync || path.existsSync;
15
- var Mocha = require('../');
16
- var utils = Mocha.utils;
17
- var interfaceNames = Object.keys(Mocha.interfaces);
18
- var join = path.join;
19
- var cwd = process.cwd();
20
- var getOptions = require('./options');
21
- var mocha = new Mocha();
22
-
23
- /**
24
- * Save timer references to avoid Sinon interfering (see GH-237).
25
- */
26
-
27
- var Date = global.Date;
28
- var setTimeout = global.setTimeout;
29
- var setInterval = global.setInterval;
30
- var clearTimeout = global.clearTimeout;
31
- var clearInterval = global.clearInterval;
32
-
33
- /**
34
- * Files.
35
- */
36
-
37
- var files = [];
38
-
39
- /**
40
- * Globals.
41
- */
42
-
43
- var globals = [];
44
-
45
- /**
46
- * Requires.
47
- */
48
-
49
- var requires = [];
50
-
51
- /**
52
- * Images.
53
- */
54
-
55
- var images = {
56
- fail: path.join(__dirname, '..', 'images', 'error.png'),
57
- pass: path.join(__dirname, '..', 'images', 'ok.png')
58
- };
59
-
60
- // options
61
-
62
- program
63
- .version(JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version)
64
- .usage('[debug] [options] [files]')
65
- .option('-A, --async-only', 'force all tests to take a callback (async) or return a promise')
66
- .option('-c, --colors', 'force enabling of colors')
67
- .option('-C, --no-colors', 'force disabling of colors')
68
- .option('-G, --growl', 'enable growl notification support')
69
- .option('-O, --reporter-options <k=v,k2=v2,...>', 'reporter-specific options')
70
- .option('-R, --reporter <name>', 'specify the reporter to use', 'spec')
71
- .option('-S, --sort', 'sort test files')
72
- .option('-b, --bail', 'bail after first test failure')
73
- .option('-d, --debug', "enable node's debugger, synonym for node --debug")
74
- .option('-g, --grep <pattern>', 'only run tests matching <pattern>')
75
- .option('-f, --fgrep <string>', 'only run tests containing <string>')
76
- .option('-gc, --expose-gc', 'expose gc extension')
77
- .option('-i, --invert', 'inverts --grep and --fgrep matches')
78
- .option('-r, --require <name>', 'require the given module')
79
- .option('-s, --slow <ms>', '"slow" test threshold in milliseconds [75]')
80
- .option('-t, --timeout <ms>', 'set test-case timeout in milliseconds [2000]')
81
- .option('-u, --ui <name>', 'specify user-interface (' + interfaceNames.join('|') + ')', 'bdd')
82
- .option('-w, --watch', 'watch files for changes')
83
- .option('--check-leaks', 'check for global variable leaks')
84
- .option('--full-trace', 'display the full stack trace')
85
- .option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
86
- .option('--debug-brk', "enable node's debugger breaking on the first line")
87
- .option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
88
- .option('--es_staging', 'enable all staged features')
89
- .option('--harmony<_classes,_generators,...>', 'all node --harmony* flags are available')
90
- .option('--preserve-symlinks', 'Instructs the module loader to preserve symbolic links when resolving and caching modules')
91
- .option('--icu-data-dir', 'include ICU data')
92
- .option('--inline-diffs', 'display actual/expected differences inline within each string')
93
- .option('--inspect', 'activate devtools in chrome')
94
- .option('--inspect-brk', 'activate devtools in chrome and break on the first line')
95
- .option('--interfaces', 'display available interfaces')
96
- .option('--no-deprecation', 'silence deprecation warnings')
97
- .option('--no-exit', 'require a clean shutdown of the event loop: mocha will not call process.exit')
98
- .option('--no-timeouts', 'disables timeouts, given implicitly with --debug')
99
- .option('--no-warnings', 'silence all node process warnings')
100
- .option('--opts <path>', 'specify opts path', 'test/mocha.opts')
101
- .option('--perf-basic-prof', 'enable perf linux profiler (basic support)')
102
- .option('--napi-modules', 'enable experimental NAPI modules')
103
- .option('--prof', 'log statistical profiling information')
104
- .option('--log-timer-events', 'Time events including external callbacks')
105
- .option('--recursive', 'include sub directories')
106
- .option('--reporters', 'display available reporters')
107
- .option('--retries <times>', 'set numbers of time to retry a failed test case')
108
- .option('--throw-deprecation', 'throw an exception anytime a deprecated function is used')
109
- .option('--trace', 'trace function calls')
110
- .option('--trace-deprecation', 'show stack traces on deprecations')
111
- .option('--trace-warnings', 'show stack traces on node process warnings')
112
- .option('--use_strict', 'enforce strict mode')
113
- .option('--watch-extensions <ext>,...', 'additional extensions to monitor with --watch', list, [])
114
- .option('--delay', 'wait for async suite definition')
115
- .option('--allow-uncaught', 'enable uncaught errors to propagate')
116
- .option('--forbid-only', 'causes test marked with only to fail the suite')
117
- .option('--forbid-pending', 'causes pending tests and test marked with skip to fail the suite');
118
-
119
- program._name = 'mocha-compat-3';
120
-
121
- // init command
122
-
123
- program
124
- .command('init <path>')
125
- .description('initialize a client-side mocha setup at <path>')
126
- .action(function (path) {
127
- var mkdir = require('mkdirp');
128
- mkdir.sync(path);
129
- var css = fs.readFileSync(join(__dirname, '..', 'mocha.css'));
130
- var js = fs.readFileSync(join(__dirname, '..', 'mocha.js'));
131
- var tmpl = fs.readFileSync(join(__dirname, '..', 'lib/template.html'));
132
- fs.writeFileSync(join(path, 'mocha.css'), css);
133
- fs.writeFileSync(join(path, 'mocha.js'), js);
134
- fs.writeFileSync(join(path, 'tests.js'), '');
135
- fs.writeFileSync(join(path, 'index.html'), tmpl);
136
- process.exit(0);
137
- });
138
-
139
- // --globals
140
-
141
- program.on('globals', function (val) {
142
- globals = globals.concat(list(val));
143
- });
144
-
145
- // --reporters
146
-
147
- program.on('reporters', function () {
148
- console.log();
149
- console.log(' dot - dot matrix');
150
- console.log(' doc - html documentation');
151
- console.log(' spec - hierarchical spec list');
152
- console.log(' json - single json object');
153
- console.log(' progress - progress bar');
154
- console.log(' list - spec-style listing');
155
- console.log(' tap - test-anything-protocol');
156
- console.log(' landing - unicode landing strip');
157
- console.log(' xunit - xunit reporter');
158
- console.log(' min - minimal reporter (great with --watch)');
159
- console.log(' json-stream - newline delimited json events');
160
- console.log(' markdown - markdown documentation (github flavour)');
161
- console.log(' nyan - nyan cat!');
162
- console.log();
163
- process.exit();
164
- });
165
-
166
- // --interfaces
167
-
168
- program.on('interfaces', function () {
169
- console.log('');
170
- interfaceNames.forEach(function (interfaceName) {
171
- console.log(' ' + interfaceName);
172
- });
173
- console.log('');
174
- process.exit();
175
- });
176
-
177
- // -r, --require
178
-
179
- module.paths.push(cwd, join(cwd, 'node_modules'));
180
-
181
- program.on('require', function (mod) {
182
- var abs = exists(mod) || exists(mod + '.js');
183
- if (abs) {
184
- mod = resolve(mod);
185
- }
186
- requires.push(mod);
187
- });
188
-
189
- // If not already done, load mocha.opts
190
- if (!process.env.LOADED_MOCHA_OPTS) {
191
- getOptions();
192
- }
193
-
194
- // parse args
195
-
196
- program.parse(process.argv);
197
-
198
- // infinite stack traces
199
-
200
- Error.stackTraceLimit = Infinity; // TODO: config
201
-
202
- // reporter options
203
-
204
- var reporterOptions = {};
205
- if (program.reporterOptions !== undefined) {
206
- program.reporterOptions.split(',').forEach(function (opt) {
207
- var L = opt.split('=');
208
- if (L.length > 2 || L.length === 0) {
209
- throw new Error("invalid reporter option '" + opt + "'");
210
- } else if (L.length === 2) {
211
- reporterOptions[L[0]] = L[1];
212
- } else {
213
- reporterOptions[L[0]] = true;
214
- }
215
- });
216
- }
217
-
218
- // reporter
219
-
220
- mocha.reporter(program.reporter, reporterOptions);
221
-
222
- // load reporter
223
-
224
- var Reporter = null;
225
- try {
226
- Reporter = require('../lib/reporters/' + program.reporter);
227
- } catch (err) {
228
- try {
229
- Reporter = require(program.reporter);
230
- } catch (err2) {
231
- throw new Error('reporter "' + program.reporter + '" does not exist');
232
- }
233
- }
234
-
235
- // --no-colors
236
-
237
- if (!program.colors) {
238
- mocha.useColors(false);
239
- }
240
-
241
- // --colors
242
-
243
- if (~process.argv.indexOf('--colors') || ~process.argv.indexOf('-c')) {
244
- mocha.useColors(true);
245
- }
246
-
247
- // --inline-diffs
248
-
249
- if (program.inlineDiffs) {
250
- mocha.useInlineDiffs(true);
251
- }
252
-
253
- // --slow <ms>
254
-
255
- if (program.slow) {
256
- mocha.suite.slow(program.slow);
257
- }
258
-
259
- // --no-timeouts
260
-
261
- if (!program.timeouts) {
262
- mocha.enableTimeouts(false);
263
- }
264
-
265
- // --timeout
266
-
267
- if (program.timeout) {
268
- mocha.suite.timeout(program.timeout);
269
- }
270
-
271
- // --bail
272
-
273
- mocha.suite.bail(program.bail);
274
-
275
- // --grep
276
-
277
- if (program.grep) {
278
- mocha.grep(program.grep);
279
- }
280
-
281
- // --fgrep
282
-
283
- if (program.fgrep) {
284
- mocha.fgrep(program.fgrep);
285
- }
286
-
287
- // --invert
288
-
289
- if (program.invert) {
290
- mocha.invert();
291
- }
292
-
293
- // --check-leaks
294
-
295
- if (program.checkLeaks) {
296
- mocha.checkLeaks();
297
- }
298
-
299
- // --stack-trace
300
-
301
- if (program.fullTrace) {
302
- mocha.fullTrace();
303
- }
304
-
305
- // --growl
306
-
307
- if (program.growl) {
308
- mocha.growl();
309
- }
310
-
311
- // --async-only
312
-
313
- if (program.asyncOnly) {
314
- mocha.asyncOnly();
315
- }
316
-
317
- // --delay
318
-
319
- if (program.delay) {
320
- mocha.delay();
321
- }
322
-
323
- // --allow-uncaught
324
-
325
- if (program.allowUncaught) {
326
- mocha.allowUncaught();
327
- }
328
-
329
- // --globals
330
-
331
- mocha.globals(globals);
332
-
333
- // --retries
334
-
335
- if (program.retries) {
336
- mocha.suite.retries(program.retries);
337
- }
338
-
339
- // --forbid-only
340
-
341
- if (program.forbidOnly) mocha.forbidOnly();
342
-
343
- // --forbid-pending
344
-
345
- if (program.forbidPending) mocha.forbidPending();
346
-
347
- // custom compiler support
348
-
349
- var extensions = ['js'];
350
- program.compilers.forEach(function (c) {
351
- var idx = c.indexOf(':');
352
- var ext = c.slice(0, idx);
353
- var mod = c.slice(idx + 1);
354
-
355
- if (mod[0] === '.') {
356
- mod = join(process.cwd(), mod);
357
- }
358
- require(mod);
359
- extensions.push(ext);
360
- program.watchExtensions.push(ext);
361
- });
362
-
363
- // requires
364
-
365
- requires.forEach(function (mod) {
366
- require(mod);
367
- });
368
-
369
- // interface
370
-
371
- mocha.ui(program.ui);
372
-
373
- // args
374
-
375
- var args = program.args;
376
-
377
- // default files to test/*.{js,coffee}
378
-
379
- if (!args.length) {
380
- args.push('test');
381
- }
382
-
383
- args.forEach(function (arg) {
384
- var newFiles;
385
- try {
386
- newFiles = utils.lookupFiles(arg, extensions, program.recursive);
387
- } catch (err) {
388
- if (err.message.indexOf('cannot resolve path') === 0) {
389
- console.error('Warning: Could not find any test files matching pattern: ' + arg);
390
- return;
391
- }
392
-
393
- throw err;
394
- }
395
-
396
- files = files.concat(newFiles);
397
- });
398
-
399
- if (!files.length) {
400
- console.error('No test files found');
401
- process.exit(1);
402
- }
403
-
404
- // resolve
405
-
406
- files = files.map(function (path) {
407
- return resolve(path);
408
- });
409
-
410
- if (program.sort) {
411
- files.sort();
412
- }
413
-
414
- // --watch
415
-
416
- var runner;
417
- var loadAndRun;
418
- var purge;
419
- var rerun;
420
-
421
- if (program.watch) {
422
- console.log();
423
- hideCursor();
424
- process.on('SIGINT', function () {
425
- showCursor();
426
- console.log('\n');
427
- process.exit(130);
428
- });
429
-
430
- var watchFiles = utils.files(cwd, ['js'].concat(program.watchExtensions));
431
- var runAgain = false;
432
-
433
- loadAndRun = function loadAndRun() {
434
- try {
435
- mocha.files = files;
436
- runAgain = false;
437
- runner = mocha.run(function () {
438
- runner = null;
439
- if (runAgain) {
440
- rerun();
441
- }
442
- });
443
- } catch (e) {
444
- console.log(e.stack);
445
- }
446
- };
447
-
448
- purge = function purge() {
449
- watchFiles.forEach(function (file) {
450
- delete require.cache[file];
451
- });
452
- };
453
-
454
- loadAndRun();
455
-
456
- rerun = function rerun() {
457
- purge();
458
- stop();
459
- if (!program.grep) {
460
- mocha.grep(null);
461
- }
462
- mocha.suite = mocha.suite.clone();
463
- mocha.suite.ctx = new Mocha.Context();
464
- mocha.ui(program.ui);
465
- loadAndRun();
466
- };
467
-
468
- utils.watch(watchFiles, function () {
469
- runAgain = true;
470
- if (runner) {
471
- runner.abort();
472
- } else {
473
- rerun();
474
- }
475
- });
476
- } else {
477
- // load
478
-
479
- mocha.files = files;
480
- runner = mocha.run(program.exit ? exit : exitLater);
481
- }
482
-
483
- function exitLater(code) {
484
- process.on('exit', function () {
485
- process.exit(Math.min(code, 255));
486
- });
487
- }
488
-
489
- function exit(code) {
490
- var clampedCode = Math.min(code, 255);
491
-
492
- // Eagerly set the process's exit code in case stream.write doesn't
493
- // execute its callback before the process terminates.
494
- process.exitCode = clampedCode;
495
-
496
- // flush output for Node.js Windows pipe bug
497
- // https://github.com/joyent/node/issues/6247 is just one bug example
498
- // https://github.com/visionmedia/mocha/issues/333 has a good discussion
499
- function done() {
500
- if (!(draining--)) {
501
- process.exit(clampedCode);
502
- }
503
- }
504
-
505
- var draining = 0;
506
- var streams = [process.stdout, process.stderr];
507
-
508
- streams.forEach(function (stream) {
509
- // submit empty write request and wait for completion
510
- draining += 1;
511
- stream.write('', done);
512
- });
513
-
514
- done();
515
- }
516
-
517
- process.on('SIGINT', function () {
518
- runner.abort();
519
-
520
- // This is a hack:
521
- // Instead of `process.exit(130)`, set runner.failures to 130 (exit code for SIGINT)
522
- // The amount of failures will be emitted as error code later
523
- runner.failures = 130;
524
- });
525
-
526
- /**
527
- * Parse list.
528
- */
529
-
530
- function list(str) {
531
- return str.split(/ *, */);
532
- }
533
-
534
- /**
535
- * Hide the cursor.
536
- */
537
-
538
- function hideCursor() {
539
- process.stdout.write('\u001b[?25l');
540
- }
541
-
542
- /**
543
- * Show the cursor.
544
- */
545
-
546
- function showCursor() {
547
- process.stdout.write('\u001b[?25h');
548
- }
549
-
550
- /**
551
- * Stop play()ing.
552
- */
553
-
554
- function stop() {
555
- process.stdout.write('\u001b[2K');
556
- clearInterval(play.timer);
557
- }
558
-
559
- /**
560
- * Play the given array of strings.
561
- */
562
-
563
- function play(arr, interval) {
564
- var len = arr.length;
565
- interval = interval || 100;
566
- var i = 0;
567
-
568
- play.timer = setInterval(function () {
569
- var str = arr[i++ % len];
570
- process.stdout.write('\u001b[0G' + str);
571
- }, interval);
572
- }
package/bin/mocha-compat DELETED
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- /**
6
- * This tiny wrapper file checks for known node flags and appends them
7
- * when found, before invoking the "real" _mocha-compat(1) executable.
8
- */
9
-
10
- var spawn = require('child_process').spawn;
11
- var path = require('path');
12
- var getOptions = require('./options');
13
- var args = [path.join(__dirname, '_mocha-compat')];
14
-
15
- // Load mocha.opts into process.argv
16
- // Must be loaded here to handle node-specific options
17
- getOptions();
18
-
19
- process.argv.slice(2).forEach(function (arg) {
20
- var flag = arg.split('=')[0];
21
-
22
- switch (flag) {
23
- case '-d':
24
- args.unshift('--debug');
25
- args.push('--no-timeouts');
26
- break;
27
- case 'debug':
28
- case '--debug':
29
- case '--debug-brk':
30
- case '--inspect':
31
- case '--inspect-brk':
32
- args.unshift(arg);
33
- args.push('--no-timeouts');
34
- break;
35
- case '-gc':
36
- case '--expose-gc':
37
- args.unshift('--expose-gc');
38
- break;
39
- case '--gc-global':
40
- case '--es_staging':
41
- case '--no-deprecation':
42
- case '--no-warnings':
43
- case '--prof':
44
- case '--log-timer-events':
45
- case '--throw-deprecation':
46
- case '--trace-deprecation':
47
- case '--trace-warnings':
48
- case '--use_strict':
49
- case '--allow-natives-syntax':
50
- case '--perf-basic-prof':
51
- case '--napi-modules':
52
- args.unshift(arg);
53
- break;
54
- default:
55
- if (arg.indexOf('--harmony') === 0) {
56
- args.unshift(arg);
57
- } else if (arg.indexOf('--trace') === 0) {
58
- args.unshift(arg);
59
- } else if (arg.indexOf('--icu-data-dir') === 0) {
60
- args.unshift(arg);
61
- } else if (arg.indexOf('--max-old-space-size') === 0) {
62
- args.unshift(arg);
63
- } else if (arg.indexOf('--preserve-symlinks') === 0) {
64
- args.unshift(arg);
65
- } else {
66
- args.push(arg);
67
- }
68
- break;
69
- }
70
- });
71
-
72
- var proc = spawn(process.execPath, args, { stdio: 'inherit' });
73
- proc.on('exit', function (code, signal) {
74
- process.on('exit', function () {
75
- if (signal) {
76
- process.kill(process.pid, signal);
77
- } else {
78
- process.exit(code);
79
- }
80
- });
81
- });
82
-
83
- // terminate children.
84
- process.on('SIGINT', function () {
85
- proc.kill('SIGINT'); // calls runner.abort()
86
- proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
87
- });
package/bin/options.js DELETED
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Dependencies.
5
- */
6
-
7
- var fs = require('fs');
8
-
9
- /**
10
- * Export `getOptions`.
11
- */
12
-
13
- module.exports = getOptions;
14
-
15
- /**
16
- * Get options.
17
- */
18
-
19
- function getOptions () {
20
- var optsPath = process.argv.indexOf('--opts') === -1
21
- ? 'test/mocha.opts'
22
- : process.argv[process.argv.indexOf('--opts') + 1];
23
-
24
- try {
25
- var opts = fs.readFileSync(optsPath, 'utf8')
26
- .replace(/\\\s/g, '%20')
27
- .split(/\s/)
28
- .filter(Boolean)
29
- .map(function (value) {
30
- return value.replace(/%20/g, ' ');
31
- });
32
-
33
- process.argv = process.argv
34
- .slice(0, 2)
35
- .concat(opts.concat(process.argv.slice(2)));
36
- } catch (err) {
37
- // ignore
38
- }
39
-
40
- process.env.LOADED_MOCHA_OPTS = true;
41
- }