Skip to content

Commit a712663

Browse files
committed
add second logfile test and factor out stderr/stdout asserts
1 parent d6edb64 commit a712663

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert, assertStringIncludes } from "testing/asserts";
22
import { docs, quartoDevCmd } from "../../../../utils.ts";
33
import { existsSync } from "fs/exists";
4-
import { juliaTransportFile } from "../../../../../src/execute/julia.ts";
4+
import { juliaServerLogFile, juliaTransportFile } from "../../../../../src/execute/julia.ts";
55

66
const sleepQmd = docs("call/engine/julia/sleep.qmd");
77
assert(existsSync(sleepQmd));
@@ -15,6 +15,13 @@ function assertSuccess(output: Deno.CommandOutput) {
1515
}
1616
}
1717

18+
function assertStdoutIncludes(output: Deno.CommandOutput, str: string) {
19+
assertStringIncludes(new TextDecoder().decode(output.stdout), str);
20+
}
21+
function assertStderrIncludes(output: Deno.CommandOutput, str: string) {
22+
assertStringIncludes(new TextDecoder().decode(output.stderr), str);
23+
}
24+
1825
// make sure we don't have a server process running by sending a kill command
1926
// and then also try to remove the transport file in case one still exists
2027
const killcmd = new Deno.Command(
@@ -33,8 +40,7 @@ Deno.test("kill without server running", () => {
3340
{args: ["call", "engine", "julia", "kill"]}
3441
).outputSync();
3542
assertSuccess(output);
36-
const stderr = new TextDecoder().decode(output.stderr);
37-
assertStringIncludes(stderr, "Julia control server is not running.");
43+
assertStderrIncludes(output, "Julia control server is not running.");
3844
});
3945

4046
Deno.test("status without server running", () => {
@@ -43,8 +49,21 @@ Deno.test("status without server running", () => {
4349
{args: ["call", "engine", "julia", "status"]}
4450
).outputSync();
4551
assertSuccess(output);
46-
const stderr = new TextDecoder().decode(output.stderr);
47-
assertStringIncludes(stderr, "Julia control server is not running.");
52+
assertStderrIncludes(output, "Julia control server is not running.");
53+
});
54+
55+
try {
56+
await Deno.remove(juliaServerLogFile());
57+
} catch {
58+
}
59+
60+
Deno.test("log file doesn't exist", () => {
61+
const log_output = new Deno.Command(
62+
quartoDevCmd(),
63+
{args: ["call", "engine", "julia", "log"]}
64+
).outputSync();
65+
assertSuccess(log_output);
66+
assertStderrIncludes(log_output, "Server log file doesn't exist");
4867
});
4968

5069
Deno.test("status with server and worker running", () => {
@@ -59,10 +78,7 @@ Deno.test("status with server and worker running", () => {
5978
{args: ["call", "engine", "julia", "status"]}
6079
).outputSync();
6180
assertSuccess(status_output);
62-
const stdout = new TextDecoder().decode(status_output.stdout);
63-
assert(status_output.success);
64-
65-
assertStringIncludes(stdout, "workers active: 1");
81+
assertStdoutIncludes(status_output, "workers active: 1");
6682
});
6783

6884
Deno.test("log exists", () => {
@@ -71,6 +87,5 @@ Deno.test("log exists", () => {
7187
{args: ["call", "engine", "julia", "log"]}
7288
).outputSync();
7389
assertSuccess(log_output);
74-
const stdout_log = new TextDecoder().decode(log_output.stdout);
75-
assertStringIncludes(stdout_log, "Log started at");
90+
assertStdoutIncludes(log_output, "Log started at");
7691
});

0 commit comments

Comments
 (0)