@@ -2,18 +2,39 @@ import OffsetArrays: OffsetArray
22import SparseArrays: sprand
33import Rotations: RotMatrix
44
5+ # workaround for github.com/JuliaLang/julia/issues/12711
6+ function _redirect_stdout (f:: Function , io:: IO )
7+ old_stdout = stdout
8+ rd, = redirect_stdout ()
9+ task = @async write (io, rd)
10+ try
11+ ret = f ()
12+ Libc. flush_cstdio ()
13+ flush (stdout )
14+ return ret
15+ finally
16+ close (rd)
17+ redirect_stdout (old_stdout)
18+ wait (task)
19+ end
20+ end
21+
522@testset " STDOUT" begin
623 # make sure it compiles and executes
724 for mode in (8 , 24 )
825 set_colormode (mode)
9- # 2D - Matrix
10- imshow (colorview (RGB, rand (3 , 2 , 3 )))
11- println ()
12- imshow (colorview (RGB, rand (3 , 2 , 3 )), (2 , 3 ))
13- println ()
14- # 3D
15- imshow (colorview (RGB, rand (3 , 3 , 4 , 2 )))
16- println ()
26+ io = PipeBuffer ()
27+ _redirect_stdout (io) do
28+ # 2D - Matrix
29+ @ensurecolor imshow (colorview (RGB, rand (3 , 2 , 3 )))
30+ println ()
31+ @ensurecolor imshow (colorview (RGB, rand (3 , 2 , 3 )), (2 , 3 ))
32+ println ()
33+ # 3D
34+ @ensurecolor imshow (colorview (RGB, rand (3 , 3 , 4 , 2 )))
35+ println ()
36+ end
37+ @test length (read (io, String)) > 500
1738 end
1839end
1940
7192 end
7293end
7394
74- set_colormode (8 )
95+ set_colormode (8 ) # reset to default state
0 commit comments