Skip to content

Commit 9bfbb07

Browse files
committed
adding a warmup request
1 parent 45afd98 commit 9bfbb07

File tree

1 file changed

+16
-5
lines changed
  • crates/rust-analyzer/tests/slow-tests

1 file changed

+16
-5
lines changed

crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -735,18 +735,29 @@ fn main() {
735735
.server()
736736
.wait_until_workspace_is_loaded();
737737

738-
// For some reason, `wait_until_workspace_is_loaded` doesn't wait for loading non rs
739-
// files, so here we sleep to make sure test will pass
740-
sleep(Duration::from_secs(1));
741738

742739
let checker = |line, hover: &str| {
743-
let res = server.send_request::<HoverRequest>(HoverParams {
740+
let params = HoverParams {
744741
text_document_position_params: TextDocumentPositionParams::new(
745742
server.doc_id("src/main.rs"),
746743
Position::new(line, 10),
747744
),
748745
work_done_progress_params: Default::default(),
749-
});
746+
};
747+
748+
749+
// This hover request will trigger the macro expanding, which will ask
750+
// the handle to watch the missing file. Answer of the actual hover request
751+
// might become ready before the file is being read. By sending a warmup
752+
// request we make sure that this race condition won't make problem for
753+
// this test.
754+
//
755+
// In practice this is not a problem because other things like inlayHint will
756+
// trigger macro expansion.
757+
server.send_request::<HoverRequest>(params.clone());
758+
sleep(Duration::from_millis(1));
759+
760+
let res = server.send_request::<HoverRequest>(params);
750761
let res = res.to_string();
751762
assert!(
752763
res.contains(hover),

0 commit comments

Comments
 (0)