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