aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-10-07 23:28:50 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-10-07 23:28:50 -0300
commit3c1f6ba5d89a9928ffbe1d94396d628ffa89f953 (patch)
tree4f59603fe83344bbfece5c4de0805811a76001ea /lib
parent483089803a411920fea7696ea6b40c664cf3003a (diff)
downloadRNT-3c1f6ba5d89a9928ffbe1d94396d628ffa89f953.tar.gz
RNT-3c1f6ba5d89a9928ffbe1d94396d628ffa89f953.zip
scratch root for testing with subsystems explorer
Diffstat (limited to 'lib')
-rw-r--r--lib/Scratch.ml23
-rw-r--r--lib/Scratch.mli7
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/Scratch.ml b/lib/Scratch.ml
new file mode 100644
index 0000000..0779db3
--- /dev/null
+++ b/lib/Scratch.ml
@@ -0,0 +1,23 @@
+module LMDB = Backend.Storage.LMDB
+module I = Kernel.Initialization.Make (LMDB)
+
+let rec remove path =
+ if Sys.is_directory path then begin
+ Array.iter (fun name -> remove (Filename.concat path name)) (Sys.readdir path);
+ Sys.rmdir path
+ end
+ else Sys.remove path
+
+let root ?(evaluators = ["fol", Evaluators.FOL.make ()]) () =
+ let open Utilities.Result in
+ let directory = Filename.temp_dir "rnt-scratch" "" in
+ let* connection =
+ Sexplib.Sexp.(
+ List [Atom "lmdb"; List [Atom "path"; Atom directory]; List [Atom "mode"; Atom "420"]] )
+ |> Concepts.Configuration.term_of_sexp
+ |> LMDB.connect
+ in
+ at_exit (fun () ->
+ LMDB.disconnect connection;
+ try remove directory with Sys_error _ -> () );
+ I.initialize ~evaluators connection
diff --git a/lib/Scratch.mli b/lib/Scratch.mli
new file mode 100644
index 0000000..804c2c2
--- /dev/null
+++ b/lib/Scratch.mli
@@ -0,0 +1,7 @@
+(** a root over a database of its own in a temporary directory, removed
+ when the program exits: for tests, and for trying things out. Its
+ system evaluators are [evaluators], FOL unless told otherwise. *)
+val root :
+ ?evaluators:(string * Protocols.Handle.t) list ->
+ unit ->
+ (Protocols.Handle.t, Concepts.Condition.condition) result