1 open Integration_test_base_types
3 module Test
= Integration_test_base
5 let init_base_content =
7 enum DynamicTemplateField : string {
9 DESCRIPTION = 'description';
13 let err_base_content =
15 enum DynamicTemplateField : string {
17 DESCRIPTION = 'description';
21 let make_disk_changes base_content
=
23 ("base.php", base_content
);
28 DynamicTemplateField $field,
30 // Switch enforces enum exhaustiveness
32 case DynamicTemplateField::BRAND:
34 case DynamicTemplateField::DESCRIPTION:
41 let errors_to_string errors
=
43 (fun str error
-> str ^
Errors.(error
|> to_absolute
|> to_string
))
48 let env = Test.setup_server
() in
49 (* Initially we expect no errors *)
55 default_loop_input
with
56 disk_changes
= make_disk_changes init_base_content;
59 let errors = Errors.get_sorted_error_list
env.errorl
in
61 Test.fail
("Expected no errors. Got:\n" ^
errors_to_string errors);
63 (* We expect errors when we change base.php to err_base_content *)
69 default_loop_input
with
70 disk_changes
= make_disk_changes err_base_content;
73 let expected_errors = Errors.get_sorted_error_list
env.errorl
in
74 if expected_errors = [] then Test.fail
"Expected there to be errors!";
76 (* We reset the disk changes to the initial state. Should be no errors *)
82 default_loop_input
with
83 disk_changes
= make_disk_changes init_base_content;
86 let errors = Errors.get_sorted_error_list
env.errorl
in
88 Test.fail
("Expected no errors. Got:\n" ^
errors_to_string errors);
90 (* We now change only base.php. We expect the same errors as before *)
96 default_loop_input
with
97 disk_changes
= [("base.php", err_base_content)];
100 let incremental_errors = Errors.get_sorted_error_list
env.errorl
in
101 if incremental_errors <> expected_errors then
103 ("Incremental mode gave different errors than a full type check.\n\n"
104 ^
"Full Type Check Errors:\n"
105 ^
errors_to_string expected_errors
107 ^
"Incremental Mode Errors:\n"
108 ^
errors_to_string incremental_errors)