@@ -6,6 +6,11 @@ var ProcessLauncher = function (spawn, tempDir, timer, processKillTimeout) {
6
6
var self = this
7
7
var onExitCallback
8
8
var killTimeout = processKillTimeout || 2000
9
+ // Will hold output from the spawned child process
10
+ var streamedOutputs = {
11
+ stdout : '' ,
12
+ stderr : ''
13
+ }
9
14
10
15
this . _tempDir = tempDir . getPath ( '/karma-' + this . id . toString ( ) )
11
16
@@ -46,6 +51,14 @@ var ProcessLauncher = function (spawn, tempDir, timer, processKillTimeout) {
46
51
return path . normalize ( cmd )
47
52
}
48
53
54
+ this . _onStdout = function ( data ) {
55
+ streamedOutputs . stdout += data
56
+ }
57
+
58
+ this . _onStderr = function ( data ) {
59
+ streamedOutputs . stderr += data
60
+ }
61
+
49
62
this . _execCommand = function ( cmd , args ) {
50
63
if ( ! cmd ) {
51
64
log . error ( 'No binary for %s browser on your platform.\n ' +
@@ -61,9 +74,12 @@ var ProcessLauncher = function (spawn, tempDir, timer, processKillTimeout) {
61
74
62
75
log . debug ( cmd + ' ' + args . join ( ' ' ) )
63
76
self . _process = spawn ( cmd , args )
64
-
65
77
var errorOutput = ''
66
78
79
+ self . _process . stdout . on ( 'data' , self . _onStdout )
80
+
81
+ self . _process . stderr . on ( 'data' , self . _onStderr )
82
+
67
83
self . _process . on ( 'exit' , function ( code ) {
68
84
self . _onProcessExit ( code , errorOutput )
69
85
} )
@@ -98,7 +114,14 @@ var ProcessLauncher = function (spawn, tempDir, timer, processKillTimeout) {
98
114
error = 'crashed'
99
115
}
100
116
117
+ if ( error ) {
118
+ log . error ( '%s stdout: %s' , self . name , streamedOutputs . stdout )
119
+ log . error ( '%s stderr: %s' , self . name , streamedOutputs . stderr )
120
+ }
121
+
101
122
self . _process = null
123
+ streamedOutputs . stdout = ''
124
+ streamedOutputs . stderr = ''
102
125
if ( self . _killTimer ) {
103
126
timer . clearTimeout ( self . _killTimer )
104
127
self . _killTimer = null
0 commit comments