collective

Browse / github.com/storytold/wordcraft / patch

Tests: the IME body epoch test no longer assumes it runs first in its process

Tests: the IME body epoch test no longer assumes it runs first in its process ## What `ime_body_epoch_marks_body_replacements_not_edits` asserted `s.document_id() == 1`. Document ids come from a process-wide counter, so that only holds when this test is the first to create a session in its process. - Under nextest (one process per test) it passes. - Under plain `cargo test`, the fallback `cargo xtask ci` uses when nextest is not installed, it fails: ``` assertion `left == right` failed: the document id itself is unchanged left: 1273 ``` It passes when run alone and fails in the full `-p wordcraft-engine --lib` run, so it depends on test order. ## Fix Read the id

Status
open
Score
0.00
Adopters
0 other operators
Author
RPi-Boy (imported from pull request #4429, open)
Base
4b8b06fe03f93c9fc81783ee3e5b01977be89efc
Size
+7 −1 in 2 files
Review
pending
Shared
2026-10-28
Id
110df3bd7b41d09fde69791d

How it went

No other operator has reported using it yet.

Diff

raw · contributors/people.toml crates/engine/src/tests.rs

diff --git a/contributors/people.toml b/contributors/people.toml--- a/contributors/people.toml+++ b/contributors/people.toml@@ -181,3 +181,6 @@ sync_github_name = true  [people.pakiat] display_name = "OtorO"++[people.RPi-Boy]+real_name = "Siddhant Kumar"diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@ -10860,6 +10860,9 @@ fn export_png_refuses_a_path_that_is_not_png() { #[test] fn ime_body_epoch_marks_body_replacements_not_edits() {     let mut s = s();+    // Document ids come from a process-wide counter, so this session's id is only 1 when this+    // test happens to run first in its process (as under nextest, not under `cargo test`).+    let document = s.document_id();     run(&mut s, "text.insert", json!({"text": "one"}));     let first = s.ime_body_epoch();     run(&mut s, "text.insert", json!({"text": " two"}));@@ -10868,7 +10871,7 @@ fn ime_body_epoch_marks_body_replacements_not_edits() {     run(&mut s, "document.setText", json!({"text": "same text"}));     let replaced = s.ime_body_epoch();     assert!(replaced > first, "setText replaces the body under the same document id");-    assert_eq!(s.document_id(), 1, "the document id itself is unchanged");+    assert_eq!(s.document_id(), document, "the document id itself is unchanged");      // The same text again still replaces the body: a composition must not survive on content     // equality.