From 60b5c52b1a8e3aa31bbb6febb27a72c452b2f2fb Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Thu, 17 Oct 2024 22:54:46 -0700 Subject: [PATCH] Remove `SearchPath.normalize` and `SearchPath.create_normalized` Reviewed By: stroxler Differential Revision: D64569696 fbshipit-source-id: d15ea2c0d49ab89d076174c3111b18acd3712bc4 --- source/command/analyzeCommand.ml | 2 +- source/command/checkCommand.ml | 2 +- source/command/codeNavigationCommand.ml | 2 +- source/command/inferCommand.ml | 2 +- source/command/noDaemonQueryCommand.ml | 2 +- source/command/serverCommand.ml | 2 +- source/searchPath.ml | 19 ------- source/searchPath.mli | 9 ---- source/test/searchPathTest.ml | 71 ------------------------- 9 files changed, 6 insertions(+), 105 deletions(-) diff --git a/source/command/analyzeCommand.ml b/source/command/analyzeCommand.ml index 48c9319d188..8779d11e6ac 100644 --- a/source/command/analyzeCommand.ml +++ b/source/command/analyzeCommand.ml @@ -287,7 +287,7 @@ module AnalyzeConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~taint_model_paths ~strict ~debug diff --git a/source/command/checkCommand.ml b/source/command/checkCommand.ml index 624c67723ee..a6fc522493b 100644 --- a/source/command/checkCommand.ml +++ b/source/command/checkCommand.ml @@ -105,7 +105,7 @@ module CheckConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~strict ~debug ~show_error_traces diff --git a/source/command/codeNavigationCommand.ml b/source/command/codeNavigationCommand.ml index fe0a8966913..316f863380d 100644 --- a/source/command/codeNavigationCommand.ml +++ b/source/command/codeNavigationCommand.ml @@ -93,7 +93,7 @@ module CodeNavigationConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~debug ~excludes ~extensions diff --git a/source/command/inferCommand.ml b/source/command/inferCommand.ml index ef2dee49b4b..9bc70c2ea9f 100644 --- a/source/command/inferCommand.ml +++ b/source/command/inferCommand.ml @@ -89,7 +89,7 @@ module InferConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~strict:false ~debug ~show_error_traces:false diff --git a/source/command/noDaemonQueryCommand.ml b/source/command/noDaemonQueryCommand.ml index ebddcc06307..105c71b146a 100644 --- a/source/command/noDaemonQueryCommand.ml +++ b/source/command/noDaemonQueryCommand.ml @@ -96,7 +96,7 @@ module QueryConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~debug ~excludes ~extensions diff --git a/source/command/serverCommand.ml b/source/command/serverCommand.ml index b9ba30f2dd3..f3c23d5010e 100644 --- a/source/command/serverCommand.ml +++ b/source/command/serverCommand.ml @@ -177,7 +177,7 @@ module ServerConfiguration = struct ?long_lived_workers ~local_root:(Option.value local_root ~default:global_root) ~project_root:global_root - ~search_paths:(List.map search_paths ~f:SearchPath.normalize) + ~search_paths ~taint_model_paths ~strict ~debug diff --git a/source/searchPath.ml b/source/searchPath.ml index 7bb9b753820..8f5e4ba0fb6 100644 --- a/source/searchPath.ml +++ b/source/searchPath.ml @@ -77,25 +77,6 @@ let create serialized = | _ -> failwith (Format.asprintf "Unable to create search path from %s" serialized) -let normalize = function - | Root root -> - Root (PyrePath.create_absolute ~follow_symbolic_links:false (PyrePath.absolute root)) - | Subdirectory { root; subdirectory } -> - Subdirectory - { - root = PyrePath.create_absolute ~follow_symbolic_links:false (PyrePath.absolute root); - subdirectory; - } - | Submodule { root; submodule } -> - Submodule - { - root = PyrePath.create_absolute ~follow_symbolic_links:false (PyrePath.absolute root); - submodule; - } - - -let create_normalized serialized = create serialized |> normalize - let search_for_path ~search_paths analysis_path = let raw_path = ArtifactPath.raw analysis_path in let under_root search_path = diff --git a/source/searchPath.mli b/source/searchPath.mli index 943f2519890..a4f47066c3c 100644 --- a/source/searchPath.mli +++ b/source/searchPath.mli @@ -30,13 +30,4 @@ val to_path : t -> PyrePath.t side-effect. *) val create : string -> t -(* Create a normalized search path from its string representation. Normalizing a path means to - expand its relativized root and follow symlinks. This operation DOES have filesystem - side-effect. *) -val create_normalized : string -> t - -(* Turn a potentially un-normalized search path into a normalized one. This operation DOES have - filesystem side-effect.*) -val normalize : t -> t - val search_for_path : search_paths:t list -> ArtifactPath.t -> search_result option diff --git a/source/test/searchPathTest.ml b/source/test/searchPathTest.ml index 5b55d936715..f5aac8624b8 100644 --- a/source/test/searchPathTest.ml +++ b/source/test/searchPathTest.ml @@ -47,76 +47,6 @@ let test_show_search_path _ = () -let test_normalize context = - let good_root = bracket_tmpdir context in - let good_root_path = PyrePath.create_absolute good_root in - let bad_root_path = - PyrePath.create_relative ~root:good_root_path ~relative:"nonexist/directory" - in - let bad_root = PyrePath.absolute bad_root_path in - let good_subroot_path = PyrePath.create_relative ~root:good_root_path ~relative:"subroot" in - PyrePath.create_directory_recursively good_subroot_path |> Base.Result.ok_or_failwith; - let good_subroot = PyrePath.absolute good_subroot_path in - let create_input ?subdirectory ?submodule root = - let search_path = - match subdirectory, submodule with - | Some subdirectory, _ -> SearchPath.Subdirectory { root = !root; subdirectory } - | _, Some submodule -> SearchPath.Submodule { root = !root; submodule } - | _ -> SearchPath.Root !root - in - SearchPath.show search_path - in - let assert_success ~normalize ~expected input = - let create_search_path, create_type = - if normalize then - SearchPath.create_normalized, "normalized" - else - SearchPath.create, "non-normalized" - in - try - let _ = create_search_path input in - if not expected then - let message = - Format.sprintf - "Expect %s search path creation to succeed but it failed on input %s" - create_type - input - in - assert_failure message - with - | _ -> - if expected then - let message = - Format.sprintf - "Expect %s search path creation to fail but it succeeded on input %s" - create_type - input - in - assert_failure message - in - - (* Non-normalized creation succeeds all the time. *) - assert_success ~normalize:false ~expected:true (create_input good_root); - assert_success ~normalize:false ~expected:true (create_input good_subroot); - assert_success ~normalize:false ~expected:true (create_input bad_root); - assert_success ~normalize:false ~expected:true (create_input ~subdirectory:"subroot" good_root); - assert_success ~normalize:false ~expected:true (create_input ~subdirectory:"nosubroot" good_root); - assert_success ~normalize:false ~expected:true (create_input ~subdirectory:"subroot" bad_root); - assert_success ~normalize:false ~expected:true (create_input ~submodule:"subroot" bad_root); - - (* Normalized creation depends on filesystem state. *) - assert_success ~normalize:true ~expected:true (create_input good_root); - assert_success ~normalize:true ~expected:true (create_input good_subroot); - assert_success ~normalize:true ~expected:false (create_input bad_root); - assert_success ~normalize:true ~expected:true (create_input ~subdirectory:"subroot" good_root); - assert_success ~normalize:true ~expected:false (create_input ~subdirectory:"nosubroot" good_root); - assert_success ~normalize:true ~expected:false (create_input ~subdirectory:"subroot" bad_root); - assert_success ~normalize:true ~expected:true (create_input ~submodule:"subroot" good_root); - assert_success ~normalize:true ~expected:false (create_input ~submodule:"subroot" bad_root); - - () - - let test_search_for_path context = let root = bracket_tmpdir context |> PyrePath.create_absolute in let assert_path ~search_paths ~path ~expected = @@ -157,7 +87,6 @@ let () = >::: [ "create_search_path" >:: test_create_search_path; "show_search_path" >:: test_show_search_path; - "normalize" >:: test_normalize; "search_for_path" >:: test_search_for_path; ] |> Test.run