Removed unused code, tweaked test

pull/29/head
Matti Pastell 2015-01-08 19:35:47 +02:00
parent 78f04cafbd
commit c5d91dd6c7
5 changed files with 16 additions and 32 deletions

View File

@ -15,13 +15,13 @@ type Report <: Display
figures::Array{String}
term_state::Symbol
cur_chunk
function Report(cwd, basename, formatdict)
new(cwd, basename, formatdict, "", "", 1, String[], :text, nothing)
end
end
function Report(cwd, basename, formatdict)
Report(cwd, basename, formatdict, "", "", 1, String[], :text, nothing)
end
#const report = Report()
const supported_mime_types =

View File

@ -1,6 +1,5 @@
import JSON
function write_cache(doc::WeaveDoc, cache_path)
cache_dir = "$(doc.cwd)/$cache_path"
isdir(cache_dir) || mkpath(cache_dir)
@ -33,6 +32,7 @@ function restore_chunk(chunk::CodeChunk, cached, idx)
return chunk
end
function restore_chunk(chunk::DocChunk, cached, idx)
chunk
end
#Could be used to restore inline code in future
#function restore_chunk(chunk::DocChunk, cached, idx)
# chunk
#end

View File

@ -12,13 +12,6 @@ type WeaveDoc
basename = splitext(fname)[1]
new(source, basename, path, chunks, "", nothing, "")
end
function WeaveDoc(source, chunks, cwd, doctype)
path, fname = splitdir(abspath(source))
basename = splitext(fname)[1]
format = formats[doctype]
new(source, basename, path, chunks, cwd, format, doctype)
end
end

View File

@ -42,7 +42,7 @@ function Base.run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat=
report = Report(doc.cwd, doc.basename, doc.format.formatdict)
pushdisplay(report)
if cache != :off || cache != :refresh
if cache != :off || cache != :refresh
cached = read_cache(doc, cache_path)
cached == nothing && info("No cached results found, running code")
else
@ -186,12 +186,9 @@ function eval_chunk(chunk::CodeChunk, report::Report, SandBox::Module)
chunk
end
function eval_chunk(chunk::DocChunk, report::Report, SandBox)
chunk
end
#function eval_chunk(chunk::DocChunk, report::Report, SandBox)
# chunk
#end
#Set all variables to nothing
function clear_sandbox(SandBox::Module)

View File

@ -4,34 +4,28 @@ using Base.Test
#Test if running document with and without cache works
isdir("documents/cache") && rm("documents/cache", recursive = true)
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
ctime1 = ctime("documents/chunk_options.md")
result = readall(open("documents/chunk_options.md"))
rm("documents/chunk_options.md")
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
ctime2 = ctime("documents/chunk_options.md")
cached_result = readall(open("documents/chunk_options.md"))
@test result == cached_result
@test ctime1 != ctime2
# cache = :user
isdir("documents/cache") && rm("documents/cache", recursive = true)
out = "documents/chunk_cache.md"
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
result = readall(open(out))
ctime1 = ctime(out)
rm(out)
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
cached_result = readall(open(out))
ctime2 = ctime(out)
@test result == cached_result
@test ctime1 != ctime2
using Gadfly
isdir("documents/cache") && rm("documents/cache", recursive = true)
#Caching with Gadfly
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
result = readall(open("documents/gadfly_formats_test.tex"))
ctime1 = ctime("documents/gadfly_formats_test.tex")
rm("documents/gadfly_formats_test.tex")
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
ctime2 = ctime("documents/gadfly_formats_test.tex")
cached_result = readall(open("documents/gadfly_formats_test.tex"))
@test result == cached_result
@test ctime1 != ctime2