From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Wed, 7 May 2008 07:42:41 +0000 (+0100) Subject: Fix test program to work with /etc/hosts and display all files recursively. X-Git-Tag: v0.6~53 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=9c83ccd0bc4c7ad0a699096089d4fe6c13d560a3;p=ocaml-augeas.git Fix test program to work with /etc/hosts and display all files recursively. --- diff --git a/Makefile.in b/Makefile.in index 178269e..97f7e15 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,7 +55,8 @@ test_augeas: test_augeas.cmo test_root test_root: rm -rf $@ mkdir $@ - cp /etc/hosts $@/ + mkdir $@/etc + cp /etc/hosts $@/etc/ # Clean. diff --git a/test_augeas.ml b/test_augeas.ml index 0124b58..1be88b7 100644 --- a/test_augeas.ml +++ b/test_augeas.ml @@ -20,18 +20,17 @@ 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 print_endline path; + 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 ()