Skip to content

Commit

Permalink
also capture standard output before error
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Oct 17, 2024
1 parent 3a3bb74 commit 33832c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ function execute_block(sb::Module, block::String; inputfile::String, fake_source
if err isa LoadError # include_string may wrap error in LoadError
err = err.error
end
error_output = "ERROR: " * sprint(showerror, err)
return nothing, error_output, disp.data
all_output = c.output * "\n\nERROR: " * sprint(showerror, err)
return nothing, all_output, disp.data
else
error("""
$(sprint(showerror, c.value))
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1462,15 +1462,16 @@ end end
@testset "continue_on_error=true" begin
input_with_error =
"""
# The following will error
# The following will print something, then error
print("I always wanted to calculate")
sqrt(-1.0)
"""
mktempdir(@__DIR__) do sandbox
inputfile = joinpath(sandbox, "input.jl")
write(inputfile, input_with_error)
Literate.markdown(inputfile, sandbox; continue_on_error = true, execute = true)
output_md = read(joinpath(sandbox, "input.md"), String)
@test occursin("I always wanted to calculate", output_md)
@test occursin("ERROR: DomainError with -1.0", output_md)
end
end
Expand Down

0 comments on commit 33832c6

Please sign in to comment.