@@ -226,6 +226,7 @@ var TaskReporter_ = function(task, pid) {
226
226
this . pid = pid ;
227
227
this . failedCount = 0 ;
228
228
this . buffer = '' ;
229
+ this . insertTag = true ;
229
230
} ;
230
231
231
232
/**
@@ -235,18 +236,9 @@ var TaskReporter_ = function(task, pid) {
235
236
TaskReporter_ . prototype . reportHeader_ = function ( ) {
236
237
var capability = this . task . capability ;
237
238
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 ;
248
240
if ( this . task . specs . length === 1 ) {
249
- output += 'Specs: ' + this . task . specs . toString ( ) + eol ;
241
+ output += 'Specs: ' + this . task . specs . toString ( ) + eol + eol ;
250
242
}
251
243
this . log_ ( output ) ;
252
244
} ;
@@ -287,7 +279,10 @@ TaskReporter_.prototype.testsDone = function(failedCount) {
287
279
TaskReporter_ . prototype . flush = function ( ) {
288
280
if ( this . buffer ) {
289
281
// Flush buffer if nonempty
282
+ var eol = require ( 'os' ) . EOL ;
283
+ process . stdout . write ( eol + '------------------------------------' + eol ) ;
290
284
process . stdout . write ( this . buffer ) ;
285
+ process . stdout . write ( eol ) ;
291
286
this . buffer = '' ;
292
287
}
293
288
} ;
@@ -300,7 +295,30 @@ TaskReporter_.prototype.flush = function() {
300
295
* @param {string } data
301
296
*/
302
297
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
+ }
304
322
} ;
305
323
306
324
exports . init = init ;
0 commit comments