Skip to content

Commit 8c35a1a

Browse files
yatharthxsindresorhus
authored andcommitted
Fail hard when --concurrency is used without a value (#1373)
1 parent 140c0e0 commit 8c35a1a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib/cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ exports.run = () => {
118118
throw new Error(colors.error(figures.cross) + ' Watch mode is not available in CI, as it prevents AVA from terminating.');
119119
}
120120

121+
if (cli.flags.concurrency === '') {
122+
throw new Error(colors.error(figures.cross) + ' The --concurrency and -c flags must be provided the maximum number of test files to run at once.');
123+
}
124+
121125
if (hasFlag('--require') || hasFlag('-r')) {
122126
throw new Error(colors.error(figures.cross) + ' The --require and -r flags are deprecated. Requirements should be configured in package.json - see documentation.');
123127
}

test/cli.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,25 @@ test('bails when config contains `"tap": true` and `"watch": true`', t => {
364364
});
365365
});
366366

367+
['--concurrency', '-c'].forEach(concurrencyFlag => {
368+
test(`bails when ${concurrencyFlag} provided without value`, t => {
369+
execCli(['test.js', concurrencyFlag], {dirname: 'fixture/concurrency'}, (err, stdout, stderr) => {
370+
t.is(err.code, 1);
371+
t.match(stderr, 'The --concurrency and -c flags must be provided the maximum number of test files to run at once.');
372+
t.end();
373+
});
374+
});
375+
});
376+
377+
['--concurrency', '-c'].forEach(concurrencyFlag => {
378+
test(`works when ${concurrencyFlag} provided with value`, t => {
379+
execCli([`${concurrencyFlag}=1`, 'test.js'], {dirname: 'fixture/concurrency'}, err => {
380+
t.ifError(err);
381+
t.end();
382+
});
383+
});
384+
});
385+
367386
test('--match works', t => {
368387
execCli(['-m=foo', '-m=bar', '-m=!baz', '-m=t* a* f*', '-m=!t* a* n* f*', 'fixture/matcher-skip.js'], err => {
369388
t.ifError(err);

test/fixture/concurrency/test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import test from '../../../';
2+
3+
test('works', t => {
4+
t.pass();
5+
});

0 commit comments

Comments
 (0)