Skip to content

Commit 8487ef2

Browse files
authored
feat(testrunner): add DEBUG to testrunner (#1014)
The plan is to collect logs for the whole test run and upload it later on using https://github.com/actions/upload-artifact Produced log size: - 163MB (8.5MB zipped) for Chromium: `DEBUG=* npm run unit 2>log` - 135MB (4.8MB zipped) for WebKit: `DEBUG=*,-pw:wrapped* npm run wunit 2>log` - 29MB (4.0MB zipped) for Firefox: `DEBUG=* npm run funit 2>log`
1 parent 2e9e0b7 commit 8487ef2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

utils/testrunner/TestRunner.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const EventEmitter = require('events');
2222
const Multimap = require('./Multimap');
2323
const fs = require('fs');
2424
const {SourceMapSupport} = require('./SourceMapSupport');
25+
const debug = require('debug');
2526

2627
const INFINITE_TIMEOUT = 2147483647;
2728

@@ -240,6 +241,7 @@ class TestPass {
240241
} else {
241242
// Otherwise, run the test itself if there is no scheduled termination.
242243
this._runningUserCallbacks.set(workerId, test._userCallback);
244+
this._runner._willStartTestBody(test, workerId);
243245
test.error = await test._userCallback.run(state, test);
244246
if (test.error)
245247
await this._runner._sourceMapSupport.rewriteStackTraceWithSourceMaps(test.error);
@@ -252,6 +254,7 @@ class TestPass {
252254
test.result = TestResult.Terminated;
253255
else
254256
test.result = TestResult.Failed;
257+
this._runner._didFinishTestBody(test, workerId);
255258
}
256259
for (let i = suitesStack.length - 1; i >= 0; i--)
257260
crashed = (await this._runHook(workerId, suitesStack[i], 'afterEach', state, test)) || crashed;
@@ -267,19 +270,23 @@ class TestPass {
267270
const hook = suite[hookName];
268271
if (!hook)
269272
return false;
273+
this._runner._willStartHook(suite, hook, hookName, workerId);
270274
this._runningUserCallbacks.set(workerId, hook);
271275
const error = await hook.run(...args);
272276
this._runningUserCallbacks.delete(workerId, hook);
273277
if (error === TimeoutError) {
274278
const location = `${hook.location.fileName}:${hook.location.lineNumber}:${hook.location.columnNumber}`;
275279
const message = `${location} - Timeout Exceeded ${hook.timeout}ms while running "${hookName}" in suite "${suite.fullName}"`;
280+
this._runner._didFailHook(suite, hook, hookName);
276281
return await this._terminate(TestResult.Crashed, message, null);
277282
}
278283
if (error) {
279284
const location = `${hook.location.fileName}:${hook.location.lineNumber}:${hook.location.columnNumber}`;
280285
const message = `${location} - FAILED while running "${hookName}" in suite "${suite.fullName}"`;
286+
this._runner._didFailHook(suite, hook, hookName);
281287
return await this._terminate(TestResult.Crashed, message, error);
282288
}
289+
this._runner._didCompleteHook(suite, hook, hookName);
283290
return false;
284291
}
285292

@@ -289,6 +296,7 @@ class TestPass {
289296
if (error && error.stack)
290297
await this._runner._sourceMapSupport.rewriteStackTraceWithSourceMaps(error);
291298
this._termination = {result, message, error};
299+
this._runner._willTerminate(this._termination);
292300
for (const userCallback of this._runningUserCallbacks.valuesArray())
293301
userCallback.terminate();
294302
return true;
@@ -509,6 +517,30 @@ class TestRunner extends EventEmitter {
509517
test.endTimestamp = Date.now();
510518
this.emit(TestRunner.Events.TestFinished, test, workerId);
511519
}
520+
521+
_willStartTestBody(test, workerId) {
522+
debug('testrunner:test')(`starting "${test.fullName}" (${test.location.fileName + ':' + test.location.lineNumber})`);
523+
}
524+
525+
_didFinishTestBody(test, workerId) {
526+
debug('testrunner:test')(`${test.result.toUpperCase()} "${test.fullName}" (${test.location.fileName + ':' + test.location.lineNumber})`);
527+
}
528+
529+
_willStartHook(suite, hook, hookName, workerId) {
530+
debug('testrunner:hook')(`"${hookName}" started for "${suite.fullName}" (${hook.location.fileName + ':' + hook.location.lineNumber})`);
531+
}
532+
533+
_didFailHook(suite, hook, hookName, workerId) {
534+
debug('testrunner:hook')(`"${hookName}" FAILED for "${suite.fullName}" (${hook.location.fileName + ':' + hook.location.lineNumber})`);
535+
}
536+
537+
_didCompleteHook(suite, hook, hookName, workerId) {
538+
debug('testrunner:hook')(`"${hookName}" OK for "${suite.fullName}" (${hook.location.fileName + ':' + hook.location.lineNumber})`);
539+
}
540+
541+
_willTerminate(termination) {
542+
debug('testrunner')(`TERMINTED result = ${termination.result}, message = ${termination.message}`);
543+
}
512544
}
513545

514546
async function setLogBreakpoints(debuggerLogBreakpoints) {

0 commit comments

Comments
 (0)