File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,37 @@ No time : End: This is a new test
191
191
stream close ]
192
192
]
193
193
194
+ { #category : #test }
195
+ TinyLoggerTest >> testExecuteRecordedAsKeepRightIndentation [
196
+ | contents stream |
197
+ self skipInPharo6.
198
+ logger
199
+ timestampFormatBlock: [ :s | s nextPutAll: ' No time' ];
200
+ removeAllLoggers;
201
+ addStdoutLogger.
202
+ stream := ' ' writeStream.
203
+ [ Stdio stub stdout willReturn: stream.
204
+ TinyCurrentLogger
205
+ value: logger
206
+ during: [ [ Object new execute: [ Error signal ] recordedAs: ' This is a new test' ]
207
+ on: Error
208
+ do: [ " nothing" ].
209
+ Object new execute: [ ' test' record ] recordedAs: ' This is a new test' ].
210
+ contents := Stdio stdout contents asString.
211
+ " Ensure we have the right indentation."
212
+ self
213
+ assert: contents withUnixLineEndings
214
+ equals:
215
+ ' No time : Begin: This is a new test
216
+ No time : End with error: This is a new test
217
+ No time : Begin: This is a new test
218
+ No time : test
219
+ No time : End: This is a new test
220
+ ' withUnixLineEndings ]
221
+ ensure : [ Stdio recoverFromGHMutation.
222
+ stream close ]
223
+ ]
224
+
194
225
{ #category : #test }
195
226
TinyLoggerTest >> testFileLoggers [
196
227
logger
Original file line number Diff line number Diff line change @@ -184,7 +184,11 @@ TinyLogger >> execute: aBlock recordedAs: aString [
184
184
self increaseDepthLevel.
185
185
self record: ' Begin: ' , aString.
186
186
self increaseDepthLevel.
187
- aBlock cull: aString.
187
+ [ aBlock cull: aString ]
188
+ ifCurtailed: [ " If there is an error, we ensure we keep the right indentation and we print an end of action with error."
189
+ self decreaseDepthLevel.
190
+ self record: ' End with error: ' , aString.
191
+ self decreaseDepthLevel ].
188
192
self decreaseDepthLevel.
189
193
self record: ' End: ' , aString.
190
194
self decreaseDepthLevel
You can’t perform that action at this time.
0 commit comments