From b0851f599377af0e8646e6db025280a495dd5c16 Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Wed, 21 Feb 2024 19:46:30 -0800 Subject: [PATCH] Test default_stdout_iocontext Check that each IOContext property is transferred to `stdout` and `stderr` as seen from inside a notebook --- test/StdIOContext.jl | 23 +++++++++++++++++++++++ test/runtests.jl | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 test/StdIOContext.jl diff --git a/test/StdIOContext.jl b/test/StdIOContext.jl new file mode 100644 index 0000000000..469ff134c8 --- /dev/null +++ b/test/StdIOContext.jl @@ -0,0 +1,23 @@ +using Test +import Pluto: PlutoRunner, Notebook, WorkspaceManager, Cell, ServerSession, update_run! + +@testset "stdout/stderr IOContext" begin + 🍭 = ServerSession() + 🍭.options.evaluation.workspace_use_distributed = true + + notebook = Notebook(reduce( + vcat, + # $(repr(p)) rather than just $p for parseable output, e.g., Symbols with colons + [ + Cell("($(repr(p))) in stdout"), + Cell("($(repr(p))) in stderr"), + ] for p in pairs(PlutoRunner.default_stdout_iocontext.dict) + )) + + update_run!(🍭, notebook, notebook.cells) + for cell in values(notebook.cells_dict) + @test cell.output.body == "true" + end + + WorkspaceManager.unmake_workspace((🍭, notebook)) +end diff --git a/test/runtests.jl b/test/runtests.jl index 3653efc485..e1bf62b574 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,6 +24,8 @@ verify_no_running_processes() verify_no_running_processes() @timeit_include("MacroAnalysis.jl") verify_no_running_processes() +@timeit_include("StdIOContext.jl") +verify_no_running_processes() @timeit_include("Logging.jl") verify_no_running_processes() @timeit_include("webserver.jl")