ocamltest: opt-in -keep-test-dir-on-success to keep test data on success
parent
9eadd76ed1
commit
a86943c889
|
@ -154,9 +154,11 @@ let test_file test_filename =
|
||||||
let hookname_prefix = Filename.concat test_source_directory test_prefix in
|
let hookname_prefix = Filename.concat test_source_directory test_prefix in
|
||||||
let test_build_directory_prefix =
|
let test_build_directory_prefix =
|
||||||
get_test_build_directory_prefix test_directory in
|
get_test_build_directory_prefix test_directory in
|
||||||
ignore (Sys.command ("rm -rf " ^ test_build_directory_prefix));
|
let clean_test_build_directory () =
|
||||||
|
ignore (Sys.command ("rm -rf " ^ test_build_directory_prefix)) in
|
||||||
|
clean_test_build_directory ();
|
||||||
Sys.make_directory test_build_directory_prefix;
|
Sys.make_directory test_build_directory_prefix;
|
||||||
Sys.with_chdir test_build_directory_prefix
|
let summary = Sys.with_chdir test_build_directory_prefix
|
||||||
(fun () ->
|
(fun () ->
|
||||||
let log =
|
let log =
|
||||||
if !Options.log_to_stderr then stderr else begin
|
if !Options.log_to_stderr then stderr else begin
|
||||||
|
@ -193,13 +195,20 @@ let test_file test_filename =
|
||||||
let initial_status =
|
let initial_status =
|
||||||
if skip_test then Skip_all_tests else Run rootenv
|
if skip_test then Skip_all_tests else Run rootenv
|
||||||
in
|
in
|
||||||
let _summary =
|
let summary =
|
||||||
run_test_trees log common_prefix "" initial_status test_trees in
|
run_test_trees log common_prefix "" initial_status test_trees in
|
||||||
Actions.clear_all_hooks();
|
Actions.clear_all_hooks();
|
||||||
if not !Options.log_to_stderr then close_out log
|
if not !Options.log_to_stderr then close_out log;
|
||||||
);
|
summary
|
||||||
|
) in
|
||||||
(* Restore current working directory *)
|
(* Restore current working directory *)
|
||||||
Sys.chdir cwd
|
Sys.chdir cwd;
|
||||||
|
begin match summary with
|
||||||
|
| Some_failure -> ()
|
||||||
|
| No_failure ->
|
||||||
|
if not !Options.keep_test_dir_on_success then
|
||||||
|
clean_test_build_directory ()
|
||||||
|
end
|
||||||
|
|
||||||
let is_test s =
|
let is_test s =
|
||||||
match tsl_block_of_file s with
|
match tsl_block_of_file s with
|
||||||
|
|
|
@ -49,6 +49,8 @@ let log_to_stderr = ref false
|
||||||
|
|
||||||
let promote = ref false
|
let promote = ref false
|
||||||
|
|
||||||
|
let keep_test_dir_on_success = ref false
|
||||||
|
|
||||||
let find_test_dirs = ref []
|
let find_test_dirs = ref []
|
||||||
|
|
||||||
let list_tests = ref []
|
let list_tests = ref []
|
||||||
|
@ -68,6 +70,8 @@ let commandline_options =
|
||||||
" Find directories that contain tests (recursive).");
|
" Find directories that contain tests (recursive).");
|
||||||
("-list-tests", Arg.String (add_to_list list_tests),
|
("-list-tests", Arg.String (add_to_list list_tests),
|
||||||
" List tests in given directory.");
|
" List tests in given directory.");
|
||||||
|
("-keep-test-dir-on-success", Arg.Set keep_test_dir_on_success,
|
||||||
|
" Keep the test directory (with the generated test artefacts) on success.");
|
||||||
]
|
]
|
||||||
|
|
||||||
let files_to_test = ref []
|
let files_to_test = ref []
|
||||||
|
|
|
@ -26,3 +26,5 @@ val usage : string
|
||||||
val find_test_dirs : string list ref
|
val find_test_dirs : string list ref
|
||||||
|
|
||||||
val list_tests : string list ref
|
val list_tests : string list ref
|
||||||
|
|
||||||
|
val keep_test_dir_on_success : bool ref
|
||||||
|
|
Loading…
Reference in New Issue