Pure OCaml Yaml 1.2 reader and writer using Bytesrw
at main 1.3 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Load yaml-test-suite test cases using standard OCaml I/O *) 7 8(** Synchronous file I/O implementation *) 9module Sync_io : Test_suite_loader_generic.FILE_IO with type ctx = unit = struct 10 type ctx = unit 11 12 let read_file () path = 13 try 14 let ic = open_in path in 15 let n = in_channel_length ic in 16 let s = really_input_string ic n in 17 close_in ic; 18 Some s 19 with _ -> None 20 21 let file_exists () path = Sys.file_exists path 22 let is_directory () path = Sys.file_exists path && Sys.is_directory path 23 let read_dir () path = Array.to_list (Sys.readdir path) 24end 25 26module Loader = Test_suite_loader_generic.Make (Sync_io) 27(** Internal loader module *) 28 29type test_case = Loader.test_case = { 30 id : string; 31 name : string; 32 yaml : string; 33 tree : string option; 34 json : string option; 35 fail : bool; 36} 37(** Re-export test_case type from loader *) 38 39(** Load tests without needing to pass a context *) 40let load_directory path : test_case list = Loader.load_directory () path