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

Commit f0e7984

Browse files
committed
feat(launcher): append capability tag for all output
1 parent 8f7c9d1 commit f0e7984

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

lib/launcher.js

+30-12
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ var TaskReporter_ = function(task, pid) {
226226
this.pid = pid;
227227
this.failedCount = 0;
228228
this.buffer = '';
229+
this.insertTag = true;
229230
};
230231

231232
/**
@@ -235,18 +236,9 @@ var TaskReporter_ = function(task, pid) {
235236
TaskReporter_.prototype.reportHeader_ = function() {
236237
var capability = this.task.capability;
237238
var eol = require('os').EOL;
238-
var output = eol + '------------------------------------' + eol;
239-
output += 'PID: ' + this.pid + ' (capability: ';
240-
output += (capability.browserName) ?
241-
capability.browserName : '';
242-
output += (capability.version) ?
243-
capability.version : '';
244-
output += (capability.platform) ?
245-
capability.platform : '';
246-
output += (' #' + this.task.taskId);
247-
output += ')' + eol;
239+
var output = 'PID: ' + this.pid + eol;
248240
if (this.task.specs.length === 1) {
249-
output += 'Specs: '+ this.task.specs.toString() + eol;
241+
output += 'Specs: '+ this.task.specs.toString() + eol + eol;
250242
}
251243
this.log_(output);
252244
};
@@ -287,7 +279,10 @@ TaskReporter_.prototype.testsDone = function(failedCount) {
287279
TaskReporter_.prototype.flush = function() {
288280
if (this.buffer) {
289281
// Flush buffer if nonempty
282+
var eol = require('os').EOL;
283+
process.stdout.write(eol + '------------------------------------' + eol);
290284
process.stdout.write(this.buffer);
285+
process.stdout.write(eol);
291286
this.buffer = '';
292287
}
293288
};
@@ -300,7 +295,30 @@ TaskReporter_.prototype.flush = function() {
300295
* @param {string} data
301296
*/
302297
TaskReporter_.prototype.log_ = function(data) {
303-
this.buffer += data;
298+
var tag = '[';
299+
var capability = this.task.capability;
300+
tag += (capability.browserName) ?
301+
capability.browserName : '';
302+
tag += (capability.version) ?
303+
(' ' + capability.version) : '';
304+
tag += (capability.platform) ?
305+
(' ' + capability.platform) : '';
306+
tag += (' #' + this.task.taskId);
307+
tag += '] ';
308+
309+
310+
data = data.toString();
311+
for ( var i = 0; i < data.length; i++ ) {
312+
if (this.insertTag) {
313+
this.insertTag = false;
314+
this.buffer += tag;
315+
}
316+
if (data[i] === '\n') {
317+
this.insertTag = true;
318+
this.buffer += '\x1B[0m'; // Prevent color from leaking into next line
319+
}
320+
this.buffer += data[i];
321+
}
304322
};
305323

306324
exports.init = init;

0 commit comments

Comments
 (0)