|
1 | 1 | const path = require('path');
|
2 | 2 | const fs = require('fs');
|
| 3 | +const os = require('os'); |
3 | 4 | const unWindows = require('./unWindows');
|
4 | 5 |
|
5 | 6 | exports = module.exports = Command;
|
@@ -114,9 +115,15 @@ function parseOptions(argv, isWindows) {
|
114 | 115 | } else if (arg.match("^--reporter=")) {
|
115 | 116 | reporter = arg.match("^--reporter=(.*)")[1];
|
116 | 117 | } else if (arg.match("^--parallel=(.*)")) {
|
117 |
| - numWorkers = parseFloat(arg.match("^--parallel=(.*)")[1]); |
118 |
| - if (isNaN(numWorkers) || numWorkers < 2 || numWorkers !== Math.floor(numWorkers)) { |
119 |
| - usageErrors.push('Argument to --parallel= must be an integer greater than 1'); |
| 118 | + const w = arg.match("^--parallel=(.*)")[1]; |
| 119 | + if (w === 'auto') { |
| 120 | + // A reasonable default in most situations |
| 121 | + numWorkers = os.cpus().length -1; |
| 122 | + } else { |
| 123 | + numWorkers = parseFloat(w); |
| 124 | + if (isNaN(numWorkers) || numWorkers < 2 || numWorkers !== Math.floor(numWorkers)) { |
| 125 | + usageErrors.push('Argument to --parallel= must be an integer greater than 1'); |
| 126 | + } |
120 | 127 | }
|
121 | 128 | } else if (arg === '--') {
|
122 | 129 | break;
|
@@ -291,6 +298,7 @@ function help(options) {
|
291 | 298 |
|
292 | 299 | print('Options:');
|
293 | 300 | print('%s\tRun in parallel with N workers', lPad('--parallel=N', 18));
|
| 301 | + print('%s\tRun in parallel with an automatically chosen number of workers', lPad('--parallel=auto', 18)); |
294 | 302 | print('%s\tturn off color in spec output', lPad('--no-color', 18));
|
295 | 303 | print('%s\tforce turn on color in spec output', lPad('--color', 18));
|
296 | 304 | print('%s\tfilter specs to run only those that match the given string', lPad('--filter=', 18));
|
|
0 commit comments