-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c65fd4
commit 718cd8d
Showing
6 changed files
with
128 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/testsets/non_standard_mimetypes/non_standard_mimetypes.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Test, QuartoNotebookRunner | ||
import JSON3, quarto_jll | ||
|
||
@testset "non-standard mime types" begin | ||
mktempdir() do dir | ||
server = QuartoNotebookRunner.Server() | ||
expected = Dict("typst" => "```{=typst}", "docx" => "```{=openxml}") | ||
|
||
env = joinpath(dir, "integrations", "CairoMakie") | ||
mkpath(env) | ||
cp(joinpath(@__DIR__, "../examples/integrations/CairoMakie"), env; force = true) | ||
|
||
for (format, ext) in ("typst" => "pdf", "docx" => "docx") | ||
cd(dir) do | ||
source = joinpath(@__DIR__, "../examples/$(format)_mimetypes.qmd") | ||
content = read(source, String) | ||
write("$(format)_mimetypes.qmd", content) | ||
ipynb = "$(format)_mimetypes.ipynb" | ||
QuartoNotebookRunner.run!( | ||
server, | ||
"$(format)_mimetypes.qmd"; | ||
output = ipynb, | ||
showprogress = false, | ||
options = Dict{String,Any}( | ||
"format" => Dict("pandoc" => Dict("to" => format)), | ||
), | ||
) | ||
|
||
json = JSON3.read(ipynb) | ||
markdown = json.cells[end].outputs[1].data["text/markdown"] | ||
@test contains(markdown, expected[format]) | ||
|
||
if !Sys.iswindows() | ||
# No macOS ARM build, so just look for a local version that the dev | ||
# should have installed. This avoids having to use rosetta2 to run | ||
# the x86_64 version of Julia to get access to the x86_64 version of | ||
# Quarto artifact. | ||
quarto_bin = | ||
quarto_jll.is_available() ? quarto_jll.quarto() : setenv(`quarto`) | ||
# Just a smoke test to make sure it runs. Use docx since it doesn't | ||
# output a bunch of folders (html), or require a tinytex install | ||
# (pdf). All we are doing here at the moment is ensuring quarto doesn't | ||
# break on our notebook outputs. | ||
if success(`$quarto_bin --version`) | ||
@test success(`$quarto_bin render $ipynb --to $format`) | ||
else | ||
@error "quarto not found, skipping smoke test." | ||
end | ||
@test isfile("$(format)_mimetypes.$ext") | ||
end | ||
end | ||
end | ||
close!(server) | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Test, QuartoNotebookRunner | ||
import JSON3, NodeJS_18_jll | ||
|
||
@testset "socket server" begin | ||
cd(@__DIR__) do | ||
node = NodeJS_18_jll.node() | ||
client = joinpath(@__DIR__, "client.js") | ||
port = 4001 | ||
server = QuartoNotebookRunner.serve(; port, showprogress = false) | ||
sleep(1) | ||
json(cmd) = JSON3.read(read(cmd, String), Any) | ||
|
||
cell_types = "../../examples/cell_types.qmd" | ||
|
||
d1 = json(`$node $client $port run $(cell_types)`) | ||
@test length(d1["notebook"]["cells"]) == 6 | ||
|
||
d2 = json(`$node $client $port run $(cell_types)`) | ||
@test d1 == d2 | ||
|
||
d3 = json(`$node $client $port close $(cell_types)`) | ||
@test d3["status"] == true | ||
|
||
d4 = json(`$node $client $port run $(cell_types)`) | ||
@test d1 == d4 | ||
|
||
d5 = json(`$node $client $port stop`) | ||
@test d5["message"] == "Server stopped." | ||
|
||
wait(server) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let removed = [] | ||
for (root, dirs, files) in walkdir(joinpath(@__DIR__, ".."); topdown = false) | ||
for file in files | ||
_, ext = splitext(file) | ||
if ext in (".html", ".pdf", ".tex", ".docx", ".typ", ".ipynb", ".png", ".css") | ||
path = joinpath(root, file) | ||
push!(removed, path) | ||
rm(path; force = true) | ||
end | ||
end | ||
for dir in dirs | ||
path = joinpath(root, dir) | ||
if isempty(readdir(path)) | ||
push!(removed, path) | ||
rm(path; force = true, recursive = true) | ||
end | ||
end | ||
end | ||
@info "removed files and directories" removed | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Update and precompile all project TOMLs when in CI. | ||
if get(ENV, "CI", "false") == "true" | ||
for dir in ["integrations", "mimetypes"] | ||
for (root, dirs, files) in walkdir(joinpath(@__DIR__, "..", "examples", dir)) | ||
for each in files | ||
if each == "Project.toml" | ||
manifest = joinpath(root, "Manifest.toml") | ||
if isfile(manifest) | ||
rm(manifest; force = true) | ||
end | ||
run( | ||
`$(Base.julia_cmd()) --project=$root -e 'push!(LOAD_PATH, "@stdlib"); import Pkg; Pkg.update()'`, | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |