Skip to content

Commit 26c8326

Browse files
Support parallel runs that do not need to run test files
1 parent 7eb23dd commit 26c8326

File tree

16 files changed

+74
-10
lines changed

16 files changed

+74
-10
lines changed

lib/reporters/verbose.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class VerboseReporter {
9090
this.failFastEnabled = plan.failFastEnabled;
9191
this.matching = plan.matching;
9292
this.previousFailures = plan.previousFailures;
93+
this.emptyParallelRun = plan.status.emptyParallelRun;
9394

9495
if (this.watching || plan.files.length > 1) {
9596
this.prefixTitle = (testFile, title) => prefixTitle(plan.filePathPrefix, testFile, title);
@@ -320,6 +321,12 @@ class VerboseReporter {
320321
}
321322

322323
endRun() { // eslint-disable-line complexity
324+
if (this.emptyParallelRun) {
325+
this.lineWriter.writeLine('No files tested in this parallel run');
326+
this.lineWriter.writeLine();
327+
return;
328+
}
329+
323330
if (!this.stats) {
324331
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test`));
325332
this.lineWriter.writeLine();

lib/run-status.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class RunStatus extends Emittery {
88

99
this.pendingTests = new Map();
1010

11+
this.emptyParallelRun = parallelRuns &&
12+
parallelRuns.currentFileCount === 0 &&
13+
parallelRuns.totalRuns > 1 &&
14+
files > 0;
15+
1116
this.stats = {
1217
byFile: new Map(),
1318
declaredTests: 0,
@@ -143,6 +148,10 @@ class RunStatus extends Emittery {
143148
}
144149

145150
suggestExitCode(circumstances) {
151+
if (this.emptyParallelRun) {
152+
return 0;
153+
}
154+
146155
if (circumstances.matching && this.stats.selectedTests === 0) {
147156
return 1;
148157
}

test-tap/fixture/parallel-runs/2.js renamed to test-tap/fixture/parallel-runs/less-files-than-ci-total/2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const test = require('../../..');
1+
const test = require('../../../..');
22

33
test('at expected index', t => {
44
t.is(process.env.CI_NODE_INDEX, '0');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const test = require('../../../..');
2+
3+
test('at expected index', t => {
4+
t.is(process.env.CI_NODE_INDEX, '1');
5+
});

test-tap/fixture/parallel-runs/10.js renamed to test-tap/fixture/parallel-runs/more-files-than-ci-total/10.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const test = require('../../..');
1+
const test = require('../../../..');
22

33
test('at expected index', t => {
44
t.is(process.env.CI_NODE_INDEX, '1');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const test = require('../../../..');
2+
3+
test('at expected index', t => {
4+
t.is(process.env.CI_NODE_INDEX, '0');
5+
});

test-tap/fixture/parallel-runs/2a.js renamed to test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const test = require('../../..');
1+
const test = require('../../../..');
22

33
test('at expected index', t => {
44
t.is(process.env.CI_NODE_INDEX, '0');

test-tap/fixture/parallel-runs/9.js renamed to test-tap/fixture/parallel-runs/more-files-than-ci-total/9.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const test = require('../../..');
1+
const test = require('../../../..');
22

33
test('at expected index', t => {
44
t.is(process.env.CI_NODE_INDEX, '0');

test-tap/fixture/parallel-runs/Ab.js renamed to test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable unicorn/filename-case */
2-
const test = require('../../..');
2+
const test = require('../../../..');
33

44
test('at expected index', t => {
55
t.is(process.env.CI_NODE_INDEX, '1');

0 commit comments

Comments
 (0)