Browse Source

Define include in the sandbox module, fix #31.

pull/33/head v1.0.2
Fredrik Ekre 7 years ago
parent
commit
05d0b42dbf
  1. 6
      src/Literate.jl
  2. 7
      test/runtests.jl

6
src/Literate.jl

@ -511,6 +511,12 @@ end @@ -511,6 +511,12 @@ end
function execute_notebook(nb)
m = Module(gensym())
# eval(expr) is available in the REPL (i.e. Main) so we emulate that for the sandbox
Core.eval(m, :(eval(x) = Core.eval($m, x)))
# modules created with Module() does not have include defined
# abspath is needed since this will call `include_relative`
Core.eval(m, :(include(x) = Base.include($m, abspath(x))))
io = IOBuffer()
execution_count = 0

7
test/runtests.jl

@ -628,6 +628,13 @@ end @@ -628,6 +628,13 @@ end
lastidx = nextind(notebook, last(idx))
end
# issue #31
write(inputfile, "include(\"issue31.jl\")")
write(joinpath(outdir, "issue31.jl"), "10 + 21")
Literate.notebook(inputfile, outdir)
notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin("\"data\": {\n \"text/plain\": \"31\"\n }", notebook)
# test error when executing notebook
write(inputfile, "for i in 1:10\n println(i)")
r = try

Loading…
Cancel
Save