Skip to content

Commit 84d8de0

Browse files
committed
add first basic call julia engine tests
1 parent 361ed02 commit 84d8de0

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

.github/workflows/test-smokes.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ jobs:
174174
with:
175175
version: "1.11.3"
176176

177+
- name: Checkout dev branch of QuartoNotebookRunner
178+
uses: actions/checkout@v4
179+
with:
180+
repository: PumasAI/QuartoNotebookRunner.jl
181+
ref: jk/workers-status
182+
183+
- name: Set QUARTO_JULIA_PROJECT environment variable
184+
run: echo "QUARTO_JULIA_PROJECT=$GITHUB_WORKSPACE/QuartoNotebookRunner.jl" >> $GITHUB_ENV
185+
186+
- name: Instantiate QuartoNotebookRunner
187+
run: julia --project=./QuartoNotebookRunner.jl -e 'using Pkg; Pkg.instantiate()'
188+
177189
- name: Cache Julia Packages
178190
uses: julia-actions/cache@v2
179191

src/execute/julia.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ function juliaRuntimeDir(): string {
798798
}
799799
}
800800

801-
function juliaTransportFile() {
801+
export function juliaTransportFile() {
802802
return join(juliaRuntimeDir(), "julia_transport.txt");
803803
}
804804

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
engine: julia
3+
params:
4+
sleep_duration: 0
5+
---
6+
7+
```{julia}
8+
sleep(sleep_duration)
9+
```
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { assert, assertStringIncludes } from "testing/asserts";
2+
import { docs, quartoDevCmd } from "../../../../utils.ts";
3+
import { existsSync } from "fs/exists";
4+
import { juliaTransportFile } from "../../../../../src/execute/julia.ts";
5+
6+
const sleepQmd = docs("call/engine/julia/sleep.qmd");
7+
assert(existsSync(sleepQmd));
8+
9+
// make sure we don't have a server process running by sending a kill command
10+
// and then also try to remove the transport file in case one still exists
11+
const killcmd = new Deno.Command(
12+
quartoDevCmd(),
13+
{args: ["call", "engine", "julia", "kill"]}
14+
).outputSync();
15+
assert(killcmd.success);
16+
try {
17+
await Deno.remove(juliaTransportFile());
18+
} catch {
19+
}
20+
21+
Deno.test("kill without server running", () => {
22+
const output = new Deno.Command(
23+
quartoDevCmd(),
24+
{args: ["call", "engine", "julia", "kill"]}
25+
).outputSync();
26+
assert(output.success);
27+
const stderr = new TextDecoder().decode(output.stderr);
28+
assertStringIncludes(stderr, "Julia control server is not running.");
29+
});
30+
31+
Deno.test("status without server running", () => {
32+
const output = new Deno.Command(
33+
quartoDevCmd(),
34+
{args: ["call", "engine", "julia", "status"]}
35+
).outputSync();
36+
assert(output.success);
37+
const stderr = new TextDecoder().decode(output.stderr);
38+
assertStringIncludes(stderr, "Julia control server is not running.");
39+
});
40+
41+
Deno.test("status with server and worker running", () => {
42+
const render_output = new Deno.Command(
43+
quartoDevCmd(),
44+
{args: ["render", sleepQmd, "-P", "sleep_duration:0", "--execute-daemon", "60"]}
45+
).outputSync();
46+
assert(render_output.success);
47+
48+
const status_output = new Deno.Command(
49+
quartoDevCmd(),
50+
{args: ["call", "engine", "julia", "status"]}
51+
).outputSync();
52+
assert(status_output.success);
53+
const stdout = new TextDecoder().decode(status_output.stdout);
54+
assertStringIncludes(stdout, "workers active: 1");
55+
});
56+
57+
Deno.test("log exists", () => {
58+
const log_output = new Deno.Command(
59+
quartoDevCmd(),
60+
{args: ["call", "engine", "julia", "log"]}
61+
).outputSync();
62+
assert(log_output.success);
63+
const stdout_log = new TextDecoder().decode(log_output.stdout);
64+
assertStringIncludes(stdout_log, "Log started at");
65+
});

0 commit comments

Comments
 (0)