Fix error handling test

pull/137/head
Matti Pastell 2018-07-24 11:50:28 +02:00
parent e6cea19d5e
commit 57724aff67
4 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,5 @@
using Compat
using Markdown
#Contains report global properties
mutable struct Report <: AbstractDisplay
@ -44,7 +45,7 @@ function Base.display(report::Report, data)
end
catch e
throw(e)
warn("Failed to display data in \"$m\" format")
@warn("Failed to display data in \"$m\" format")
continue
end
break
@ -84,7 +85,7 @@ end
function Base.show(io, m::MIME"text/html", data::Exception)
println(io ,"<pre class=\"julia-error\">")
println(io, Base.Markdown.htmlesc("ERROR: " * sprint(showerror, data)))
println(io, Markdown.htmlesc("ERROR: " * sprint(showerror, data)))
println(io ,"</pre>")
end

View File

@ -248,7 +248,7 @@ function capture_output(expr, SandBox::Module, term, disp, plotlib,
catch E
throw_errors && throw(E)
display(E)
warn("ERROR: $(typeof(E)) occurred, including output in Weaved document")
@warn("ERROR: $(typeof(E)) occurred, including output in Weaved document")
finally
redirect_stdout(oldSTDOUT)
close(wr)

View File

@ -24,7 +24,7 @@ p1 = Weave.parse_doc(s1, "markdown")
doc = Weave.WeaveDoc("dummy1.jmd", p1, Dict())
doc1 = Weave.run(doc, doctype = "pandoc")
@test doc1.chunks[1].output == "Error: ArgumentError: Module NonExisting not found in current path.\nRun `Pkg.add(\"NonExisting\")` to install the NonExisting package.\n"
@test doc1.chunks[1].output == "Error: ArgumentError: Package Weave does not have NonExisting in its dependencies:\n - If you have Weave checked out for development and have\n added NonExisting as a dependency but haven't updated your primary\n environment's manifest file, try `Pkg.resolve()`.\n - Otherwise you may need to report an issue with Weave.\n\n"
@test doc1.chunks[2].output == "Error: syntax: incomplete: premature end of input\n"
@test doc1.chunks[3].output == "\njulia> plot(x)\nError: UndefVarError: plot not defined\n\njulia> y = 10\n10\n\njulia> print(y\nError: syntax: incomplete: premature end of input\n"
@ -32,12 +32,12 @@ try
doc2 = Weave.run(doc, doctype = "pandoc", throw_errors = true)
catch E
@test typeof(E) == ArgumentError
@test E.msg == "Module NonExisting not found in current path.\nRun `Pkg.add(\"NonExisting\")` to install the NonExisting package."
@test E.msg == "Package Weave does not have NonExisting in its dependencies:\n - If you have Weave checked out for development and have\n added NonExisting as a dependency but haven't updated your primary\n environment's manifest file, try `Pkg.resolve()`.\n - Otherwise you may need to report an issue with Weave.\n"
end
doc = Weave.WeaveDoc("dummy1.jmd", p1, Dict())
doc3 = Weave.run(doc, doctype = "md2html")
@test doc3.chunks[1].rich_output == "<pre class=\"julia-error\">\nERROR: ArgumentError: Module NonExisting not found in current path.\nRun &#96;Pkg.add&#40;&quot;NonExisting&quot;&#41;&#96; to install the NonExisting package.\n</pre>\n"
@test doc3.chunks[1].rich_output == "<pre class=\"julia-error\">\nERROR: ArgumentError: Package Weave does not have NonExisting in its dependencies:\n - If you have Weave checked out for development and have\n added NonExisting as a dependency but haven&#39;t updated your primary\n environment&#39;s manifest file, try &#96;Pkg.resolve&#40;&#41;&#96;.\n - Otherwise you may need to report an issue with Weave.\n\n</pre>\n"
@test doc3.chunks[2].rich_output == "<pre class=\"julia-error\">\nERROR: syntax: incomplete: premature end of input\n</pre>\n"
@test doc3.chunks[3].output == "\njulia> plot(x)\nError: UndefVarError: plot not defined\n\njulia> y = 10\n10\n\njulia> print(y\nError: syntax: incomplete: premature end of input\n"
@test doc3.chunks[3].rich_output == ""
@test doc3.chunks[3].rich_output == ""

View File

@ -5,8 +5,8 @@ using Test
@info("Test: Chunk options")
include("chunk_options.jl")
#@info("Testing error handling")
#include("errors_test.jl")
@info("Testing error handling")
include("errors_test.jl")
@info("Test: Converting")
include("convert_test.jl")