@@ -144,6 +144,23 @@ let checked_output_file ?snapshot_path name : checked_output_file =
144144 options = { snapshot_path };
145145 }
146146
147+ let stash_output_file src_path name =
148+ match Run. get_current_test () with
149+ | None ->
150+ failwith " Testo.stash_output_file is being called outside of a test"
151+ | Some test ->
152+ match List. find_opt (fun (x : T.checked_output_file ) -> x.name = name)
153+ test.checked_output_files with
154+ | None ->
155+ invalid_arg (
156+ sprintf
157+ " Testo.stash_output_file: invalid output file name \
158+ for test '%s': '%s'"
159+ test.name name
160+ )
161+ | Some x ->
162+ Store. stash_output_file test src_path x
163+
147164(*
148165 Create an hexadecimal hash that is just long enough to not suffer from
149166 collisions in realistic use cases defined as:
@@ -227,14 +244,8 @@ let fail = Testo_util.Error.fail_test
227244
228245let write_file = Helpers. write_file
229246let read_file = Helpers. read_file
230-
231- let map_file func src_path dst_path =
232- let old_contents = read_file src_path in
233- let new_contents = func old_contents in
234- write_file dst_path new_contents
235-
236- let copy_file src_path dst_path =
237- map_file (fun data -> data) src_path dst_path
247+ let map_file = Helpers. map_file
248+ let copy_file = Helpers. copy_file
238249
239250let with_temp_file = Temp_file. with_temp_file
240251let with_capture = Store. with_capture
@@ -247,12 +258,9 @@ let with_chdir path func =
247258 func
248259
249260(* We need this to allow the user's test function to call
250- 'stash_output_files ' *)
261+ 'stash_output_file ' *)
251262let get_current_test () = Run. get_current_test ()
252263
253- (* TODO: stash_output_files: copy the output files to compare against
254- snapshots before cleaning up the workspace *)
255-
256264(* *************************************************************************)
257265(* Hygiene *)
258266(* *************************************************************************)
0 commit comments