@@ -35,6 +35,8 @@ final class Printer implements Tracer
35
35
36
36
private ?Throwable $ throwable = null ;
37
37
38
+ private ?Trace $ trace = null ;
39
+
38
40
private bool $ flawless = true ;
39
41
40
42
public function __construct (private readonly PipConfig $ config )
@@ -60,15 +62,15 @@ public function trace(Event $event): void
60
62
$ this ->status ??= $ this ->flawless ? TestStatus::Passed : TestStatus::Flawed;
61
63
}
62
64
if ($ event instanceof Failed) {
63
- $ this ->throwable = $ event ->throwable ();
64
-
65
65
$ this ->status ??= TestStatus::Failed;
66
+
67
+ $ this ->throwable = $ event ->throwable ();
66
68
$ this ->flawless = false ;
67
69
}
68
70
if ($ event instanceof Errored) {
69
- $ this ->throwable = $ event ->throwable ();
70
-
71
71
$ this ->status ??= TestStatus::Errored;
72
+
73
+ $ this ->throwable = $ event ->throwable ();
72
74
$ this ->flawless = false ;
73
75
}
74
76
if ($ event instanceof Skipped) {
@@ -82,15 +84,23 @@ public function trace(Event $event): void
82
84
if ($ this ->status === TestStatus::Passed || $ this ->status === TestStatus::Flawed) {
83
85
$ this ->status = TestStatus::Risky;
84
86
}
87
+
88
+ $ this ->trace = new Trace ($ event ->message (), $ event ->test ()->file (), $ event ->test ()->line ());
85
89
}
86
90
if ($ event instanceof PhpNoticeTriggered) {
87
91
$ this ->status ??= TestStatus::Notice;
92
+
93
+ $ this ->trace = Trace::fromEvent ($ event );
88
94
}
89
95
if ($ event instanceof PhpWarningTriggered) {
90
96
$ this ->status ??= TestStatus::Warning;
97
+
98
+ $ this ->trace = Trace::fromEvent ($ event );
91
99
}
92
100
if ($ event instanceof PhpDeprecationTriggered) {
93
101
$ this ->status ??= TestStatus::Deprecated;
102
+
103
+ $ this ->trace = Trace::fromEvent ($ event );
94
104
}
95
105
96
106
if ($ event instanceof Finished) {
@@ -153,6 +163,19 @@ public function trace(Event $event): void
153
163
}
154
164
}
155
165
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
+
156
179
$ this ->status = null ;
157
180
}
158
181
0 commit comments