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

@ -32,6 +32,9 @@ pub struct Directories {
/// [`Handle`]'s configuration.
#[derive(Debug)]
pub struct Config {
/// Version number to associate progress updates to the right config
/// version.
pub version: u32,
/// Set of initially loaded files.
pub load: Vec<Entry>,
/// Index of watched entries in `load`.
@ -45,7 +48,7 @@ pub enum Message {
/// Indicate a gradual progress.
///
/// This is supposed to be the number of loaded files.
Progress { n_total: usize, n_done: usize },
Progress { n_total: usize, n_done: usize, config_version: u32 },
/// The handle loaded the following files' content.
Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
}
@ -196,10 +199,11 @@ impl fmt::Debug for Message {
Message::Loaded { files } => {
f.debug_struct("Loaded").field("n_files", &files.len()).finish()
}
Message::Progress { n_total, n_done } => f
Message::Progress { n_total, n_done, config_version } => f
.debug_struct("Progress")
.field("n_total", n_total)
.field("n_done", n_done)
.field("config_version", config_version)
.finish(),
}
}