Skip to content

Commit

Permalink
Fix #159, make parameters const (#164)
Browse files Browse the repository at this point in the history
* Fix #159, make parameters `const`

* Resolve breakage on newer `quarto` versions
  • Loading branch information
MichaelHatherly authored Jul 19, 2024
1 parent db6c566 commit c9550af
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ function evaluate_params!(f, params::Dict{String})
end

exprs = map(collect(pairs(params))) do (key, value)
:(@eval getfield(Main, :Notebook) $(Symbol(key::String)) = $value)
:(@eval getfield(Main, :Notebook) const $(Symbol(key::String)) = $value)
end
expr = Expr(:block, exprs...)
Malt.remote_eval_fetch(f.worker, expr)
Expand Down
3 changes: 3 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ NodeJS_18_jll = "c1e1d063-8311-5f52-a749-c7b05e91ae37"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
quarto_jll = "b7163347-bfae-5fd9-aba4-19f139889d78"

[compat]
quarto_jll = "= 1.4.549"
3 changes: 3 additions & 0 deletions test/examples/parameters.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ g["a"]
g["b"]
```

```{julia}
a = nothing
```
2 changes: 1 addition & 1 deletion test/testsets/non_standard_mimetypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include("../utilities/prelude.jl")
# (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`)
@test success(`$quarto_bin render $ipynb --no-execute --to $format`)
else
@error "quarto not found, skipping smoke test."
end
Expand Down
5 changes: 5 additions & 0 deletions test/testsets/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ test_example(joinpath(@__DIR__, "../examples/parameters.qmd")) do json
@test cells[12]["outputs"][1]["text"] == "[1, 2, 3]"
@test cells[14]["outputs"][1]["data"]["text/plain"] == "1"
@test cells[16]["outputs"][1]["data"]["text/plain"] == "2"
@test cells[18]["outputs"][1]["output_type"] == "error"
@test contains(
cells[18]["outputs"][1]["traceback"][1],
"invalid redefinition of constant",
)
end

@testset "parameters via options" begin
Expand Down
2 changes: 1 addition & 1 deletion test/utilities/prelude.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if !@isdefined(SCHEMA)
# (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 docx`)
@test success(`$quarto_bin render $ipynb --no-execute --to docx`)
else
@error "quarto not found, skipping smoke test."
end
Expand Down

0 comments on commit c9550af

Please sign in to comment.