[changed files] don't fail on non-existent absolute paths

Summary:
When a file is passed to infer through `--changed-files-index` which is
- an absolute path
- the file does not exist

Then the code fails throwing an exception in the function below while trying to relativise the absolute path.

The behaviour on relative paths is to skip missing files, and does not fail because Infer does not attempt to relativise them.

Swallow the exception and skip the file; and so unify the behaviour across relative and absolute paths.

Reviewed By: mityal

Differential Revision: D16279672

fbshipit-source-id: 33b468da7
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent 82eb91fe71
commit 380515bc89

@ -169,14 +169,16 @@ let create ?(warn_on_error = true) path =
let changed_sources_from_changed_files changed_files =
List.fold changed_files ~init:Set.empty ~f:(fun changed_files_set line ->
let source_file = create line in
let changed_files' = Set.add source_file changed_files_set in
(* Add source corresponding to changed header if it exists *)
match of_header source_file with
| Some src ->
Set.add src changed_files'
| None ->
changed_files' )
try
let source_file = create line in
let changed_files' = Set.add source_file changed_files_set in
(* Add source corresponding to changed header if it exists *)
match of_header source_file with
| Some src ->
Set.add src changed_files'
| None ->
changed_files'
with _exn -> changed_files_set )
module SQLite = struct

Loading…
Cancel
Save