Add method to clean the results directory

Summary:
I observed a bug in incremental analysis for thread safety analysis, where a thread safety violation was not being reported because the folder `racerd` was not being cleaned. This meant that the violation was determined to be a preexisting issue when it was actually an introduced issue.

This method can be used to fix this problem by cleaning the `racerd` folder. It also cleans the `captured` folder, I've done this following the original version of the method (see D16602417).

I'm not sure if the `captured` folder is used; it wasn't used in the tests I did. Thoughts about this?

Reviewed By: ngorogiannis

Differential Revision: D17261504

fbshipit-source-id: 8fea23e98
master
Phoebe Nichols 5 years ago committed by Facebook Github Bot
parent eb38b9c4c3
commit 1a010eda78

@ -35,7 +35,7 @@ val merge_dbs : infer_out_src:string -> unit
val canonicalize : unit -> unit
(** put the database on disk in deterministic form *)
val reset_capture_tables : unit -> unit [@@warning "-32"]
val reset_capture_tables : unit -> unit
val start : unit -> unit

@ -34,6 +34,24 @@ let non_empty_directory_exists results_dir =
Sys.is_directory results_dir = `Yes && not (Utils.directory_is_empty results_dir)
let dirs_to_clean ~cache_capture =
let open Config in
let common_list =
[backend_stats_dir_name; classnames_dir_name; frontend_stats_dir_name; reporting_stats_dir_name]
in
if cache_capture then common_list
else captured_dir_name :: racerd_issues_dir_name :: starvation_issues_dir_name :: common_list
let delete_capture_and_results_data () =
DBWriter.reset_capture_tables () ;
let dirs_to_delete =
List.map ~f:(Filename.concat Config.results_dir) (dirs_to_clean ~cache_capture:true)
in
List.iter ~f:Utils.rmtree dirs_to_delete ;
()
let remove_results_dir () =
if non_empty_directory_exists Config.results_dir then (
if not Config.force_delete_results_dir then

@ -15,3 +15,10 @@ val remove_results_dir : unit -> unit
val create_results_dir : unit -> unit
(** Create the results dir and sets up logging, the database, etc. *)
val delete_capture_and_results_data : unit -> unit
[@@warning "-32"]
(** delete capture and results data in the results directory *)
val dirs_to_clean : cache_capture:bool -> string list
(** directories in the results directory containing capture or results data *)

@ -81,17 +81,7 @@ let clean_results_dir () =
ResultsDatabase.db_close () ;
(* In Buck flavors mode we keep all capture data, but in Java mode we keep only the tenv *)
let should_delete_dir =
let dirs_to_delete =
let open Config in
let common_list =
[ backend_stats_dir_name
; classnames_dir_name
; frontend_stats_dir_name
; reporting_stats_dir_name ]
in
if cache_capture then common_list
else captured_dir_name :: racerd_issues_dir_name :: starvation_issues_dir_name :: common_list
in
let dirs_to_delete = ResultsDir.dirs_to_clean ~cache_capture in
List.mem ~equal:String.equal dirs_to_delete
in
let should_delete_file =

Loading…
Cancel
Save