From 361f404f95f9d6e6607bd8d8b69658676087b2f9 Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Wed, 3 Jan 2018 09:13:58 +0200 Subject: [PATCH] Fix notebook test --- test/convert_test.jl | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/test/convert_test.jl b/test/convert_test.jl index 317be01..0a86600 100644 --- a/test/convert_test.jl +++ b/test/convert_test.jl @@ -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") \ No newline at end of file +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 +