[config] add option to force deletion of results dir

Summary:
Since D5381239, infer is careful not to delete directories that do not "look
like" results directories on startup, in case the user passed, eg, `-o /`.

In our repo, lots of results dir are created by build/test of infer, and when
the version of infer changes and the expected contents of results directories
change then it might start refusing to delete the results directories created
with another version of infer.

Add an option to force infer to delete the results directory no matter how
dodgy it looks, and use it in our repo by adding the option in every
.inferconfig.

Reviewed By: mbouaziz

Differential Revision: D5870984

fbshipit-source-id: 09412de
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 72b1ac4b5a
commit d2b4f3c8da

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"siof-safe-methods": ["getGlobalNonPODWhitelisted", "whitelisted::getGlobalNonPOD",
"whitelisted::TemplatedObject::getGlobalNonPOD"],
"skip-translation": [

@ -52,6 +52,7 @@ let remove_results_dir () =
(* Look if file exists, it may not be a directory but that will be caught by the call to [is_results_dir]. If it's an empty directory, leave it alone. This allows users to create a temporary directory for the infer results without infer removing it to recreate it, which could be racy. *)
if Sys.file_exists Config.results_dir = `Yes && not (Utils.directory_is_empty Config.results_dir)
then (
if not Config.force_delete_results_dir then
Result.iter_error (is_results_dir ()) ~f:(fun err ->
L.(die UserError)
"ERROR: '%s' exists but does not seem to be an infer results directory: %s@\nERROR: Please delete '%s' and try again@."

@ -1106,6 +1106,16 @@ and flavors =
~in_help:CLOpt.([(Capture, manual_buck_flavors)])
"Buck integration using Buck flavors (clang only), eg $(i,`infer --flavors -- buck build //foo:bar#infer`)"
and force_delete_results_dir =
CLOpt.mk_bool ~long:"force-delete-results-dir" ~default:false
~in_help:
(CLOpt.(
[ (Capture, manual_generic)
; (Compile, manual_generic)
; (Diff, manual_generic)
; (Run, manual_generic) ]))
"Do not refuse to delete the results directory if it doesn't look like an infer results directory."
and from_json_report =
CLOpt.mk_path_opt ~long:"from-json-report"
~in_help:CLOpt.([(Report, manual_generic)])
@ -2067,6 +2077,8 @@ and filtering = !filtering
and flavors = !flavors
and force_delete_results_dir = !force_delete_results_dir
and fragment_retains_view = !fragment_retains_view
and from_json_report = !from_json_report

@ -404,6 +404,8 @@ val filtering : bool
val flavors : bool
val force_delete_results_dir : bool
val fragment_retains_view : bool
val from_json_report : string option

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"skip-translation": [
{
"language": "Java",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"quandary-sources": [
{
"procedure": "__infer_taint_source",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"never-returning-null": [
{
"language": "Java",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"modeled-expensive": [
{
"language": "Java",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"never-returning-null": [
{
"language": "Java",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"quandary-sources": [
{
"procedure": "codetoanalyze.java.quandary.ExternalSpecs.privateData*",

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"threadsafe-aliases": ["MyThreadSafeAlias1", "codetoanalyze.java.checkers.MyThreadSafeAlias2"],
"skip-translation": [
{

@ -1,4 +1,5 @@
{
"force-delete-results-dir": true,
"never-returning-null": [
{
"language": "Java",

Loading…
Cancel
Save