Skip to content

Commit 0ef10a6

Browse files
committed
Split clean_up_artifacts_on_startup into setup for build_files and log_files separately; fixes a corner case in test build
Signed-off-by: Lukasz Stafiniak <lukstafi@gmail.com>
1 parent fd99c07 commit 0ef10a6

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

arrayjit/lib/utils.ml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,28 @@ let diagn_log_file fname =
257257

258258
let () =
259259
(* Cleanup needs to happen before get_local_debug_runtime (or any other code is run). *)
260-
let clean_up_artifacts_on_startup =
261-
get_global_flag ~default:true ~arg_name:"clean_up_artifacts_on_startup"
260+
let remove_dir_if_exists dirname =
261+
if Stdlib.Sys.file_exists dirname && Stdlib.Sys.is_directory dirname then
262+
try
263+
Array.iter (Stdlib.Sys.readdir dirname) ~f:(fun fname ->
264+
Stdlib.Sys.remove (Stdlib.Filename.concat dirname fname));
265+
Stdlib.Sys.rmdir dirname
266+
with exn ->
267+
Stdio.eprintf "Failed to delete directory %s: %s\n%!" dirname (Exn.to_string exn)
268+
else if Stdlib.Sys.file_exists dirname then
269+
try Stdlib.Sys.remove dirname
270+
with exn ->
271+
Stdio.eprintf "Failed to delete file %s (expected a directory): %s\n%!" dirname
272+
(Exn.to_string exn)
262273
in
263-
if clean_up_artifacts_on_startup then (
264-
let remove_dir_if_exists dirname =
265-
if Stdlib.Sys.file_exists dirname && Stdlib.Sys.is_directory dirname then
266-
try
267-
Array.iter (Stdlib.Sys.readdir dirname) ~f:(fun fname ->
268-
Stdlib.Sys.remove (Stdlib.Filename.concat dirname fname));
269-
Stdlib.Sys.rmdir dirname
270-
with exn ->
271-
Stdio.eprintf "Failed to delete directory %s: %s\n%!" dirname (Exn.to_string exn)
272-
else if Stdlib.Sys.file_exists dirname then
273-
try Stdlib.Sys.remove dirname
274-
with exn ->
275-
Stdio.eprintf "Failed to delete file %s (expected a directory): %s\n%!" dirname
276-
(Exn.to_string exn)
277-
in
278-
remove_dir_if_exists "log_files";
279-
remove_dir_if_exists "build_files")
274+
let clean_up_log_files_on_startup =
275+
get_global_flag ~default:true ~arg_name:"clean_up_log_files_on_startup"
276+
in
277+
if clean_up_log_files_on_startup then remove_dir_if_exists "log_files";
278+
let clean_up_build_files_on_startup =
279+
get_global_flag ~default:true ~arg_name:"clean_up_build_files_on_startup"
280+
in
281+
if clean_up_build_files_on_startup then remove_dir_if_exists "build_files"
280282

281283
let get_local_debug_runtime =
282284
let snapshot_every_sec =

ocannl_config.example

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ check_half_prec_constants_cutoff=16384.0
5252
# recent modification.
5353
automatic_host_transfers=true
5454

55-
# If true (the default), the directories log_files and build_files are deleted on startup.
56-
clean_up_artifacts_on_startup=true
55+
# If true, the build_files directory is deleted on startup.
56+
clean_up_build_files_on_startup=true
57+
58+
# If true, the log_files directory is deleted on startup.
59+
clean_up_log_files_on_startup=true
5760

5861
# Other configurations:
5962

test/config/ocannl_config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ prefer_backend_uniformity=true
88
default_prec=single
99
fixed_state_for_init=42
1010
# Don't delete files as tests might be running in parallel deleting each-other's files.
11-
clean_up_artifacts_on_startup=false
11+
clean_up_build_files_on_startup=false
12+
clean_up_log_files_on_startup=false

test/operations/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"--ocannl_log_main_domain_to_stdout=false"
3131
"--ocannl_debug_log_to_stream_files=true"
3232
; We have to clean up to avoid appending to results of a previous run
33-
"--ocannl_clean_up_artifacts_on_startup=true")
33+
"--ocannl_clean_up_log_files_on_startup=true")
3434
(write-file %{targets} "completed\n"))))
3535

3636
; Step 2: Process the log file, depending on the backend-specific sentinel

0 commit comments

Comments
 (0)