Skip to content

Commit

Permalink
Add more end-to-end style tests for Logging
Browse files Browse the repository at this point in the history
- ANSI color output when using `printstyled`

- Correct output when using `show` and `display`
with long output.
  • Loading branch information
ReubenJ committed Aug 13, 2024
1 parent c633fc9 commit c9bdae8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/Logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ using Pluto.WorkspaceManager: poll
end
""",
"StructWithCustomShowThatLogs()", # 21
"""
printstyled(stdout, "hello", color=:red)
""", # 22
"show(collect(1:500))", # 23
"display(collect(1:500))", # 24
]))

@testset "Stdout" begin
Expand Down Expand Up @@ -123,6 +128,25 @@ using Pluto.WorkspaceManager: poll
end
end

@testset "ANSI Color Output" begin
update_run!(🍭, notebook, notebook.cells[22])
msg = only(notebook.cells[22].logs)["msg"][1]

@test startswith(msg, Base.text_colors[:red])
@test endswith(msg, Base.text_colors[:default])
end

@testset "show(...) and display(...) behavior" begin
update_run!(🍭, notebook, notebook.cells[23:24])

msg_show = only(notebook.cells[23].logs)["msg"][1]
msg_display = only(notebook.cells[24].logs)["msg"][1]

# Both should contain the first and last elements, but only `show` should contain the middle element
@test contains(msg_show, "250") && contains(msg_show, "500") && contains(msg_show, "1")
@test !contains(msg_display, "250") && contains(msg_display, "500") && contains(msg_display, "1")
end

@testset "Logging respects maxlog" begin
@testset "Single log" begin

Expand Down

0 comments on commit c9bdae8

Please sign in to comment.