Fix slow tests sometimes failing

In some situations we reloaded the workspace in the tests after having reported
to be ready. There's two fixes here:
1. Add a version to the VFS config and include that version in progress reports,
so that we don't think we're done prematurely;
2. Delay status transitions until after changes are applied. Otherwise the last
change during loading can potentially trigger a workspace reload, if it contains
interesting changes.
This commit is contained in:
Florian Diebold
2021-02-12 15:58:29 +01:00
parent dee5aba43a
commit a7387cae2c
6 changed files with 51 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ use std::{
time::{Duration, Instant},
};
use always_assert::always;
use crossbeam_channel::{select, Receiver};
use ide::PrimeCachesProgress;
use ide::{Canceled, FileId};
@@ -186,7 +187,7 @@ impl GlobalState {
log::info!("task queue len: {}", task_queue_len);
}
let prev_status = self.status;
let mut new_status = self.status;
match event {
Event::Lsp(msg) => match msg {
lsp_server::Message::Request(req) => self.on_request(loop_start, req)?,
@@ -298,22 +299,23 @@ impl GlobalState {
}
}
}
vfs::loader::Message::Progress { n_total, n_done } => {
vfs::loader::Message::Progress { n_total, n_done, config_version } => {
always!(config_version <= self.vfs_config_version);
if n_total == 0 {
self.transition(Status::Invalid);
new_status = Status::Invalid;
} else {
let state = if n_done == 0 {
self.transition(Status::Loading);
new_status = Status::Loading;
Progress::Begin
} else if n_done < n_total {
Progress::Report
} else {
assert_eq!(n_done, n_total);
let status = Status::Ready {
new_status = Status::Ready {
partial: self.config.load_out_dirs_from_check()
&& self.workspace_build_data.is_none(),
&& self.workspace_build_data.is_none()
|| config_version < self.vfs_config_version,
};
self.transition(status);
Progress::End
};
self.report_progress(
@@ -398,6 +400,10 @@ impl GlobalState {
}
let state_changed = self.process_changes();
let prev_status = self.status;
if prev_status != new_status {
self.transition(new_status);
}
let is_ready = matches!(self.status, Status::Ready { .. });
if prev_status == Status::Loading && is_ready {
for flycheck in &self.flycheck {