-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Append user exeflags to env exeflags (#209)
* Merge user specified exeflags into env specified flags * formatting * need default exeflags after all
- Loading branch information
1 parent
cbb3269
commit 6c90394
Showing
3 changed files
with
69 additions
and
3 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
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,14 @@ | ||
--- | ||
title: Exeflags merging | ||
engine: julia | ||
julia: | ||
exeflags: [] | ||
--- | ||
|
||
```{julia} | ||
print(Base.active_project()) | ||
``` | ||
|
||
```{julia} | ||
print(Threads.nthreads()) | ||
``` |
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,46 @@ | ||
include("../utilities/prelude.jl") | ||
|
||
@testset "exeflags merging" begin | ||
|
||
function with_replacement_file(f, file, replacements...) | ||
s = read(file, String) | ||
mktempdir() do dir | ||
tempfile = joinpath(dir, basename(file)) | ||
open(tempfile, "w") do io | ||
write(io, replace(s, replacements...)) | ||
end | ||
f(tempfile) | ||
end | ||
end | ||
|
||
file = joinpath(@__DIR__, "../examples/exeflags_merging.qmd") | ||
|
||
withenv( | ||
"QUARTONOTEBOOKRUNNER_EXEFLAGS" => "[\"--project=/set_via_env\", \"--threads=3\"]", | ||
) do | ||
server = QuartoNotebookRunner.Server() | ||
json = QuartoNotebookRunner.run!(server, file; showprogress = false) | ||
@test contains(json.cells[2].outputs[1].text, "set_via_env") | ||
@test json.cells[4].outputs[1].text == "3" | ||
close!(server) | ||
|
||
with_replacement_file( | ||
file, | ||
"[]" => "[\"--project=/override_via_frontmatter\"]", | ||
) do newfile | ||
server = QuartoNotebookRunner.Server() | ||
json = QuartoNotebookRunner.run!(server, newfile; showprogress = false) | ||
@test contains(json.cells[2].outputs[1].text, "override_via_frontmatter") | ||
@test json.cells[4].outputs[1].text == "3" | ||
close!(server) | ||
end | ||
|
||
with_replacement_file(file, "[]" => "[\"--threads=5\"]") do newfile | ||
server = QuartoNotebookRunner.Server() | ||
json = QuartoNotebookRunner.run!(server, newfile; showprogress = false) | ||
@test contains(json.cells[2].outputs[1].text, "set_via_env") | ||
@test json.cells[4].outputs[1].text == "5" | ||
close!(server) | ||
end | ||
end | ||
end |