# HG changeset patch # User Jonathan Knowles # Date 1284454324 -3600 # Node ID 6dc5d5527c945619673374a3e8d3321a1e3feba6 # Parent 2c66f33e8c29f8e112e2b09c0092e22ecb40e95f Rescues the indendation for several functions within the quicktest module. Splits an often-modified list of tests into multiple lines, reducing the chance that further patches will conflict with one another. Signed-off-by: Jonathan Knowles diff -r 2c66f33e8c29 -r 6dc5d5527c94 ocaml/xapi/quicktest.ml --- a/ocaml/xapi/quicktest.ml Tue Sep 14 09:47:40 2010 +0100 +++ b/ocaml/xapi/quicktest.ml Tue Sep 14 09:52:04 2010 +0100 @@ -651,49 +651,62 @@ else failed test "one or more scenarios failed" let _ = - let all_tests = [ "storage"; "vm-placement"; "vm-memory-constraints"; "encodings"; "http"; "event"; "vdi"; "async"; "import"; "powercycle"; "squeezing"; "lifecycle"; "vhd" ] in - let default_tests = List.filter (fun x -> not(List.mem x [ "lifecycle"; "vhd" ])) all_tests in + let all_tests = [ + "storage"; + "vm-placement"; + "vm-memory-constraints"; + "encodings"; + "http"; + "event"; + "vdi"; + "async"; + "import"; + "powercycle"; + "squeezing"; + "lifecycle"; + "vhd"; + ] in + let default_tests = List.filter (fun x -> not(List.mem x [ "lifecycle"; "vhd" ])) all_tests in - let tests_to_run = ref default_tests in (* default is everything *) - Arg.parse - [ "-single", Arg.String (fun x -> tests_to_run := [ x ]), Printf.sprintf "Only run one test (possibilities are %s)" (String.concat ", " all_tests) ; - "-all", Arg.Unit (fun () -> tests_to_run := all_tests), Printf.sprintf "Run all tests (%s)" (String.concat ", " all_tests); - "-nocolour", Arg.Clear Quicktest_common.use_colour, "Don't use colour in the output" ] - (fun x -> match !host, !username, !password with - | "", _, _ -> host := x; rpc := rpc_remote; using_unix_domain_socket := false; - | _, "", _ -> username := x - | _, _, "" -> password := x - | _, _, _ -> Printf.fprintf stderr "Skipping unrecognised argument: %s" x) - "Perform some quick functional tests. The default is to test localhost over a Unix socket. For remote server supply and arguments."; - if !host = "" then host := "localhost"; - if !username = "" then username := "root"; - - let maybe_run_test name f = - assert (List.mem name all_tests); - if List.mem name !tests_to_run then f () in + let tests_to_run = ref default_tests in (* default is everything *) + Arg.parse [ + "-single", Arg.String (fun x -> tests_to_run := [ x ]), Printf.sprintf "Only run one test (possibilities are %s)" (String.concat ", " all_tests) ; + "-all", Arg.Unit (fun () -> tests_to_run := all_tests), Printf.sprintf "Run all tests (%s)" (String.concat ", " all_tests); + "-nocolour", Arg.Clear Quicktest_common.use_colour, "Don't use colour in the output" ] + (fun x -> match !host, !username, !password with + | "", _, _ -> host := x; rpc := rpc_remote; using_unix_domain_socket := false; + | _, "", _ -> username := x + | _, _, "" -> password := x + | _, _, _ -> Printf.fprintf stderr "Skipping unrecognised argument: %s" x) + "Perform some quick functional tests. The default is to test localhost over a Unix socket. For remote server supply and arguments."; + if !host = "" then host := "localhost"; + if !username = "" then username := "root"; + + let maybe_run_test name f = + assert (List.mem name all_tests); + if List.mem name !tests_to_run then f () in - Stunnel.init_stunnel_path (); - let s = init_session !username !password in - finally - (fun () -> - (try - maybe_run_test "encodings" Quicktest_encodings.run_from_within_quicktest; - maybe_run_test "squeezing" squeeze_test; - maybe_run_test "vm-memory-constraints" Quicktest_vm_memory_constraints.run_from_within_quicktest; - maybe_run_test "vm-placement" Quicktest_vm_placement.run_from_within_quicktest; - maybe_run_test "storage" (fun () -> Quicktest_storage.go s); - maybe_run_test "http" Quicktest_http.run_from_within_quicktest; - maybe_run_test "event" event_next_unblocking_test; - maybe_run_test "vdi" (fun () -> vdi_test s); - maybe_run_test "async" (fun () -> async_test s); - maybe_run_test "import" (fun () -> import_export_test s); - maybe_run_test "vhd" (fun () -> with_vm s test_vhd_locking_hook); - maybe_run_test "powercycle" (fun () -> with_vm s vm_powercycle_test); - maybe_run_test "lifecycle" (fun () -> with_vm s Quicktest_lifecycle.test); - - with - | Api_errors.Server_error (a,b) -> - output_string stderr (Printf.sprintf "%s: %s" a (String.concat "," b)); - | e -> - output_string stderr (Printexc.to_string e)) - ) (fun () -> summarise ()) + Stunnel.init_stunnel_path (); + let s = init_session !username !password in + finally + (fun () -> + (try + maybe_run_test "encodings" Quicktest_encodings.run_from_within_quicktest; + maybe_run_test "squeezing" squeeze_test; + maybe_run_test "vm-memory-constraints" Quicktest_vm_memory_constraints.run_from_within_quicktest; + maybe_run_test "vm-placement" Quicktest_vm_placement.run_from_within_quicktest; + maybe_run_test "storage" (fun () -> Quicktest_storage.go s); + maybe_run_test "http" Quicktest_http.run_from_within_quicktest; + maybe_run_test "event" event_next_unblocking_test; + maybe_run_test "vdi" (fun () -> vdi_test s); + maybe_run_test "async" (fun () -> async_test s); + maybe_run_test "import" (fun () -> import_export_test s); + maybe_run_test "vhd" (fun () -> with_vm s test_vhd_locking_hook); + maybe_run_test "powercycle" (fun () -> with_vm s vm_powercycle_test); + maybe_run_test "lifecycle" (fun () -> with_vm s Quicktest_lifecycle.test); + with + | Api_errors.Server_error (a,b) -> + output_string stderr (Printf.sprintf "%s: %s" a (String.concat "," b)); + | e -> + output_string stderr (Printexc.to_string e)) + ) (fun () -> summarise ())