Skip to content

Commit 0d7cb29

Browse files
authored
test: continue running tests after crash, report crashes separately (#1362)
1 parent cfd3ae2 commit 0d7cb29

File tree

3 files changed

+132
-106
lines changed

3 files changed

+132
-106
lines changed

test/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ new Reporter(testRunner, {
138138
});
139139

140140
// await utils.initializeFlakinessDashboardIfNeeded(testRunner);
141-
testRunner.run().then(result => {
141+
testRunner.run({ totalTimeout: process.env.CI ? 15 * 60 * 1000 : 0 }).then(result => {
142142
process.exit(result.exitCode);
143143
});
144144

utils/testrunner/Reporter.js

+25-39
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Reporter {
3737
runner.on('finished', this._onFinished.bind(this));
3838
runner.on('teststarted', this._onTestStarted.bind(this));
3939
runner.on('testfinished', this._onTestFinished.bind(this));
40-
this._workersState = new Map();
4140
}
4241

4342
_onStarted(runnableTests) {
@@ -62,48 +61,33 @@ class Reporter {
6261
}
6362
}
6463

65-
_printTermination(result, message, error) {
66-
console.log(colors.red(`## ${result.toUpperCase()} ##`));
67-
console.log('Message:');
68-
console.log(` ${colors.red(message)}`);
69-
if (error && error.stack) {
70-
console.log('Stack:');
71-
console.log(padLines(error.stack, 2));
64+
_printFailedResult(result) {
65+
console.log(colors.red(`## ${result.result.toUpperCase()} ##`));
66+
if (result.message) {
67+
console.log('Message:');
68+
console.log(` ${colors.red(result.message)}`);
7269
}
73-
console.log('WORKERS STATE');
74-
const workerIds = Array.from(this._workersState.keys());
75-
workerIds.sort((a, b) => a - b);
76-
for (const workerId of workerIds) {
77-
const {isRunning, test} = this._workersState.get(workerId);
78-
let description = '';
79-
if (isRunning)
80-
description = colors.yellow('RUNNING');
81-
else if (test.result === 'ok')
82-
description = colors.green('OK');
83-
else if (test.result === 'skipped')
84-
description = colors.yellow('SKIPPED');
85-
else if (test.result === 'failed')
86-
description = colors.red('FAILED');
87-
else if (test.result === 'crashed')
88-
description = colors.red('CRASHED');
89-
else if (test.result === 'timedout')
90-
description = colors.red('TIMEDOUT');
91-
else if (test.result === 'terminated')
92-
description = colors.magenta('TERMINATED');
93-
else
94-
description = colors.red('<UNKNOWN>');
95-
console.log(` ${workerId}: [${description}] ${test.fullName} (${formatLocation(test.location)})`);
70+
71+
for (let i = 0; i < result.errors.length; i++) {
72+
const { message, error, workerId, tests } = result.errors[i];
73+
console.log(`\n${colors.magenta('NON-TEST ERROR #' + i)}: ${message}`);
74+
if (error && error.stack)
75+
console.log(padLines(error.stack, 2));
76+
const lastTests = tests.slice(tests.length - Math.min(10, tests.length));
77+
if (lastTests.length)
78+
console.log(`WORKER STATE`);
79+
for (let j = 0; j < lastTests.length; j++)
80+
this._printVerboseTestResult(j, lastTests[j], workerId);
9681
}
9782
console.log('');
9883
console.log('');
99-
process.exitCode = 2;
10084
}
10185

102-
_onFinished({result, terminationError, terminationMessage}) {
86+
_onFinished(result) {
10387
this._printTestResults();
104-
if (terminationMessage || terminationError)
105-
this._printTermination(result, terminationMessage, terminationError);
106-
process.exitCode = result === 'ok' ? 0 : 1;
88+
if (!result.ok())
89+
this._printFailedResult(result);
90+
process.exitCode = result.exitCode;
10791
}
10892

10993
_printTestResults() {
@@ -171,11 +155,9 @@ class Reporter {
171155
}
172156

173157
_onTestStarted(test, workerId) {
174-
this._workersState.set(workerId, {test, isRunning: true});
175158
}
176159

177160
_onTestFinished(test, workerId) {
178-
this._workersState.set(workerId, {test, isRunning: false});
179161
if (this._verbose) {
180162
++this._testCounter;
181163
this._printVerboseTestResult(this._testCounter, test, workerId);
@@ -240,7 +222,11 @@ class Reporter {
240222
console.log('');
241223
} else {
242224
console.log(' Message:');
243-
console.log(` ${colors.red(test.error.message || test.error)}`);
225+
let message = '' + (test.error.message || test.error);
226+
if (test.error.stack && message.includes(test.error.stack))
227+
message = message.substring(0, message.indexOf(test.error.stack));
228+
if (message)
229+
console.log(` ${colors.red(message)}`);
244230
if (test.error.stack) {
245231
console.log(' Stack:');
246232
let stack = test.error.stack;

0 commit comments

Comments
 (0)