aboutsummaryrefslogtreecommitdiff
path: root/tests/confLoader.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-03-13 20:17:51 +0100
committerSébastien Dailly <sebastien@dailly.me>2025-04-08 18:39:49 +0200
commit9e2dbe43abe97c4e60b158e5fa52172468a2afb8 (patch)
treef58276e500d8ab0b84cdf74cc36fc73d4bca3892 /tests/confLoader.ml
parent0bdc640331b903532fb345930e7078752ba54a2d (diff)
Declare the files to load from an external configuration file
Diffstat (limited to 'tests/confLoader.ml')
-rw-r--r--tests/confLoader.ml22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/confLoader.ml b/tests/confLoader.ml
index 13f9840..e6187c3 100644
--- a/tests/confLoader.ml
+++ b/tests/confLoader.ml
@@ -1,5 +1,23 @@
-let load' : string -> (ImporterSyntax.t, string) Result.t =
- fun content -> Otoml.Parser.from_string content |> ImportConf.t_of_toml
+(** During the test, we don’t care with the file existence *)
+let context =
+ ImportConf.
+ { loadFile = (fun _ -> Otoml.array []); checkFile = (fun _ -> true) }
+
+let load' :
+ ?dataset:(string -> Otoml.t) ->
+ string ->
+ (ImporterSyntax.t, string) Result.t =
+ fun ?(dataset = fun _ -> Otoml.array []) content ->
+ let toml = Otoml.Parser.from_string content in
+ ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset }
+
+let load_from_file :
+ ?dataset:(string -> Otoml.t) ->
+ string ->
+ (ImporterSyntax.t, string) Result.t =
+ fun ?(dataset = fun _ -> Otoml.array []) content ->
+ let toml = Otoml.Parser.from_file content in
+ ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset }
(** Read the configuration in toml and return the internal representation *)
let load : string -> ImporterSyntax.t =