caml_named_value returns const value pointer in OCaml 4.09+
[ocaml-augeas.git] / test_augeas.ml
index 0124b58..c47db9a 100644 (file)
 
 let () =
   let aug =
-    let loadpath = Some "/usr/share/augeas/lenses" in
+    let loadpath = None in
     let flags = [ Augeas.AugSaveBackup ] in
     Augeas.create "test_root" loadpath flags in
 
-  (* Print all files. *)
-  let files = Augeas.matches aug "/files/*" in
-  List.iter print_endline files;
-
-  (* Print all Augeas-metainfo. *)
-  let augs = Augeas.matches aug "/augeas/*" in
-  List.iter print_endline augs;
-
+  (* Print all files recursively. *)
+  let rec print path =
+    if path <> "" then (
+      let value = Augeas.get aug path in
+      match value with
+      | None -> print_endline path
+      | Some value -> Printf.printf "%s -> '%s'\n%!" path value
+    );
+    let files = List.sort compare (Augeas.matches aug (path ^ "/*")) in
+    List.iter print files
+  in
+  print "";
 
   (* Run the garbage collector to check for internal errors. *)
   Gc.compact ()