@@ -35,6 +35,8 @@ final class Printer implements Tracer
3535
3636 private ?Throwable $ throwable = null ;
3737
38+ private ?Trace $ trace = null ;
39+
3840 private bool $ flawless = true ;
3941
4042 public function __construct (private readonly PipConfig $ config )
@@ -60,15 +62,15 @@ public function trace(Event $event): void
6062 $ this ->status ??= $ this ->flawless ? TestStatus::Passed : TestStatus::Flawed;
6163 }
6264 if ($ event instanceof Failed) {
63- $ this ->throwable = $ event ->throwable ();
64-
6565 $ this ->status ??= TestStatus::Failed;
66+
67+ $ this ->throwable = $ event ->throwable ();
6668 $ this ->flawless = false ;
6769 }
6870 if ($ event instanceof Errored) {
69- $ this ->throwable = $ event ->throwable ();
70-
7171 $ this ->status ??= TestStatus::Errored;
72+
73+ $ this ->throwable = $ event ->throwable ();
7274 $ this ->flawless = false ;
7375 }
7476 if ($ event instanceof Skipped) {
@@ -82,15 +84,23 @@ public function trace(Event $event): void
8284 if ($ this ->status === TestStatus::Passed || $ this ->status === TestStatus::Flawed) {
8385 $ this ->status = TestStatus::Risky;
8486 }
87+
88+ $ this ->trace = new Trace ($ event ->message (), $ event ->test ()->file (), $ event ->test ()->line ());
8589 }
8690 if ($ event instanceof PhpNoticeTriggered) {
8791 $ this ->status ??= TestStatus::Notice;
92+
93+ $ this ->trace = Trace::fromEvent ($ event );
8894 }
8995 if ($ event instanceof PhpWarningTriggered) {
9096 $ this ->status ??= TestStatus::Warning;
97+
98+ $ this ->trace = Trace::fromEvent ($ event );
9199 }
92100 if ($ event instanceof PhpDeprecationTriggered) {
93101 $ this ->status ??= TestStatus::Deprecated;
102+
103+ $ this ->trace = Trace::fromEvent ($ event );
94104 }
95105
96106 if ($ event instanceof Finished) {
@@ -153,6 +163,19 @@ public function trace(Event $event): void
153163 }
154164 }
155165
166+ if ($ this ->trace ) {
167+ printf (
168+ Color::colorize ("fg- {$ this ->status ->getColour ()}" , '%s%s: %s in %s on line %s%1$s%1$s ' ),
169+ PHP_EOL ,
170+ $ this ->status ->name ,
171+ $ this ->trace ->message ,
172+ $ this ->trace ->file ,
173+ $ this ->trace ->line
174+ );
175+
176+ $ this ->trace = null ;
177+ }
178+
156179 $ this ->status = null ;
157180 }
158181
0 commit comments