mirror of https://github.com/mpastell/Weave.jl
add test
parent
66c33e6679
commit
e52c30f72e
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -44,6 +44,10 @@ end
|
||||||
include("test_chunk_options.jl")
|
include("test_chunk_options.jl")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "evaluation's meta info" begin
|
||||||
|
include("test_meta.jl")
|
||||||
|
end
|
||||||
|
|
||||||
@testset "error rendering" begin
|
@testset "error rendering" begin
|
||||||
include("test_error_rendering.jl")
|
include("test_error_rendering.jl")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
function get_err_str(ex)
|
using Weave: unwrap_load_err
|
||||||
|
|
||||||
|
|
||||||
|
function get_err_str(str::AbstractString)
|
||||||
try
|
try
|
||||||
eval(ex)
|
include_string(Main, str)
|
||||||
catch err
|
catch _err
|
||||||
|
err = unwrap_load_err(_err)
|
||||||
return sprint(showerror, err)
|
return sprint(showerror, err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
get_err_str(str::AbstractString) = get_err_str(Meta.parse(str; raise = false))
|
|
||||||
|
|
||||||
err_stmt1 = "using NonExisting"
|
err_stmt1 = "using NonExisting"
|
||||||
err_stmt2 = "x = "
|
err_stmt2 = "x = "
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
doc_body = """
|
||||||
|
```julia
|
||||||
|
include("test_include.jl")
|
||||||
|
```
|
||||||
|
|
||||||
|
```julia
|
||||||
|
@__MODULE__
|
||||||
|
```
|
||||||
|
|
||||||
|
```julia
|
||||||
|
@__DIR__
|
||||||
|
```
|
||||||
|
|
||||||
|
```julia
|
||||||
|
@__FILE__
|
||||||
|
```
|
||||||
|
|
||||||
|
```julia
|
||||||
|
@__LINE__ # broken
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
doc_dir = joinpath(@__DIR__, "mocks")
|
||||||
|
doc_path = joinpath(doc_dir, "test_meta.jmd")
|
||||||
|
write(doc_path, doc_body)
|
||||||
|
|
||||||
|
script_line = ":include_me"
|
||||||
|
script_body = "$script_line"
|
||||||
|
script_path = joinpath(@__DIR__, "mocks", "test_include.jl")
|
||||||
|
write(script_path, script_body)
|
||||||
|
|
||||||
|
|
||||||
|
m = Core.eval(@__MODULE__, :(module $(gensym(:WeaveTestModule)) end))
|
||||||
|
mock = run_doc(WeaveDoc(doc_path); mod = m)
|
||||||
|
check_output(i, s) = occursin(s, mock.chunks[i].output)
|
||||||
|
|
||||||
|
@test check_output(1, script_line)
|
||||||
|
@test check_output(2, string(m))
|
||||||
|
@test check_output(3, doc_dir)
|
||||||
|
@test check_output(4, doc_path)
|
||||||
|
@test_broken check_output(5, 18)
|
Loading…
Reference in New Issue