Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 30102fb

Browse files
authored
feat(util): Allow more verbose logging with multiple sessions (#2985). (#3499)
1 parent e0b151a commit 30102fb

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

docs/referenceConf.js

+7
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ exports.config = {
200200
// Use a number less than 1 to denote unlimited. Default is unlimited.
201201
maxSessions: -1,
202202

203+
// Whether or not to buffer output when running tests on multiple browsers
204+
// in parallel. By default, when running multiple browser sessions, the
205+
// results are buffered and not logged until the test run finishes. If true,
206+
// when running multiple sessions in parallel results will be logged when each
207+
// test finishes.
208+
verboseMultiSessions: false,
209+
203210
// ---------------------------------------------------------------------------
204211
// ----- Global test information ---------------------------------------------
205212
// ---------------------------------------------------------------------------

lib/config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ export interface Config {
309309
*/
310310
maxSessions?: number;
311311

312+
/**
313+
* Whether or not to buffer output when running tests on multiple browsers
314+
* in parallel. By default, when running multiple browser sessions, the
315+
* results are buffered and not logged until the test run finishes. If true,
316+
* when running multiple sessions in parallel results will be logged when
317+
* each test finishes.
318+
*/
319+
verboseMultiSessions?: boolean;
320+
312321
// ---------------------------------------------------------------------------
313322
// ----- Global test information
314323
// ---------------------------------------------

lib/configParser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class ConfigParser {
2828
this.config_ = {
2929
specs: [],
3030
multiCapabilities: [],
31+
verboseMultiSessions: false,
3132
rootElement: 'body',
3233
allScriptsTimeout: 11000,
3334
getPageTimeout: 10000,

lib/taskLogger.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,23 @@ export class TaskLogger {
3232
}
3333

3434
/**
35-
* Flushes the buffer to stdout.
35+
* Prints the contents of the buffer without clearing it.
3636
*/
37-
public flush(): void {
37+
public peek(): void {
3838
if (this.buffer) {
3939
// Flush buffer if nonempty
4040
logger.info(os.EOL + '------------------------------------' + os.EOL);
4141
logger.info(this.buffer);
4242
logger.info(os.EOL);
43+
}
44+
}
45+
46+
/**
47+
* Flushes the buffer to stdout.
48+
*/
49+
public flush(): void {
50+
if (this.buffer) {
51+
this.peek();
4352
this.buffer = '';
4453
}
4554
}

lib/taskRunner.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ export class TaskRunner extends EventEmitter {
5353
specResults: []
5454
};
5555

56+
let configParser = new ConfigParser();
57+
if (this.configFile) {
58+
configParser.addFileConfig(this.configFile);
59+
}
60+
if (this.additionalConfig) {
61+
configParser.addConfig(this.additionalConfig);
62+
}
63+
let config = configParser.getConfig();
64+
config.capabilities = this.task.capabilities;
65+
config.specs = this.task.specs;
66+
5667
if (this.runInFork) {
5768
let deferred = q.defer();
5869

@@ -72,6 +83,9 @@ export class TaskRunner extends EventEmitter {
7283
childProcess
7384
.on('message',
7485
(m: any) => {
86+
if (config.verboseMultiSessions) {
87+
taskLogger.peek();
88+
}
7589
switch (m.event) {
7690
case 'testPass':
7791
process.stdout.write('.');
@@ -106,17 +120,6 @@ export class TaskRunner extends EventEmitter {
106120

107121
return deferred.promise;
108122
} else {
109-
let configParser = new ConfigParser();
110-
if (this.configFile) {
111-
configParser.addFileConfig(this.configFile);
112-
}
113-
if (this.additionalConfig) {
114-
configParser.addConfig(this.additionalConfig);
115-
}
116-
let config = configParser.getConfig();
117-
config.capabilities = this.task.capabilities;
118-
config.specs = this.task.specs;
119-
120123
let runner = new Runner(config);
121124

122125
runner.on('testsDone', (results: RunResults) => {

0 commit comments

Comments
 (0)