Permalink
Browse files

Explicitly trigger full checks in integration tests

Summary:
There is a pattern in integration tests -  whenever I want the server to perform a full recheck, I ask it for full error list (which immediately forces this recheck).

I want to change the scheduling algorithm so that this will not be guaranteed (the request can be stored in environment to be handled later). I change the tests not to depend on this behavior.

Reviewed By: jamesjwu

Differential Revision: D8052008

fbshipit-source-id: 1fb5ed9b65b6498c1e29b7d1054bbf55f8ffa19f
  • Loading branch information...
dabek authored and hhvm-bot committed May 18, 2018
1 parent 3fe4135 commit 1785fdac936bef60beb0604e9e708ca60901ac9b
@@ -122,9 +122,7 @@ let () =
Test.assert_diagnostics loop_output bar107_cleared;
(* Trigger next full recheck to get more global errors *)
let env, _ = Test.status env in
let env = Test.wait env in
let env, loop_output = Test.(run_loop_once env default_loop_input) in
let env, loop_output = Test.full_check env in
(* Notice that foo position is correct on line 5 *)
Test.assert_diagnostics loop_output bar_108_foo_line_5_diagnostics;
@@ -139,9 +137,7 @@ let () =
let env = Test.wait env in
let env, loop_output = Test.(run_loop_once env default_loop_input) in
Test.assert_diagnostics loop_output bar106_cleared;
let env, _ = Test.status env in
let env = Test.wait env in
let env, loop_output = Test.(run_loop_once env default_loop_input) in
let env, loop_output = Test.full_check env in
(* Notice that foo position is back to line 3 *)
Test.assert_diagnostics loop_output bar_109_foo_line_3_diagnostics;
ignore env
@@ -99,9 +99,7 @@ let () =
Test.fail "Expected diagnostics for baz.php";
(* Trigger global recheck *)
let env, loop_output = Test.status env in
Test.assert_no_diagnostics loop_output;
let env, loop_output = Test.(run_loop_once env default_loop_input) in
let env, loop_output = Test.full_check env in
let diagnostics_map = get_diagnostics_map loop_output in
let files_with_errors = get_files_with_errors diagnostics_map in
@@ -121,8 +119,6 @@ let () =
Test.assert_diagnostics loop_output bar_10_clear_diagnostics;
(* Trigger another global recheck to get more global errors *)
let env, loop_output = Test.status env in
Test.assert_no_diagnostics loop_output;
let _, loop_output = Test.(run_loop_once env default_loop_input) in
let _, loop_output = Test.full_check env in
Test.assert_diagnostics loop_output bar_107_diagnostics;
@@ -58,6 +58,5 @@ let () =
* so we don't recheck it immediately. *)
Test.assert_no_diagnostics loop_outputs;
(* Asking for global error list will trigger recheck of bar.php *)
let env, _ = Test.status env in
let _, loop_outputs = Test.(run_loop_once env default_loop_input) in
let _, loop_outputs = Test.full_check env in
Test.assert_diagnostics loop_outputs full_diagnostics
@@ -76,11 +76,9 @@ let () =
let env, loop_output = Test.(run_loop_once env default_loop_input) in
Test.assert_no_diagnostics loop_output;
let env, _ = Test.status env in
let env, loop_output = Test.full_check env in
Test.assert_env_errors env c_errors;
let env = Test.wait env in
let env, loop_output = Test.(run_loop_once env default_loop_input) in
Test.assert_diagnostics loop_output c_diagnostics;
let env, _ = Test.edit_file env a_name a_with_foo_contents in
@@ -8,8 +8,6 @@
*
*)
open Integration_test_base_types
module Test = Integration_test_base
let foo_name = "foo.php"
@@ -57,8 +55,5 @@ let () =
* so we don't recheck it immediately. *)
Test.assert_no_diagnostics loop_outputs;
(* Asking for global error list will trigger recheck of bar.php *)
let env, _ = Test.(run_loop_once env { default_loop_input with
new_client = Some (RequestResponse (ServerCommandTypes.STATUS false))
}) in
let _, loop_outputs = Test.(run_loop_once env default_loop_input) in
let _, loop_outputs = Test.full_check env in
Test.assert_diagnostics loop_outputs full_diagnostics
@@ -61,12 +61,15 @@ let () =
let env = Test.connect_persistent_client env in
let env = Test.open_file env foo_name ~contents:foo_takes_string_contents in
let env, _ = Test.full_check env in
let env, loop_output = Test.status env in
Test.assert_status loop_output ide_diagnostics;
let env, loop_output = Test.status ~ignore_ide:true env in
Test.assert_status loop_output disk_diagnostics;
let env, _ = Test.full_check env in
let env, loop_output = Test.status ~ignore_ide:false env in
Test.assert_status loop_output ide_diagnostics;
ignore env
@@ -264,6 +264,11 @@ let status ?(ignore_ide=false) env =
new_client = Some (RequestResponse (ServerCommandTypes.STATUS ignore_ide))
}
let full_check env =
run_loop_once env { default_loop_input with
disk_changes = ["__dummy_file_to_trigger_full_check.php", ""]
}
let assert_no_diagnostics loop_output =
match loop_output.push_message with
| Some (DIAGNOSTIC _) ->
@@ -58,6 +58,8 @@ val status :
ServerEnv.env *
(ServerCommandTypes.Server_status.t, 'a) loop_outputs
val full_check : ServerEnv.env -> ServerEnv.env * ('a, unit) loop_outputs
val prepend_root: string -> string
val errors_to_string : Pos.absolute Errors.error_ list -> string

0 comments on commit 1785fda

Please sign in to comment.