···107107 val init_function : string -> unit -> unit
108108 val get_stdlib_dcs : string -> Toplevel_api_gen.dynamic_cmis list
109109 val findlib_init : string -> findlib_t
110110+ val path : string
110111111112 val require :
112113 bool -> findlib_t -> string list -> Toplevel_api_gen.dynamic_cmis list
···355356 let init (init_libs : Toplevel_api_gen.init_config) =
356357 try
357358 Logs.info (fun m -> m "init()");
358358- path := Some "/static/cmis";
359359+ path := Some S.path;
359360360361 findlib_v := Some (S.findlib_init "findlib_index");
361362 let stdlib_dcs =
···895896 source;
896897 })
897898 in
898898- if List.length errors = 0 then add_cmi id deps src;
899899+ (if List.length errors = 0
900900+ then add_cmi id deps src
901901+ else failed_cells := StringSet.add id !failed_cells);
902902+899903 (* Logs.info (fun m -> m "Got to end"); *)
900904 IdlM.ErrM.return errors
901905 with e ->
+21-33
test/unix/unix_test.ml
···8585 with exn ->
8686 handle_findlib_error exn;
8787 []
8888+8989+ let path = "/tmp/cmis"
8890end
89919092module U = Impl.Make (S)
91939292-(* let test () =
9393- let _x = Compmisc.initial_env in
9494- let oc = open_out "/tmp/unix_worker.ml" in
9595- Printf.fprintf oc "let x=1;;\n";
9696- close_out oc;
9797- let unit_info = Unit_info.make ~source_file:"/tmp/unix_worker.ml" "/tmp/unix_worker" in
9898- try
9999- let _ast = Pparse.parse_implementation ~tool_name:"worker" "/tmp/unix_worker.ml" in
100100- let _ = Typemod.type_implementation unit_info (Compmisc.initial_env ()) _ast in
101101- ()
102102- with exn ->
103103- Printf.eprintf "error: %s\n%!" (Printexc.to_string exn);
104104- let ppf = Format.err_formatter in
105105- let _ = Location.report_exception ppf exn in
106106- () *)
107107-10894let start_server () =
9595+ (try Unix.mkdir S.path 0o777 with Unix.Unix_error (Unix.EEXIST, _, _) -> ());
10996 let open U in
11097 Logs.set_reporter (Logs_fmt.reporter ());
11198 Logs.set_level (Some Logs.Info);
···122109 IdlM.server Server.implementation
123110124111module Client = Js_top_worker_rpc.Toplevel_api_gen.Make (Impl.IdlM.GenClient ())
112112+113113+let c1, c2, c3, c4 = "c1", "c2", "c3", "c4"
114114+let notebook = [
115115+ (c1,[],"typ xxxx = int;;\n");
116116+ (c2,[c1],"type yyy=xxx;;\n");
117117+ (c3,[c1;c2],"type xxx = int;;\n");
118118+ (c4,[c1;c2;c3],"type yyy = xxx;;\n");
119119+]
125120126121let _ =
127122 let rpc = start_server () in
···132127 { stdlib_dcs = None; findlib_requires = []; execute = true }
133128 in
134129 let x =
130130+ let rec run notebook =
131131+ match notebook with
132132+ | (id, deps, cell) :: cells ->
133133+ let* errs = Client.query_errors rpc (Some id) deps false cell in
134134+ Printf.printf "Cell %s: %d errors\n%!" id (List.length errs);
135135+ run cells
136136+ | [] -> IdlM.ErrM.return ()
137137+ in
135138 let* _ = Client.init rpc init in
136136- let* o = Client.setup rpc () in
137137- Printf.printf "setup output: %s\n%!" (Option.value ~default:"" o.stdout);
138138- let* _ =
139139- Client.query_errors rpc (Some "c1") [] false "typ xxxx = int;;\n"
140140- in
141141- let* o1 =
142142- Client.query_errors rpc (Some "c2") [ "c1" ] false "type yyy = xxx;;\n"
143143- in
144144- Printf.printf "Number of errors: %d\n%!" (List.length o1);
145145- let* _ =
146146- Client.query_errors rpc (Some "c1") [] false "type xxx = int;;\n"
147147- in
148148- let* o2 =
149149- Client.query_errors rpc (Some "c2") [ "c1" ] false "type yyy = xxx;;\n"
150150- in
151151- Printf.printf "Number of errors1: %d\n%!" (List.length o1);
152152- Printf.printf "Number of errors2: %d\n%!" (List.length o2);
139139+ let* _ = Client.setup rpc () in
140140+ let* _ = run notebook in
153141 IdlM.ErrM.return ()
154142 in
155143 match x |> IdlM.T.get |> M.run with