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
=
44 str ^
(error
|> User_error.to_absolute
|> Errors.to_string
))
49 let env = Test.setup_server
() in
50 (* Initially we expect no errors *)
56 default_loop_input
with
57 disk_changes
= make_disk_changes init_base_content;
60 let errors = Errors.get_sorted_error_list
env.errorl
in
62 Test.fail
("Expected no errors. Got:\n" ^
errors_to_string errors);
64 (* We expect errors when we change base.php to err_base_content *)
70 default_loop_input
with
71 disk_changes
= make_disk_changes err_base_content;
74 let expected_errors = Errors.get_sorted_error_list
env.errorl
in
75 if expected_errors = [] then Test.fail
"Expected there to be errors!";
77 (* We reset the disk changes to the initial state. Should be no errors *)
83 default_loop_input
with
84 disk_changes
= make_disk_changes init_base_content;
87 let errors = Errors.get_sorted_error_list
env.errorl
in
89 Test.fail
("Expected no errors. Got:\n" ^
errors_to_string errors);
91 (* We now change only base.php. We expect the same errors as before *)
97 default_loop_input
with
98 disk_changes
= [("base.php", err_base_content)];
101 let incremental_errors = Errors.get_sorted_error_list
env.errorl
in
102 if incremental_errors <> expected_errors then
104 ("Incremental mode gave different errors than a full type check.\n\n"
105 ^
"Full Type Check Errors:\n"
106 ^
errors_to_string expected_errors
108 ^
"Incremental Mode Errors:\n"
109 ^
errors_to_string incremental_errors)