Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thazhemadam committed Oct 6, 2021
1 parent 7db71d2 commit 6471471
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/terminal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ const keydict = Dict(:up => "\e[A",
if isdefined(Base, :active_repl)
@test Cthulhu.default_terminal() isa REPL.Terminals.TTYTerminal
end
colorize(use_color::Bool, c::Char) = Cthulhu.stringify() do io
use_color ? printstyled(io, c; color=:cyan) : print(io, c)
colorize(active_option::Bool, c::Char) = Cthulhu.stringify() do io
active_option ? printstyled(io, c; color=:green) : printstyled(io, c; color=:red)
end

colorize(s::AbstractString; color::Symbol = :cyan) = Cthulhu.stringify() do io
printstyled(io, s; color)
end

# Write a file that we track with Revise. Creating it programmatically allows us to rewrite it with
# different content
fn = tempname()
Expand Down Expand Up @@ -64,14 +69,14 @@ const keydict = Dict(:up => "\e[A",
@test occursin('[' * colorize(true, 'o') * "]ptimize", lines)
@test occursin('[' * colorize(true, 'T') * "]yped", lines)

@test occursin("\nSelect a call to descend into", lines) # beginning of the line
@test occursin('\n' * colorize("Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark."; color = :blue), lines) # beginning of the line
@test occursin('', lines)
write(in, 'o') # switch to unoptimized
lines = cread(out)
@test occursin("invoke simplef(::Float32,::Int32)::Float32", lines)
@test occursin(r"\(z = a \* a\)\u001B\[\d\dm::Float32\u001B\[39m", lines)
@test occursin('[' * colorize(false, 'o') * "]ptimize", lines)
@test occursin("\nSelect a call to descend into", lines) # beginning of the line
@test occursin('\n' * colorize("Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark."; color = :blue), lines) # beginning of the line
@test occursin("• %1 = *(::Float32,::Float32)::Float32", lines)
# Call selection
write(in, keydict[:down])
Expand Down Expand Up @@ -103,7 +108,7 @@ const keydict = Dict(:up => "\e[A",
@test occursin(r"z.*::Float32", lines)
@test occursin(r"\nBody.*Float32", lines)
@test occursin('[' * colorize(true, 'w') * "]arn", lines)
@test occursin("\nSelect a call to descend into", lines) # beginning of the line
@test occursin('\n' * colorize("Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark."; color = :blue), lines) # beginning of the line
@test occursin("• %1 = *(::Float32,::Float32)::Float32", lines)
# Source view
write(in, 'S')
Expand Down Expand Up @@ -146,7 +151,7 @@ const keydict = Dict(:up => "\e[A",
write(in, 'd'); cread(out)
write(in, 'L')
lines = cread(out)
@test occursin('[' * colorize(false, 'd') * "]ebuginfo", lines)
@test occursin("[d]ebuginfo", lines)
@test !occursin("┌ @ promotion.jl", lines)
# Native-code view
write(in, 'N')
Expand Down

0 comments on commit 6471471

Please sign in to comment.