Skip to content

Commit d109025

Browse files
committed
add test for force-closing a worker
1 parent 49c3653 commit d109025

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

tests/smoke/call/engine/julia/julia.test.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Deno.test("status with server and worker running", () => {
8282
assertStdoutIncludes(status_output, "workers active: 1");
8383
});
8484

85-
Deno.test("closing a running worker", () => {
85+
Deno.test("closing an idling worker", () => {
8686
const close_output = new Deno.Command(
8787
quartoDevCmd(),
8888
{args: ["call", "engine", "julia", "close", sleepQmd]}
@@ -98,6 +98,46 @@ Deno.test("closing a running worker", () => {
9898
assertStdoutIncludes(status_output, "workers active: 0");
9999
});
100100

101+
Deno.test("force-closing a running worker", async () => {
102+
// spawn a long-running command
103+
const render_cmd = new Deno.Command(
104+
quartoDevCmd(),
105+
{args: ["render", sleepQmd, "-P", "sleep_duration:30"]}
106+
).output();
107+
108+
await sleep(3000);
109+
110+
const close_output = new Deno.Command(
111+
quartoDevCmd(),
112+
{args: ["call", "engine", "julia", "close", sleepQmd]}
113+
).outputSync();
114+
assertStderrIncludes(close_output, "worker is busy");
115+
116+
const status_output = new Deno.Command(
117+
quartoDevCmd(),
118+
{args: ["call", "engine", "julia", "status"]}
119+
).outputSync();
120+
assertSuccess(status_output);
121+
assertStdoutIncludes(status_output, "workers active: 1");
122+
123+
const force_close_output = new Deno.Command(
124+
quartoDevCmd(),
125+
{args: ["call", "engine", "julia", "close", "--force", sleepQmd]}
126+
).outputSync();
127+
assertSuccess(force_close_output);
128+
assertStderrIncludes(force_close_output, "Worker force-closed successfully");
129+
130+
const status_output_2 = new Deno.Command(
131+
quartoDevCmd(),
132+
{args: ["call", "engine", "julia", "status"]}
133+
).outputSync();
134+
assertSuccess(status_output_2);
135+
assertStdoutIncludes(status_output_2, "workers active: 0");
136+
137+
const render_output = await render_cmd;
138+
assertStderrIncludes(render_output, "File was force-closed during run")
139+
});
140+
101141
Deno.test("log exists", () => {
102142
const log_output = new Deno.Command(
103143
quartoDevCmd(),

0 commit comments

Comments
 (0)