Tests: the autosave scenario crashes once its autosave has landed (#10690) (#10694)

* Tests: the autosave scenario crashes once its autosave has landed (#10690)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Tests: the autosave scenario crashes once its autosave has landed (#10690)

s25_autosave_recovery 'crashed' right after the extrude; under load the
autosave of it, written on a worker thread, had not landed, so the next
launch recovered the earlier autosave without the body (step 16).

The harness's crash restart now runs frames, bounded, until the active
autosave has caught up (Autosaver::caught_up: no write running and the
last autosave holds the design as it is). The app's own ticks still do
the writing, so an autosave that stopped writing still fails the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
austin62jake
2026-11-02 00:09:03 +00:00
committed by GitHub
parent af54b09bb1
commit 75c46dad7b
2 changed files with 22 additions and 0 deletions
+8
View File
@@ -283,6 +283,14 @@ impl Autosaver {
Ok(true)
}
/// Whether the last autosave holds `s` as it is now, with no write still running: what a
/// crash now would leave for the next launch to offer. A finished write counts once a
/// [`Self::tick`] has taken its outcome.
pub fn caught_up(&self, s: &Session) -> bool {
self.writing.is_none()
&& self.last.as_ref().is_some_and(|(doc, visibility)| (Arc::ptr_eq(doc, &s.doc) || **doc == *s.doc) && *visibility == s.visibility)
}
/// Autosave when the interval has passed, or right away after a big operation. The design
/// is written on a worker thread; true when this call started a write.
pub fn tick(&mut self, s: &Session, big: bool) -> Result<bool> {
+14
View File
@@ -595,6 +595,20 @@ impl Harness {
} else if let Some(how) = s.get("restart").and_then(Value::as_str) {
// "crash": the app dies (its autosave lock goes with it, the entry stays);
// "close": it closes normally. Then a new app starts on the same folders.
if how == "crash" {
// The work so far is autosaved before the crash: the write runs on a worker
// thread, which a loaded machine had not finished (#10690). The autosave's
// own ticks write it; a bounded wait, so an autosave that stopped writing
// still fails the recovery that follows.
for _ in 0..600 {
let caught_up = self.app.autosave.as_ref().and_then(|a| a.active.as_ref()).is_none_or(|a| a.caught_up(&self.app.session));
if caught_up {
break;
}
std::thread::sleep(std::time::Duration::from_millis(5));
self.frames(1);
}
}
let mut old = std::mem::replace(&mut self.app, SolveApp::new(Session::default(), Services::default()));
if how == "close" {
crate::recovery_ui::close(&mut old);