Make pull diagnostics remote test more robust (#33057)
Follow-up of https://github.com/zed-industries/zed/pull/33028 Due to request races, we cannot predict the amount of result_id s that we'll get. Ensure their amount grows monotonically each time. This time, iterations=5000 did not fail for me. Release Notes: - N/A
This commit is contained in:
parent
b89ddf3a6e
commit
bca1a9145c
1 changed files with 19 additions and 30 deletions
|
@ -2656,10 +2656,9 @@ async fn test_lsp_pull_diagnostics(cx_a: &mut TestAppContext, cx_b: &mut TestApp
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert!(
|
||||||
&BTreeSet::from_iter([None]),
|
diagnostics_pulls_result_ids.lock().await.len() > 0,
|
||||||
diagnostics_pulls_result_ids.lock().await.deref(),
|
"Initial diagnostics pulls should report None at least"
|
||||||
"Initial diagnostics pulls should not reuse any result ids"
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
0,
|
0,
|
||||||
|
@ -2689,18 +2688,6 @@ async fn test_lsp_pull_diagnostics(cx_a: &mut TestAppContext, cx_b: &mut TestApp
|
||||||
"After client lib.rs edits, the workspace diagnostics request should follow"
|
"After client lib.rs edits, the workspace diagnostics request should follow"
|
||||||
);
|
);
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
{
|
|
||||||
assert_eq!(
|
|
||||||
2,
|
|
||||||
diagnostics_pulls_result_ids.lock().await.len(),
|
|
||||||
"One new id for a client's lib.rs pull"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
2,
|
|
||||||
workspace_diagnostics_pulls_result_ids.lock().await.len(),
|
|
||||||
"Two more entries for 2 currently opened files that previously pulled the diagnostics"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_b_main.update_in(cx_b, |editor, window, cx| {
|
editor_b_main.update_in(cx_b, |editor, window, cx| {
|
||||||
editor.move_to_end(&MoveToEnd, window, cx);
|
editor.move_to_end(&MoveToEnd, window, cx);
|
||||||
|
@ -2720,14 +2707,6 @@ async fn test_lsp_pull_diagnostics(cx_a: &mut TestAppContext, cx_b: &mut TestApp
|
||||||
"After client main.rs edits, the workspace diagnostics pull should follow"
|
"After client main.rs edits, the workspace diagnostics pull should follow"
|
||||||
);
|
);
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
{
|
|
||||||
assert_eq!(
|
|
||||||
3,
|
|
||||||
diagnostics_pulls_result_ids.lock().await.len(),
|
|
||||||
"One new id for a client's main.rs pull"
|
|
||||||
);
|
|
||||||
assert_eq!(4, workspace_diagnostics_pulls_result_ids.lock().await.len());
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_a_main.update_in(cx_a, |editor, window, cx| {
|
editor_a_main.update_in(cx_a, |editor, window, cx| {
|
||||||
editor.move_to_end(&MoveToEnd, window, cx);
|
editor.move_to_end(&MoveToEnd, window, cx);
|
||||||
|
@ -2747,9 +2726,17 @@ async fn test_lsp_pull_diagnostics(cx_a: &mut TestAppContext, cx_b: &mut TestApp
|
||||||
"After host main.rs edits, the workspace diagnostics pull should follow"
|
"After host main.rs edits, the workspace diagnostics pull should follow"
|
||||||
);
|
);
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
|
let diagnostic_pulls_result_ids = diagnostics_pulls_result_ids.lock().await.len();
|
||||||
|
let workspace_pulls_result_ids = workspace_diagnostics_pulls_result_ids.lock().await.len();
|
||||||
{
|
{
|
||||||
assert_eq!(5, diagnostics_pulls_result_ids.lock().await.len());
|
assert!(
|
||||||
assert_eq!(6, workspace_diagnostics_pulls_result_ids.lock().await.len());
|
diagnostic_pulls_result_ids > 1,
|
||||||
|
"Should have sent result ids when pulling diagnostics"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
workspace_pulls_result_ids > 1,
|
||||||
|
"Should have sent result ids when pulling workspace diagnostics"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fake_language_server
|
fake_language_server
|
||||||
|
@ -2769,12 +2756,14 @@ async fn test_lsp_pull_diagnostics(cx_a: &mut TestAppContext, cx_b: &mut TestApp
|
||||||
"Another workspace diagnostics pull should happen after the diagnostics refresh server request"
|
"Another workspace diagnostics pull should happen after the diagnostics refresh server request"
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert!(
|
||||||
5,
|
diagnostics_pulls_result_ids.lock().await.len() == diagnostic_pulls_result_ids,
|
||||||
diagnostics_pulls_result_ids.lock().await.len(),
|
|
||||||
"Pulls should not happen hence no extra ids should appear"
|
"Pulls should not happen hence no extra ids should appear"
|
||||||
);
|
);
|
||||||
assert_eq!(8, workspace_diagnostics_pulls_result_ids.lock().await.len(),);
|
assert!(
|
||||||
|
workspace_diagnostics_pulls_result_ids.lock().await.len() > workspace_pulls_result_ids,
|
||||||
|
"More workspace diagnostics should be pulled"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
editor_b_lib.update(cx_b, |editor, cx| {
|
editor_b_lib.update(cx_b, |editor, cx| {
|
||||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue