1
1
using TerminalLoggers: default_metafmt, format_message
2
2
3
+ using ProgressLogging
4
+
3
5
@noinline func1 () = backtrace ()
4
6
5
7
function dummy_metafmt (level, _module, group, id, file, line)
192
194
┌ PREFIX msg
193
195
│ exception =
194
196
│ DivideError: integer division error
195
- │ Stacktrace:
196
- │ [1] func1() at """ )
197
+ │ Stacktrace:""" )
198
+ @test occursin ( " [1] func1" , genmsg ( " msg " , exception = ( DivideError (),bt)) )
197
199
198
200
# Exception stacks
199
201
if VERSION >= v " 1.2"
@@ -211,19 +213,21 @@ end
211
213
end
212
214
213
215
@testset " Limiting large data structures" begin
214
- @test genmsg (" msg" , a= fill (1.00001 , 100 ,100 ), b= fill (2.00002 , 10 ,10 )) ==
216
+ a = fill (1.00001 , 10 ,10 )
217
+ b = fill (2.00002 , 10 ,10 )
218
+ @test genmsg (" msg" , a= a, b= b) ==
215
219
replace ("""
216
220
┌ PREFIX msg
217
221
│ a =
218
- │ 100×100 Array{Float64,2} :
222
+ │ $( summary (a)) :
219
223
│ 1.00001 1.00001 1.00001 1.00001 … 1.00001 1.00001 1.00001
220
224
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
221
225
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
222
226
│ ⋮ ⋱ EOL
223
227
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
224
228
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
225
229
│ b =
226
- │ 10×10 Array{Float64,2} :
230
+ │ $( summary (b)) :
227
231
│ 2.00002 2.00002 2.00002 2.00002 … 2.00002 2.00002 2.00002
228
232
│ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002
229
233
│ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002
@@ -237,11 +241,11 @@ end
237
241
(VERSION < v " 1.4-" ? " EOL" : " EOL" )=> " "
238
242
)
239
243
# Limiting the amount which is printed
240
- @test genmsg (" msg" , a= fill ( 1.00001 , 10 , 10 ) , show_limited= false ) ==
244
+ @test genmsg (" msg" , a= a , show_limited= false ) ==
241
245
"""
242
246
┌ PREFIX msg
243
247
│ a =
244
- │ 10×10 Array{Float64,2} :
248
+ │ $( summary (a)) :
245
249
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
246
250
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
247
251
│ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001
300
304
301
305
# For non-strings a blank line is added so that any formatting for
302
306
# vertical alignment isn't broken
303
- @test format_message ([ 1 2 ; 3 4 ] , 6 , io_ctx) ==
307
+ @test format_message (Text ( " 1 2 \n 3 4 " ) , 6 , io_ctx) ==
304
308
[" " ,
305
- " 2×2 Array{Int64,2}:" ,
306
309
" 1 2" ,
307
310
" 3 4" ]
308
311
end
393
396
Outer 100%\| █+\| Time: .*
394
397
"""
395
398
end
399
+
400
+ @static if VERSION >= v " 1.3.0"
401
+ @testset " Parallel progress" begin
402
+ buf = IOBuffer ()
403
+ io = IOContext (buf, :displaysize => (30 ,75 ), :color => false )
404
+ logger = TerminalLogger (io, Debug)
405
+ # Crude multithreading test: generate some contention.
406
+ #
407
+ # Generate some contention in multi-threaded cases
408
+ ntasks = 8
409
+ @sync begin
410
+ with_logger (logger) do
411
+ for i= 1 : ntasks
412
+ Threads. @spawn for j= 1 : 100
413
+ @info " XXXX <$i ,$j >" maxlog= 100
414
+ # sleep(0.001)
415
+ end
416
+ end
417
+ end
418
+ end
419
+ log_str = String (take! (buf))
420
+ @test length (findall (" XXXX" , log_str)) == 100
421
+
422
+ # Fun test of parallel progress logging to watch interactively:
423
+ #=
424
+ using ProgressLogging
425
+ @sync begin
426
+ for i=1:8
427
+ Threads.@spawn @progress name="task $i" threshold=0.00005 for j=1:10000
428
+ #sleep(0.001)
429
+ end
430
+ end
431
+ end
432
+ =#
433
+ end
434
+ end
396
435
end
0 commit comments