Browse Source

also capture standard output before error

pull/261/head
Tamás K. Papp 1 year ago
parent
commit
33832c68e0
  1. 4
      src/Literate.jl
  2. 5
      test/runtests.jl

4
src/Literate.jl

@ -942,8 +942,8 @@ function execute_block(sb::Module, block::String; inputfile::String, fake_source @@ -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))

5
test/runtests.jl

@ -1462,8 +1462,8 @@ end end @@ -1462,8 +1462,8 @@ 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
@ -1471,6 +1471,7 @@ end end @@ -1471,6 +1471,7 @@ end end
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

Loading…
Cancel
Save