@@ -23,7 +23,11 @@ module type S = sig
2323
2424 val initialization_special_cases : unit -> unit
2525
26- val remove_data_on_gc : unit -> unit
26+ (* * [remove_data_on_gc_impl ?gc_strict ())] test behavior of cache on GC.
27+ If [gc_strict] is set to [false], then we won't check if the cache is
28+ empty after GC.
29+ *)
30+ val remove_data_on_gc : ?gc_strict : bool -> unit -> unit
2731end
2832
2933module type S_extended = sig
@@ -77,7 +81,7 @@ module Make_impl (Cache : Disk_cache_intf.S_with_count with module Data := Mock)
7781 File_system. with_temp_dir " disk_cache"
7882 ~f: (simple_write_impl ?additional_checks)
7983
80- let remove_data_on_gc_impl tmp_dir =
84+ let remove_data_on_gc_impl ~ gc_strict tmp_dir =
8185 let % map cache = initialize_cache_or_fail tmp_dir ~logger in
8286
8387 let proof = Mock. { proof = " dummy" } in
@@ -91,16 +95,19 @@ module Make_impl (Cache : Disk_cache_intf.S_with_count with module Data := Mock)
9195 [% test_eq: string ] proof.proof proof_from_cache.proof
9296 ~message: " invalid proof from cache" ) ;
9397
94- Gc. compact () ;
98+ match gc_strict with
99+ | Some false ->
100+ ()
101+ | _ ->
102+ Gc. compact () ;
103+ [% test_eq: int ] (Cache. count cache) 0
104+ ~message: " cache should be empty after garbage collector run"
95105
96- [% test_eq: int ] (Cache. count cache) 0
97- ~message: " cache should be empty after garbage collector run"
98-
99- let remove_data_on_gc () =
106+ let remove_data_on_gc ?gc_strict () =
100107 Async.Thread_safe. block_on_async_exn
101108 @@ fun () ->
102109 File_system. with_temp_dir " disk_cache-remove_data_on_gc"
103- ~f: remove_data_on_gc_impl
110+ ~f: ( remove_data_on_gc_impl ~gc_strict )
104111
105112 let initialize_and_expect_failure path ~logger =
106113 let % bind cache_res = Cache. initialize path ~logger in
0 commit comments