this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Tests

+190 -4
-4
test/cram/simple.t/run.t
··· 9 9 error while evaluating #disable "shortvar";;);stdout:S(OCaml version 5.2.0 10 10 Unknown directive enable. 11 11 Unknown directive disable.)} 12 - unix_worker: [WARNING] Parsing toplevel phrases 13 12 {mime_vals:[];parts:[];script:S(# Printf.printf "Hello, world\n";; 14 13 Hello, world 15 14 - : unit = ())} 16 - unix_worker: [WARNING] Parsing toplevel phrases 17 - unix_worker: [WARNING] Warning: Legacy toplevel output detected 18 15 unix_worker: [WARNING] Warning: Legacy toplevel output detected 19 16 {mime_vals:[];parts:[];script:S(# let x = 1 + 2;; 20 17 val x : int = 3 21 18 # let x = 2+3;; 22 19 val x : int = 5)} 23 - unix_worker: [WARNING] Parsing toplevel phrases 24 20 {mime_vals:[];parts:[];script:S(# let x = 1 + 2;; 25 21 val x : int = 3 26 22 # let x = 2+3;;
+8
test/unix/dune
··· 1 + (executable 2 + (name unix_test) 3 + (public_name unix_test) 4 + (modes byte) 5 + (package js_top_worker-unix) 6 + (modules unix_test) 7 + (link_flags (-linkall)) 8 + (libraries js_top_worker logs logs.fmt rpclib.core rpclib.json findlib.top))
+182
test/unix/unix_test.ml
··· 1 + (* Unix worker *) 2 + open Js_top_worker 3 + open Impl 4 + 5 + let capture f () = 6 + let stdout_backup = Unix.dup ~cloexec:true Unix.stdout in 7 + let stderr_backup = Unix.dup ~cloexec:true Unix.stderr in 8 + let filename_out = Filename.temp_file "ocaml-mdx-" ".stdout" in 9 + let filename_err = Filename.temp_file "ocaml-mdx-" ".stderr" in 10 + let fd_out = 11 + Unix.openfile filename_out 12 + Unix.[ O_WRONLY; O_CREAT; O_TRUNC; O_CLOEXEC ] 13 + 0o600 14 + in 15 + let fd_err = 16 + Unix.openfile filename_err 17 + Unix.[ O_WRONLY; O_CREAT; O_TRUNC; O_CLOEXEC ] 18 + 0o600 19 + in 20 + Unix.dup2 ~cloexec:false fd_out Unix.stdout; 21 + Unix.dup2 ~cloexec:false fd_err Unix.stderr; 22 + let ic_out = open_in filename_out in 23 + let ic_err = open_in filename_err in 24 + let capture oc ic fd buf = 25 + flush oc; 26 + let len = Unix.lseek fd 0 Unix.SEEK_CUR in 27 + Buffer.add_channel buf ic len 28 + in 29 + Fun.protect 30 + (fun () -> 31 + let x = f () in 32 + let buf_out = Buffer.create 1024 in 33 + let buf_err = Buffer.create 1024 in 34 + capture stdout ic_out fd_out buf_out; 35 + capture stderr ic_err fd_err buf_err; 36 + ( { 37 + Impl.stdout = Buffer.contents buf_out; 38 + stderr = Buffer.contents buf_err; 39 + }, 40 + x )) 41 + ~finally:(fun () -> 42 + close_in_noerr ic_out; 43 + close_in_noerr ic_out; 44 + Unix.close fd_out; 45 + Unix.close fd_err; 46 + Unix.dup2 ~cloexec:false stdout_backup Unix.stdout; 47 + Unix.dup2 ~cloexec:false stderr_backup Unix.stderr; 48 + Unix.close stdout_backup; 49 + Unix.close stderr_backup; 50 + Sys.remove filename_out; 51 + Sys.remove filename_err) 52 + 53 + let handle_findlib_error = function 54 + | Failure msg -> Printf.fprintf stderr "%s" msg 55 + | Fl_package_base.No_such_package (pkg, reason) -> 56 + Printf.fprintf stderr "No such package: %s%s\n" pkg 57 + (if reason <> "" then " - " ^ reason else "") 58 + | Fl_package_base.Package_loop pkg -> 59 + Printf.fprintf stderr "Package requires itself: %s\n" pkg 60 + | exn -> raise exn 61 + 62 + module Server = Js_top_worker_rpc.Toplevel_api_gen.Make (Impl.IdlM.GenServer ()) 63 + 64 + module S : Impl.S = struct 65 + type findlib_t = unit 66 + 67 + let capture = capture 68 + let sync_get _ = None 69 + let create_file ~name:_ ~content:_ = failwith "Not implemented" 70 + 71 + let import_scripts urls = 72 + if List.length urls > 0 then failwith "Not implemented" else () 73 + 74 + let init_function _ () = failwith "Not implemented" 75 + let findlib_init _ = () 76 + let get_stdlib_dcs _uri = [] 77 + 78 + let require () packages = 79 + try 80 + let eff_packages = 81 + Findlib.package_deep_ancestors !Topfind.predicates packages 82 + in 83 + Topfind.load eff_packages; 84 + [] 85 + with exn -> 86 + handle_findlib_error exn; 87 + [] 88 + end 89 + 90 + module U = Impl.Make (S) 91 + 92 + (* let test () = 93 + let _x = Compmisc.initial_env in 94 + let oc = open_out "/tmp/unix_worker.ml" in 95 + Printf.fprintf oc "let x=1;;\n"; 96 + close_out oc; 97 + let unit_info = Unit_info.make ~source_file:"/tmp/unix_worker.ml" "/tmp/unix_worker" in 98 + try 99 + let _ast = Pparse.parse_implementation ~tool_name:"worker" "/tmp/unix_worker.ml" in 100 + let _ = Typemod.type_implementation unit_info (Compmisc.initial_env ()) _ast in 101 + () 102 + with exn -> 103 + Printf.eprintf "error: %s\n%!" (Printexc.to_string exn); 104 + let ppf = Format.err_formatter in 105 + let _ = Location.report_exception ppf exn in 106 + () *) 107 + 108 + let start_server () = 109 + let open U in 110 + Logs.set_reporter (Logs_fmt.reporter ()); 111 + Logs.set_level (Some Logs.Info); 112 + (* let pid = Unix.getpid () in *) 113 + Server.exec execute; 114 + Server.setup setup; 115 + Server.init init; 116 + Server.typecheck typecheck_phrase; 117 + Server.complete_prefix complete_prefix; 118 + Server.query_errors query_errors; 119 + Server.type_enclosing type_enclosing; 120 + Server.compile_js compile_js; 121 + Server.exec_toplevel exec_toplevel; 122 + IdlM.server Server.implementation 123 + 124 + module Client = Js_top_worker_rpc.Toplevel_api_gen.Make (Impl.IdlM.GenClient ()) 125 + 126 + let _ = 127 + let rpc = start_server () in 128 + Printf.printf "Starting worker...\n%!"; 129 + let ( let* ) = IdlM.ErrM.bind in 130 + let dcs = 131 + Js_top_worker_rpc.Toplevel_api_gen. 132 + { 133 + dcs_url = "cmis/"; 134 + dcs_toplevel_modules = 135 + [ 136 + "CamlinternalOO"; 137 + "Stdlib"; 138 + "CamlinternalFormat"; 139 + "Std_exit"; 140 + "CamlinternalMod"; 141 + "CamlinternalFormatBasics"; 142 + "CamlinternalLazy"; 143 + ]; 144 + dcs_file_prefixes = [ "stdlib__" ]; 145 + } 146 + in 147 + let init = 148 + Js_top_worker_rpc.Toplevel_api_gen. 149 + { 150 + path = "/tmp/static/cmis"; 151 + cmas = []; 152 + cmis = { dynamic_cmis = [ dcs ]; static_cmis = [] }; 153 + stdlib_dcs = "/lib/ocaml/dynamic_cmis.json"; 154 + findlib_index = "/lib/findlib_index"; 155 + findlib_requires = []; 156 + } 157 + in 158 + let x = 159 + let* _ = Client.init rpc init in 160 + let* o = Client.setup rpc () in 161 + Printf.printf "setup output: %s\n%!" (Option.value ~default:"" o.stdout); 162 + let* _ = 163 + Client.query_errors rpc (Some "c1") [] false "typ xxxx = int;;\n" 164 + in 165 + let* o1 = 166 + Client.query_errors rpc (Some "c2") ["c1"] false "type yyy = xxx;;\n" 167 + in 168 + Printf.printf "Number of errors: %d\n%!" (List.length o1); 169 + let* _ = 170 + Client.query_errors rpc (Some "c1") [] false "type xxx = int;;\n" 171 + in 172 + let* o2 = 173 + Client.query_errors rpc (Some "c2") ["c1"] false 174 + "type yyy = xxx;;\n" 175 + in 176 + Printf.printf "Number of errors1: %d\n%!" (List.length o1); 177 + Printf.printf "Number of errors2: %d\n%!" (List.length o2); 178 + IdlM.ErrM.return () 179 + in 180 + match x |> IdlM.T.get |> M.run with 181 + | Ok () -> Printf.printf "Success\n%!" 182 + | Error (InternalError s) -> Printf.printf "Error: %s\n%!" s