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 4fae19b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/Logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ using Pluto.WorkspaceManager: poll
end
""",
"StructWithCustomShowThatLogs()", # 21
"""
printstyled(stdout, "hello", color=:red)
""", # 22
"show(collect(1:500))", # 23
"show(stdout, collect(1:500))", # 24
"show(stdout, \"text/plain\", collect(1:500))", # 25
"display(collect(1:500))", # 26
]))

@testset "Stdout" begin
Expand Down Expand Up @@ -123,6 +130,33 @@ 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:25])

msgs_show = [only(cell.logs)["msg"][1] for cell in notebook.cells[23:25]]

# `show` should show a middle element of the big array
for msg in msgs_show
@test contains(msg, "1") && contains(msg, "500")
@test contains(msg, "250")
end

update_run!(🍭, notebook, notebook.cells[26])
msg_display = only(notebook.cells[26].logs)["msg"][1]

# `display` should not display the middle element of the big array
@test contains(msg_display, "1") && contains(msg_display, "500")
@test !contains(msg_display, "250")
end

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

Expand Down

0 comments on commit 4fae19b

Please sign in to comment.