Fix notebook test

pull/114/head
Matti Pastell 2018-01-03 09:13:58 +02:00
parent c1795e7310
commit 361f404f95
1 changed files with 22 additions and 12 deletions

View File

@ -1,9 +1,8 @@
using Weave
using Base.Test
function convert_test(outfile)
function convert_test(outfile, infile="documents/chunk_options.noweb")
outfile = joinpath("documents/convert", outfile)
infile = "documents/chunk_options.noweb"
convert_doc(infile, outfile)
result = readstring(outfile)
ref = readstring(outfile * ".ref")
@ -14,16 +13,27 @@ end
convert_test("chunk_options.jmd")
convert_test("chunk_options.jl")
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)
outfile = joinpath("documents/convert", outfile)
infile = "documents/chunk_options.ipynb"
convert_doc(infile, outfile)
result = readstring(outfile)
ref = readstring(outfile * ".ref")
rm(outfile)
@test result == ref
# Separate test for notebook (output depends on julia version)
function contents(chunk::Weave.DocChunk)
return join([strip(c.content) for c in chunk.content], "")
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