diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-07-31 12:12:29 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-07-31 12:12:29 +0100 |
commit | 686f28dd7eb98c17aa98c981adf64c53af99e125 (patch) | |
tree | ffa38decd291ff16a2cdbc99b2e0bef69db73973 /src | |
parent | 77b2275dfcebce16ceea17ddf77a7f9d0a41c082 (diff) | |
download | libguestfs-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-x | src/generator.ml | 31 |
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"; |