@@ -183,6 +183,7 @@ public function footer()
183
183
for ($ i = 0 ; $ i < $ errorCount ; $ i ++) {
184
184
list ($ test , $ error ) = $ this ->errors [$ i ];
185
185
$ this ->outputError ($ i + 1 , $ test , $ error );
186
+ $ this ->output ->writeln ('' );
186
187
}
187
188
}
188
189
@@ -191,7 +192,7 @@ public function footer()
191
192
*
192
193
* @param int $errorNumber
193
194
* @param TestInterface $test
194
- * @param $exception - an exception like interface with ->getMessage(), ->getTraceAsString ()
195
+ * @param $exception - an exception like interface with ->getMessage(), ->getTrace ()
195
196
*/
196
197
protected function outputError ($ errorNumber , TestInterface $ test , $ exception )
197
198
{
@@ -200,8 +201,32 @@ protected function outputError($errorNumber, TestInterface $test, $exception)
200
201
$ message = sprintf (" %s " , str_replace (PHP_EOL , PHP_EOL . " " , $ exception ->getMessage ()));
201
202
$ this ->output ->writeln ($ this ->color ('error ' , $ message ));
202
203
203
- $ trace = preg_replace ('/^#/m ' , " # " , $ exception ->getTraceAsString ());
204
- $ this ->output ->writeln ($ this ->color ('muted ' , $ trace ));
204
+ $ location = sprintf (' at %s:%d ' , $ exception ->getFile (), $ exception ->getLine ());
205
+ $ this ->output ->writeln ($ location );
206
+
207
+ $ this ->outputTrace ($ exception ->getTrace ());
208
+ }
209
+
210
+ /**
211
+ * Output a stack trace.
212
+ *
213
+ * @param array $trace
214
+ */
215
+ protected function outputTrace (array $ trace )
216
+ {
217
+ foreach ($ trace as $ index => $ entry ) {
218
+ if (isset ($ entry ['class ' ])) {
219
+ $ function = $ entry ['class ' ] . $ entry ['type ' ] . $ entry ['function ' ];
220
+ } else {
221
+ $ function = $ entry ['function ' ];
222
+ }
223
+
224
+ if (strncmp ($ function , 'Peridot \\' , 8 ) === 0 ) {
225
+ break ;
226
+ }
227
+
228
+ $ this ->output ->writeln ($ this ->color ('muted ' , $ this ->renderTraceEntry ($ index , $ entry , $ function )));
229
+ }
205
230
}
206
231
207
232
/**
@@ -309,4 +334,15 @@ private function isTtyTerminal(StreamOutput $output)
309
334
* @return void
310
335
*/
311
336
abstract public function init ();
337
+
338
+ private function renderTraceEntry ($ index , array $ entry , $ function )
339
+ {
340
+ if (isset ($ entry ['file ' ])) {
341
+ $ location = sprintf (' (%s:%d) ' , $ entry ['file ' ], $ entry ['line ' ]);
342
+ } else {
343
+ $ location = '' ;
344
+ }
345
+
346
+ return sprintf (' #%d %s%s ' , $ index , $ function , $ location );
347
+ }
312
348
}
0 commit comments