Wrap `File_heap` in `File_provider` abstraction
[hiphop-php.git] / hphp / hack / test / integration_ml / saved_state / test_predeclare_ide_deps.ml
blobc7b4e92070a32e91a74a49c0cb390977304a734d
1 module Test = Integration_test_base
2 open Integration_test_base_types
4 let foo_fun = {|<?hh // strict
5 function foo(): void {}
6 |}
8 let bar_class = {|<?hh // strict
9 class Bar {}
12 let baz_typedef = {|<?hh // strict
13 type Baz = int;
16 let qux_const = {|<?hh // strict
17 const int QUX = 4;
20 let test_contents = {|<?hh // strict
21 function test(Baz $x): void {
22 Bar::class;
23 foo();
24 QUX + $x;
28 let disk_state = [
29 "foo.php", foo_fun;
30 "bar.php", bar_class;
31 "baz.php", baz_typedef;
32 "qux.php", qux_const;
35 let () = Tempfile.with_real_tempdir @@ fun temp_dir ->
36 let saved_state_dir = Path.to_string temp_dir in
37 Test.save_state disk_state saved_state_dir;
38 let env = Test.load_state
39 saved_state_dir
40 ~disk_state
41 ~master_changes:[]
42 ~local_changes:[]
43 ~predeclare_ide_deps:true
46 (* After loading from saved state, nothing should be in memory *)
47 assert (not @@ Decl_heap.Funs.mem "\\foo");
48 assert (not @@ Decl_heap.Classes.mem "\\Bar");
49 assert (not @@ Decl_heap.Typedefs.mem "\\Baz");
50 assert (not @@ Decl_heap.GConsts.mem "\\QUX");
52 (* Executing any command that will lead to running type inference on test_contents *)
53 let env = Test.connect_persistent_client env in
54 let env, _ = Test.(run_loop_once env { default_loop_input with
55 persistent_client_request = Some (
56 Request ServerCommandTypes.(IDENTIFY_FUNCTION ((FileContent test_contents), 5, 5))
58 }) in
60 (* Ensure that any results we'll get are from shared memory *)
61 SharedMem.invalidate_caches ();
63 let foo_path = Relative_path.from_root "foo.php" in
65 (* Check that we didn't pollute parser heaps with anything *)
66 assert ((File_provider.get foo_path) = None);
67 assert (not @@ Ast_provider.has_for_test foo_path);
69 (* Check that we did populate declaration heaps *)
70 assert (Decl_heap.Funs.mem "\\foo");
71 assert (Decl_heap.Classes.mem "\\Bar");
72 assert (Decl_heap.Typedefs.mem "\\Baz");
73 assert (Decl_heap.GConsts.mem "\\QUX");
74 ignore env;