11using ProfileView
22using Cthulhu
3- if ! isdefined (@__MODULE__ , :fake_terminal )
4- @eval (@__MODULE__ ) begin
5- include (joinpath (pkgdir (Cthulhu), " test" , " FakeTerminals.jl" ))
6- using . FakeTerminals
7- macro with_try_stderr (out, expr)
8- quote
9- try
10- $ (esc (expr))
11- catch err
12- bt = catch_backtrace ()
13- Base. display_error (stderr , err, bt)
14- # close($(esc(out)))
15- end
16- end
17- end
18- end
19- end
3+ using Cthulhu. Testing
4+ # if !isdefined(@__MODULE__, Symbol("@with_try_stderr"))
5+ # macro with_try_stderr(out, expr)
6+ # quote
7+ # try
8+ # $(esc(expr))
9+ # catch err
10+ # bt = catch_backtrace()
11+ # Base.display_error(stderr, err, bt)
12+ # end
13+ # end
14+ # end
15+ # end
16+ # end
2017using Test
2118
2219@testset " Extensions" begin
2320 @testset " Cthulhu" begin
24- cread1 (io) = readuntil (io, ' ↩' ; keep= true )
25- cread (io) = cread1 (io) * cread1 (io)
26-
21+ println (" starting Cthulhu extension tests" )
2722 # profile_test(1) # defined in test/runtests.jl
2823 # @profile profile_test(10)
2924 _, bt = add2 (Any[1 ,2 ])
3025 st = stacktrace (bt)
3126 ProfileView. clicked[] = st[1 ]
32- fake_terminal () do term, in, out, _
33- t = @async begin
34- @with_try_stderr out descend_clicked (; interruptexc= false , terminal= term)
35- end
36- lines = cread (out)
37- @test occursin (" Select a call to descend into" , lines)
38- write (in, ' q' )
39- wait (t)
40- end
27+ terminal = VirtualTerminal ()
28+ harness = Testing. @run terminal descend_clicked (; terminal)
29+ displayed, text = Testing. read_next (harness)
30+ @test occursin (" Select a call to descend into" , text)
31+ @test Testing. end_terminal_session (harness)
32+ println (" finished 1" )
33+ terminal = VirtualTerminal ()
4134 ProfileView. clicked_trace[] = st
42- fake_terminal () do term, in, out, _
43- t = @async begin
44- @with_try_stderr out ascend_clicked (; interruptexc= false , terminal= term)
45- end
46- lines = readuntil (out, ' q' ; keep= true ) # up to the "q to quit" prompt
47- @test occursin (" Choose a call for analysis" , lines)
48- write (in, ' q' )
49- write (in, ' q' )
50- wait (t)
51- end
35+ harness = Testing. @run terminal ascend_clicked (; terminal)
36+ # descend into something to generate a next "section" to read,
37+ # as VirtualTerminal is designed to read `descend` output
38+ write (terminal, :enter )
39+ displayed, text = Testing. read_next (harness)
40+ @test occursin (" Choose a call for analysis" , text)
41+ @test Testing. end_terminal_session (harness)
42+ println (" finished 2" )
5243 end
5344end
0 commit comments