summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-31 12:12:29 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-31 12:12:29 +0100
commit686f28dd7eb98c17aa98c981adf64c53af99e125 (patch)
treeffa38decd291ff16a2cdbc99b2e0bef69db73973 /src
parent77b2275dfcebce16ceea17ddf77a7f9d0a41c082 (diff)
downloadlibguestfs-686f28dd7eb98c17aa98c981adf64c53af99e125.tar.gz
libguestfs-686f28dd7eb98c17aa98c981adf64c53af99e125.tar.xz
libguestfs-686f28dd7eb98c17aa98c981adf64c53af99e125.zip
Improve warnings about missing tests.
Don't warn where a command just has no tests. Instead check other commands' tests so we get a definitive (and much smaller) list of commands that are not tested anywhere.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/generator.ml31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/generator.ml b/src/generator.ml
index b0b3f066..74379269 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3581,6 +3581,13 @@ let files_equal n1 n2 =
| 1 -> false
| i -> failwithf "%s: failed with error code %d" cmd i
+let rec filter_map f = function
+ | [] -> []
+ | x :: xs ->
+ match f x with
+ | Some y -> y :: filter_map f xs
+ | None -> filter_map f xs
+
let rec find_map f = function
| [] -> raise Not_found
| x :: xs ->
@@ -4923,15 +4930,29 @@ static void print_table (char * const * const argv)
}
*/
-static void no_test_warnings (void)
-{
";
+ (* Generate a list of commands which are not tested anywhere. *)
+ pr "static void no_test_warnings (void)\n";
+ pr "{\n";
+
+ let hash : (string, bool) Hashtbl.t = Hashtbl.create 13 in
List.iter (
- function
- | name, _, _, _, [], _, _ ->
+ fun (_, _, _, _, tests, _, _) ->
+ let tests = filter_map (
+ function
+ | (_, (Always|If _|Unless _), test) -> Some test
+ | (_, Disabled, _) -> None
+ ) tests in
+ let seq = List.concat (List.map seq_of_test tests) in
+ let cmds_tested = List.map List.hd seq in
+ List.iter (fun cmd -> Hashtbl.replace hash cmd true) cmds_tested
+ ) all_functions;
+
+ List.iter (
+ fun (name, _, _, _, _, _, _) ->
+ if not (Hashtbl.mem hash name) then
pr " fprintf (stderr, \"warning: \\\"guestfs_%s\\\" has no tests\\n\");\n" name
- | name, _, _, _, tests, _, _ -> ()
) all_functions;
pr "}\n";