@@ -96,15 +96,13 @@ module Action : sig
9696 type t = [
9797 | `Ignore
9898 | `Test_mode of test_mode
99- | `Collect of (unit -> unit ) list ref
10099 ]
101100 val get : unit -> t
102101 val set : t -> unit
103102end = struct
104103 type t = [
105104 | `Ignore
106105 | `Test_mode of test_mode
107- | `Collect of (unit -> unit ) list ref
108106 ]
109107 let action : t ref = ref `Ignore
110108 let force_drop =
@@ -310,7 +308,6 @@ let () =
310308let am_test_runner =
311309 match Action. get () with
312310 | `Test_mode _ -> true
313- | `Collect _ -> assert false
314311 | `Ignore -> false
315312
316313let am_running_inline_test_env_var =
@@ -411,10 +408,11 @@ let add_hooks ((module C) : config) f =
411408
412409let [@ inline never] test ~config ~descr ~tags ~filename: def_filename ~line_number: def_line_number
413410 ~start_pos ~end_pos f =
414- let f = add_hooks config f in
415- let descr () = displayed_descr descr def_filename def_line_number start_pos end_pos in
416411 match Action. get () with
412+ | `Ignore -> ()
417413 | `Test_mode { which_tests = { libname; only_test_location; which_tags } ; what_to_do } ->
414+ let f = add_hooks config f in
415+ let descr () = displayed_descr descr def_filename def_line_number start_pos end_pos in
418416 let complete_tags = tags @ Module_context. current_tags () in
419417 let should_run =
420418 Some libname = ! dynamic_lib
@@ -460,9 +458,6 @@ let[@inline never] test ~config ~descr ~tags ~filename:def_filename ~line_number
460458 backtrace (string_of_module_descr () )
461459 end
462460 end
463- | `Ignore -> ()
464- | `Collect r ->
465- r := (fun () -> if not (time_and_reset_random_seeds f) then failwith (descr () )) :: ! r
466461
467462let set_lib_and_partition static_lib partition =
468463 match ! dynamic_lib with
@@ -473,7 +468,7 @@ let set_lib_and_partition static_lib partition =
473468 | None ->
474469 dynamic_lib := Some static_lib;
475470 match Action. get () with
476- | `Collect _ | ` Ignore -> ()
471+ | `Ignore -> ()
477472 | `Test_mode { which_tests; what_to_do } ->
478473 if which_tests.libname = static_lib then begin
479474 let requires_partition =
@@ -501,25 +496,13 @@ let test_unit ~config ~descr ~tags ~filename ~line_number ~start_pos ~end_pos f
501496 test ~config ~descr ~tags ~filename ~line_number ~start_pos ~end_pos
502497 (fun () -> f () ; true )
503498
504- let collect f =
505- let prev_action = Action. get () in
506- let tests = ref [] in
507- Action. set (`Collect tests);
508- try
509- f () ; (* see comment below about why we don't reset random states *)
510- let tests = List. rev ! tests in
511- Action. set prev_action;
512- tests
513- with e ->
514- Action. set prev_action;
515- raise e
516-
517499let [@ inline never] test_module ~config ~descr ~tags ~filename: def_filename ~line_number: def_line_number
518500 ~start_pos ~end_pos f =
519- let f = add_hooks config f in
520- let descr () = displayed_descr descr def_filename def_line_number start_pos end_pos in
521501 match Action. get () with
502+ | `Ignore -> ()
522503 | `Test_mode { which_tests = { libname; only_test_location = _ ; which_tags } ; what_to_do } ->
504+ let f = add_hooks config f in
505+ let descr () = displayed_descr descr def_filename def_line_number start_pos end_pos in
523506 let partial_tags = tags @ Module_context. current_tags () in
524507 let should_run =
525508 Some libname = ! dynamic_lib
@@ -562,10 +545,6 @@ let[@inline never] test_module ~config ~descr ~tags ~filename:def_filename ~line
562545 (String. uncapitalize_ascii descr) sep exn_str backtrace (string_of_module_descr () )
563546 end
564547 end
565- | `Ignore -> ()
566- | `Collect r ->
567- (* tEST_MODULE are going to be executed inline, unlike before *)
568- r := List. rev_append (collect f) ! r
569548
570549let summarize () =
571550 match Action. get () with
@@ -581,7 +560,7 @@ let summarize () =
581560 | `Test_mode { which_tests = _ ; what_to_do = `List_partitions } ->
582561 List. iter (Printf. printf " %s\n " ) (Partition. all () );
583562 Test_result. Success
584- | ( `Test_mode _ | `Collect _ as action ) -> begin
563+ | `Test_mode { what_to_do = `Run_partition _ ; which_tests } -> begin
585564 begin match ! log with
586565 | None -> ()
587566 | Some ch -> close_out ch
@@ -593,15 +572,12 @@ let summarize () =
593572 Printf. eprintf " %d tests ran, %d test_modules ran\n %!" ! tests_ran ! test_modules_ran
594573 end ;
595574 let errors =
596- match action with
597- | `Collect _ -> None
598- | `Test_mode { what_to_do = `List_partitions ; _ } -> assert false
599- | `Test_mode { what_to_do = `Run_partition _ ; which_tests = { only_test_location; _ } ; _ } ->
600- let unused_tests =
601- List. filter (fun (_ , _ , used ) -> not ! used) only_test_location in
602- match unused_tests with
603- | [] -> None
604- | _ :: _ -> Some unused_tests
575+ let unused_tests =
576+ List. filter (fun (_ , _ , used ) -> not ! used) which_tests.only_test_location
577+ in
578+ match unused_tests with
579+ | [] -> None
580+ | _ :: _ -> Some unused_tests
605581 in
606582 match errors with
607583 | Some tests ->
0 commit comments