Skip to content

Commit

Permalink
feat(util): Allow more verbose logging with multiple sessions (angula…
Browse files Browse the repository at this point in the history
  • Loading branch information
heathkit authored Sep 1, 2016
1 parent e0b151a commit 30102fb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
7 changes: 7 additions & 0 deletions docs/referenceConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ exports.config = {
// Use a number less than 1 to denote unlimited. Default is unlimited.
maxSessions: -1,

// Whether or not to buffer output when running tests on multiple browsers
// in parallel. By default, when running multiple browser sessions, the
// results are buffered and not logged until the test run finishes. If true,
// when running multiple sessions in parallel results will be logged when each
// test finishes.
verboseMultiSessions: false,

// ---------------------------------------------------------------------------
// ----- Global test information ---------------------------------------------
// ---------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ export interface Config {
*/
maxSessions?: number;

/**
* Whether or not to buffer output when running tests on multiple browsers
* in parallel. By default, when running multiple browser sessions, the
* results are buffered and not logged until the test run finishes. If true,
* when running multiple sessions in parallel results will be logged when
* each test finishes.
*/
verboseMultiSessions?: boolean;

// ---------------------------------------------------------------------------
// ----- Global test information
// ---------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions lib/configParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ConfigParser {
this.config_ = {
specs: [],
multiCapabilities: [],
verboseMultiSessions: false,
rootElement: 'body',
allScriptsTimeout: 11000,
getPageTimeout: 10000,
Expand Down
13 changes: 11 additions & 2 deletions lib/taskLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ export class TaskLogger {
}

/**
* Flushes the buffer to stdout.
* Prints the contents of the buffer without clearing it.
*/
public flush(): void {
public peek(): void {
if (this.buffer) {
// Flush buffer if nonempty
logger.info(os.EOL + '------------------------------------' + os.EOL);
logger.info(this.buffer);
logger.info(os.EOL);
}
}

/**
* Flushes the buffer to stdout.
*/
public flush(): void {
if (this.buffer) {
this.peek();
this.buffer = '';
}
}
Expand Down
25 changes: 14 additions & 11 deletions lib/taskRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ export class TaskRunner extends EventEmitter {
specResults: []
};

let configParser = new ConfigParser();
if (this.configFile) {
configParser.addFileConfig(this.configFile);
}
if (this.additionalConfig) {
configParser.addConfig(this.additionalConfig);
}
let config = configParser.getConfig();
config.capabilities = this.task.capabilities;
config.specs = this.task.specs;

if (this.runInFork) {
let deferred = q.defer();

Expand All @@ -72,6 +83,9 @@ export class TaskRunner extends EventEmitter {
childProcess
.on('message',
(m: any) => {
if (config.verboseMultiSessions) {
taskLogger.peek();
}
switch (m.event) {
case 'testPass':
process.stdout.write('.');
Expand Down Expand Up @@ -106,17 +120,6 @@ export class TaskRunner extends EventEmitter {

return deferred.promise;
} else {
let configParser = new ConfigParser();
if (this.configFile) {
configParser.addFileConfig(this.configFile);
}
if (this.additionalConfig) {
configParser.addConfig(this.additionalConfig);
}
let config = configParser.getConfig();
config.capabilities = this.task.capabilities;
config.specs = this.task.specs;

let runner = new Runner(config);

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

0 comments on commit 30102fb

Please sign in to comment.