Skip to content

Commit 5342300

Browse files
IlrilanШилов Михаил Николаевич
andauthored
Fixed finishedTest checks in run-workers command with rerun parameter (#2237)
* Fixed finishedTest checks in run-workers command with rerun parameter * Fixed finishedTest checks in run-workers command with rerun parameter Co-authored-by: Шилов Михаил Николаевич <ext.mshilov@tinkoff.ru>
1 parent 52bc9c2 commit 5342300

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

lib/command/run-workers.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ module.exports = function (workers, options) {
4646
...overrideConfigs,
4747
};
4848

49+
const configRerun = config.rerun || {};
50+
let maxReruns = configRerun.maxReruns || 1;
51+
if (maxReruns > 1) {
52+
maxReruns *= numberOfWorkers;
53+
}
54+
4955
const testRoot = getTestRoot(configPath);
5056

5157
const codecept = new Codecept(config, options);
@@ -95,11 +101,11 @@ module.exports = function (workers, options) {
95101

96102
switch (message.event) {
97103
case event.test.failed:
98-
updateFinishedTests(repackTest(message.data));
104+
updateFinishedTests(repackTest(message.data), maxReruns);
99105
output.test.failed(repackTest(message.data));
100106
break;
101107
case event.test.passed: output.test.passed(repackTest(message.data));
102-
updateFinishedTests(repackTest(message.data));
108+
updateFinishedTests(repackTest(message.data), maxReruns);
103109
break;
104110
case event.suite.before: output.suite.started(message.data); break;
105111
case event.all.after: appendStats(message.data); break;
@@ -223,11 +229,21 @@ function simplifyObject(object) {
223229
}, {});
224230
}
225231

226-
const updateFinishedTests = (test) => {
232+
const updateFinishedTests = (test, maxReruns) => {
227233
const { id } = test;
228234
if (finishedTests[id]) {
229-
const stats = { passes: 0, failures: -1, tests: 0 };
230-
appendStats(stats);
235+
if (finishedTests[id].runs > maxReruns) {
236+
const stats = {
237+
passes: 0,
238+
failures: -1,
239+
tests: 0,
240+
};
241+
appendStats(stats);
242+
} else {
243+
finishedTests[id].runs++;
244+
}
245+
} else {
246+
finishedTests[id] = test;
247+
finishedTests[id].runs = 1;
231248
}
232-
finishedTests[id] = test;
233249
};

0 commit comments

Comments
 (0)