From 4cee0882bead74639e11ce51e8cec957976945fe Mon Sep 17 00:00:00 2001 From: Martin Trojer Date: Wed, 11 Mar 2020 07:07:34 -0700 Subject: [PATCH] move integration tmpfiles to infer-out/tmp/ Reviewed By: jvillard Differential Revision: D19537047 fbshipit-source-id: 188200738 --- infer/src/base/Config.ml | 2 ++ infer/src/base/Config.mli | 2 ++ infer/src/base/ResultsDir.ml | 1 + infer/src/base/Utils.ml | 2 +- infer/src/integration/Buck.ml | 2 +- infer/src/integration/BuckGenrule.ml | 4 ++-- infer/src/integration/CaptureCompilationDatabase.ml | 2 +- infer/src/integration/ClangQuotes.ml | 3 +-- infer/src/integration/Javac.ml | 4 ++-- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 344642b5c..5e1874fb8 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -3028,6 +3028,8 @@ and custom_symbols = and symops_per_iteration = !symops_per_iteration +and temp_file_dir = !results_dir ^/ "tmp" + and keep_going = !keep_going and test_determinator = !test_determinator diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index ddd0e2147..02c55b401 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -665,6 +665,8 @@ val xcode_developer_dir : string option val xcpretty : bool (** {2 Global variables with initial values specified by command-line options} *) +val temp_file_dir : string + val clang_compilation_dbs : [`Escaped of string | `Raw of string] list ref (** {2 Command Line Interface Documentation} *) diff --git a/infer/src/base/ResultsDir.ml b/infer/src/base/ResultsDir.ml index e570ce31b..c75a98e76 100644 --- a/infer/src/base/ResultsDir.ml +++ b/infer/src/base/ResultsDir.ml @@ -82,6 +82,7 @@ let create_results_dir () = L.die UserError "ERROR: %s@\nPlease remove '%s' and try again" error Config.results_dir ) ; Unix.mkdir_p Config.results_dir ; + Unix.mkdir_p Config.temp_file_dir ; List.iter ~f:Unix.mkdir_p results_dir_dir_markers ; prepare_logging_and_db () ; () diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 98001c136..3b0eb03eb 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -215,7 +215,7 @@ type file_lock = ; unlock: unit -> unit } let create_file_lock () = - let file, oc = Core.Filename.open_temp_file "infer" "" in + let file, oc = Core.Filename.open_temp_file "infer_lock" "" in let fd = Core.Unix.openfile ~mode:[IStd.Unix.O_WRONLY] file in let lock () = Core.Unix.lockf fd ~mode:IStd.Unix.F_LOCK ~len:IStd.Int64.zero in let unlock () = Core.Unix.lockf fd ~mode:IStd.Unix.F_ULOCK ~len:IStd.Int64.zero in diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index bd755be9e..ece782f37 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -324,7 +324,7 @@ let rec exceed_length ~max = function let store_args_in_file args = if exceed_length ~max:max_command_line_length args then ( - let file = Filename.temp_file "buck_targets" ".txt" in + let file = Filename.temp_file ~in_dir:Config.temp_file_dir "buck_targets" ".txt" in let write_args outc = Out_channel.output_string outc (String.concat ~sep:"\n" args) in let () = Utils.with_file_out file ~f:write_args in L.(debug Capture Quiet) "Buck targets options stored in file '%s'@\n" file ; diff --git a/infer/src/integration/BuckGenrule.ml b/infer/src/integration/BuckGenrule.ml index 568864981..4787b1088 100644 --- a/infer/src/integration/BuckGenrule.ml +++ b/infer/src/integration/BuckGenrule.ml @@ -23,7 +23,7 @@ let write_infer_deps infile = let run_buck_capture cmd = - let buck_output_file = Filename.temp_file "buck_output" ".log" in + let buck_output_file = Filename.temp_file ~in_dir:Config.temp_file_dir "buck_output" ".log" in let shell_cmd = List.map ~f:Escape.escape_shell cmd |> String.concat ~sep:" " @@ -45,7 +45,7 @@ let run_buck_capture cmd = In_channel.close buck_stderr ; match Unix.waitpid pid with | Ok () -> - write_infer_deps buck_output_file ; Unix.unlink buck_output_file + write_infer_deps buck_output_file | Error _ as err -> L.(die ExternalError) "*** Buck genrule capture failed to execute: %s@\n***@." diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index eb05ed719..f8aebbbfe 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -124,7 +124,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args = (** Compute the compilation database files. *) let get_compilation_database_files_xcodebuild ~prog ~args = - let tmp_file = Filename.temp_file "cdb" ".json" in + let tmp_file = Filename.temp_file ~in_dir:Config.temp_file_dir "cdb" ".json" in let xcodebuild_prog, xcodebuild_args = (prog, prog :: args) in let xcpretty_prog = "xcpretty" in let xcpretty_args = diff --git a/infer/src/integration/ClangQuotes.ml b/infer/src/integration/ClangQuotes.ml index 1c29f146e..8f8cf4817 100644 --- a/infer/src/integration/ClangQuotes.ml +++ b/infer/src/integration/ClangQuotes.ml @@ -28,7 +28,7 @@ let quote style = let mk_arg_file prefix style args = - let file = Filename.temp_file prefix ".txt" in + let file = Filename.temp_file prefix ~in_dir:Config.temp_file_dir ".txt" in let write_args outc = List.iter ~f:(fun arg -> @@ -38,5 +38,4 @@ let mk_arg_file prefix style args = in Utils.with_file_out file ~f:write_args ; L.(debug Capture Medium) "Clang options stored in file %s@\n" file ; - if not Config.debug_mode then Utils.unlink_file_on_exit file ; file diff --git a/infer/src/integration/Javac.ml b/infer/src/integration/Javac.ml index 6ddd09427..c20777b4b 100644 --- a/infer/src/integration/Javac.ml +++ b/infer/src/integration/Javac.ml @@ -30,7 +30,7 @@ let compile compiler build_prog build_args = in (* Pass non-special args via a file to avoid exceeding the command line size limit. *) let args_file = - let file = Filename.temp_file "args_" "" in + let file = Filename.temp_file ~in_dir:Config.temp_file_dir "args_" "" in let quoted_file_args = List.map file_args ~f:(fun arg -> if String.contains arg '\'' then arg else F.sprintf "'%s'" arg ) @@ -41,7 +41,7 @@ let compile compiler build_prog build_args = let cli_file_args = cli_args @ ["@" ^ args_file] in let args = prog_args @ cli_file_args in L.(debug Capture Quiet) "Current working directory: '%s'@." (Sys.getcwd ()) ; - let verbose_out_file = Filename.temp_file "javac" ".out" in + let verbose_out_file = Filename.temp_file ~in_dir:Config.temp_file_dir "javac" ".out" in let try_run cmd error_k = let shell_cmd = List.map ~f:Escape.escape_shell cmd |> String.concat ~sep:" " in let shell_cmd_redirected = Printf.sprintf "%s 2>'%s'" shell_cmd verbose_out_file in