Skip to content

Commit

Permalink
Convert relpaths to abspaths prior to dir check, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Jan 11, 2024
1 parent 958b76d commit da5e1dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ function evaluate!(
end

function _check_output_dst(s::AbstractString)
s = abspath(s)
dir = dirname(s)
if !isdir(dir)
_dir = dirname(joinpath(pwd(), s))
isdir(_dir) || throw(ArgumentError("directory does not exist: $(dir)"))
end
isdir(dir) || throw(ArgumentError("directory does not exist: $(dir)"))
return nothing
end
_check_output_dst(::Any) = nothing
Expand Down
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -811,4 +811,24 @@ end
)
end
end

@testset "relative paths in `output`" begin
content = read(joinpath(@__DIR__, "examples/stdout.qmd"), String)
mktempdir() do dir
cd(dir) do
server = QuartoNotebookRunner.Server()
write("notebook.qmd", content)
ipynb = "notebook.ipynb"
QuartoNotebookRunner.run!(server, "notebook.qmd"; output = ipynb)

json = JSON3.read(ipynb)

cells = json.cells
cell = cells[8]
@test contains(cell.outputs[1].text, "\e[1mInfo: \e[22m\e[39minfo text")

close!(server)
end
end
end
end

0 comments on commit da5e1dc

Please sign in to comment.