From ec986b387b736849d29b94106699ab19fc4f6db7 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sat, 13 Jun 2020 20:42:57 +0900 Subject: [PATCH] `cd` into doc's working directory --- src/run.jl | 7 +++++-- test/test_meta.jl | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/run.jl b/src/run.jl index 487a6ed..d956e84 100644 --- a/src/run.jl +++ b/src/run.jl @@ -25,7 +25,7 @@ function run_doc( if isnothing(fig_path) fig_path = if (endswith(doctype, "2pdf") && cache === :off) || endswith(doctype, "2html") - basename(mktempdir(abspath(doc.cwd))) + basename(mktempdir(abspath(cwd))) else DEFAULT_FIG_PATH end @@ -43,7 +43,9 @@ function run_doc( mimetypes = doc.format.mimetypes - report = Report(doc.cwd, doc.basename, doc.format, mimetypes, throw_errors) + report = Report(cwd, doc.basename, doc.format, mimetypes, throw_errors) + cd_back = let d = pwd(); () -> cd(d); end + cd(cwd) pushdisplay(report) try if cache !== :off && cache !== :refresh @@ -86,6 +88,7 @@ function run_doc( rethrow(err) finally @info "Weaved all chunks" progress=1 _id=PROGRESS_ID + cd_back() popdisplay(report) # ensure display pops out even if internal error occurs end diff --git a/test/test_meta.jl b/test/test_meta.jl index 5df2c1a..cacb0b8 100644 --- a/test/test_meta.jl +++ b/test/test_meta.jl @@ -18,6 +18,10 @@ include("test_include.jl") ```julia @__LINE__ # broken ``` + +```julia +read("./test_include.jl", String) +``` """ doc_dir = joinpath(@__DIR__, "mocks") doc_path = joinpath(doc_dir, "test_meta.jmd") @@ -38,3 +42,4 @@ check_output(i, s) = occursin(s, mock.chunks[i].output) @test check_output(3, doc_dir) @test check_output(4, doc_path) @test_broken check_output(5, 18) +@test check_output(6, string('"', script_line, '"')) # current working directory