mirror of https://github.com/mpastell/Weave.jl
Fix notebook test
parent
c1795e7310
commit
361f404f95
|
@ -1,9 +1,8 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Base.Test
|
||||||
|
|
||||||
function convert_test(outfile)
|
function convert_test(outfile, infile="documents/chunk_options.noweb")
|
||||||
outfile = joinpath("documents/convert", outfile)
|
outfile = joinpath("documents/convert", outfile)
|
||||||
infile = "documents/chunk_options.noweb"
|
|
||||||
convert_doc(infile, outfile)
|
convert_doc(infile, outfile)
|
||||||
result = readstring(outfile)
|
result = readstring(outfile)
|
||||||
ref = readstring(outfile * ".ref")
|
ref = readstring(outfile * ".ref")
|
||||||
|
@ -14,16 +13,27 @@ end
|
||||||
convert_test("chunk_options.jmd")
|
convert_test("chunk_options.jmd")
|
||||||
convert_test("chunk_options.jl")
|
convert_test("chunk_options.jl")
|
||||||
convert_test("chunk_options.mdw")
|
convert_test("chunk_options.mdw")
|
||||||
#convert_test("chunk_options.ipynb") #TODO fix this, fails due to version number in notebook
|
convert_test("chunk_options_nb.mdw", "documents/chunk_options.ipynb")
|
||||||
|
|
||||||
function convert_test_nb(outfile)
|
# Separate test for notebook (output depends on julia version)
|
||||||
outfile = joinpath("documents/convert", outfile)
|
function contents(chunk::Weave.DocChunk)
|
||||||
infile = "documents/chunk_options.ipynb"
|
return join([strip(c.content) for c in chunk.content], "")
|
||||||
convert_doc(infile, outfile)
|
|
||||||
result = readstring(outfile)
|
|
||||||
ref = readstring(outfile * ".ref")
|
|
||||||
rm(outfile)
|
|
||||||
@test result == ref
|
|
||||||
end
|
end
|
||||||
|
|
||||||
convert_test_nb("chunk_options_nb.mdw")
|
function contents(chunk::Weave.CodeChunk)
|
||||||
|
return chunk.content
|
||||||
|
end
|
||||||
|
|
||||||
|
function contents(doc::Weave.WeaveDoc)
|
||||||
|
return join([contents(chunk) for chunk in doc.chunks], "")
|
||||||
|
end
|
||||||
|
|
||||||
|
outfile = "documents/convert/chunk_options.ipynb"
|
||||||
|
infile = "documents/chunk_options.noweb"
|
||||||
|
convert_doc(infile, outfile)
|
||||||
|
input = contents(Weave.read_doc(infile))
|
||||||
|
output = contents(Weave.read_doc(outfile))
|
||||||
|
rm(outfile)
|
||||||
|
|
||||||
|
@test input == output
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue