Merge branch 't3/fix-linux-ci-failures'

This commit is contained in:
swaits committed 2026-11-20 22:43:10 -07:00
commit 40d818fb5e
18 files changed
+238 -39

No files matched your search

+4 -3
View File
@@ -7,9 +7,10 @@
//! when every one of them has ended; and a job that must not be cut
//! off (an owner's change to the books) holds the tab and the window
//! open until it is done.
//! SOURCE: plan/p15-app-and-relay.md 3.2 (closing a tab ends what the tab
//! started); WB-GUI-2 (the viewer never abandons a change to the
//! books).
//! SOURCE: plan/p15-app-and-relay.md 3.2 (D-78: a tab per open company,
//! and what the tab started ends with it); CONVENTION (a change
//! an owner has begun on the books is never cut off half-way: the
//! tab and the window wait for it).
//! INVARIANTS:
//! 1. Every thread started through a [`Spawner`] is counted from before
//! it starts until it has ended, however it ends (a panic too): the
+4 -2
View File
@@ -176,8 +176,10 @@ impl TabBar {
// when they don't fit, the "+" stays at the right edge
// and the tabs scroll.
let widths: Vec<f32> = tabs.iter().map(|t| tab_width(ui, t)).collect();
let total: f32 =
widths.iter().sum::<f32>() + widths.len().saturating_sub(1) as f32 * TAB_GAP;
// A fold, not `sum`: the kernel-only check refuses an
// `Iterator::sum` of any type, and these are widths.
let total: f32 = widths.iter().fold(0.0, |w, t| w + t)
+ widths.len().saturating_sub(1) as f32 * TAB_GAP;
let room = (ui.available_width() - PLUS_W - PLUS_GAP).max(0.0);
let strip_w = total.min(room);
let strip = egui::Rect::from_min_size(bar.min, vec2(strip_w, bar.height()));
+9 -4
View File
@@ -104,6 +104,7 @@ const FOOTERS: [Footer; 9] = [
/// menu), about 560 events and 110 stored receipts. Removed when dropped.
struct Fixture {
_dir: tempfile::TempDir,
_plain_dir: tempfile::TempDir,
root: PathBuf,
plain: PathBuf,
}
@@ -153,15 +154,19 @@ impl Fixture {
std::fs::create_dir_all(&root).unwrap();
fill(&root);
// The same books outside the root: no Books menu.
let plain = tempfile::Builder::new()
// Outside a data root a company's badge hue is chosen from its
// folder's name (company.rs `hue_key`), so that folder has a fixed
// name here, never the temporary folder's random one: the same
// picture on every machine and every run.
let plain_dir = tempfile::Builder::new()
.prefix("wb-gui-sidenav-plain-")
.tempdir()
.unwrap()
.keep();
let plain_book = plain.join("books-data");
.unwrap();
let plain_book = plain_dir.path().join("wanderland-copy").join("books-data");
copy_dir(&root, &plain_book);
Fixture {
_dir: dir,
_plain_dir: plain_dir,
root,
plain: plain_book,
}
@@ -0,0 +1 @@
264f46e9e8e6513b
@@ -0,0 +1 @@
3a01e3d1c17e7a42
@@ -0,0 +1 @@
d3c3cc6f9e97b02b
@@ -0,0 +1 @@
19867322b240d3af
@@ -0,0 +1 @@
36b4501433dfff25
@@ -0,0 +1 @@
216c4495455951ef
@@ -0,0 +1 @@
e81f5a809e024c55
@@ -0,0 +1 @@
aeace623f1babf2b
@@ -0,0 +1 @@
057c55da25ed99a6
@@ -0,0 +1 @@
43e2533dd7ebc46b
+134 -7
View File
@@ -89,10 +89,12 @@ struct Co {
impl World {
fn new() -> World {
let dir = tempfile::Builder::new()
.prefix("wb-gui-tabs-")
.tempdir()
.unwrap();
World::named("wb-gui-tabs-")
}
/// A world whose temporary folder's name starts with `prefix`.
fn named(prefix: &str) -> World {
let dir = tempfile::Builder::new().prefix(prefix).tempdir().unwrap();
let home = dir.path().join("home");
std::fs::create_dir_all(&home).unwrap();
let root = dir.path().join("root");
@@ -1298,11 +1300,101 @@ fn every_tab_never_writes_into_its_books_in_front_or_not() {
// ---- 8: how the bar looks ----------------------------------------------------
/// Pixels compared where there is a renderer; tolerant of antialiasing
/// (as the sidebar's are: sidenav.rs).
/// A shape in words, without where its glyphs happen to lie in egui's font
/// atlas: that depends on which text this process laid out first (other
/// tests, in other threads), and no picture shows it. Positions, colours,
/// the text and each glyph's place are all here.
fn describe(shape: &egui::epaint::Shape) -> String {
use egui::epaint::Shape;
match shape {
Shape::Text(t) => {
let mut out = format!(
"Text pos={:?} under={:?} fallback={:?} over={:?} opacity={:?} angle={:?} text={:?}",
t.pos,
t.underline,
t.fallback_color,
t.override_text_color,
t.opacity_factor,
t.angle,
t.galley.job.text,
);
for placed in &t.galley.rows {
out.push_str(&format!(" row@{:?} size={:?}", placed.pos, placed.row.size));
for g in &placed.row.glyphs {
out.push_str(&format!(" {}@{:?}+{:?}", g.chr, g.pos, g.advance_width));
}
for v in &placed.row.visuals.mesh.vertices {
out.push_str(&format!(" v{:?}{:?}", v.pos, v.color));
}
}
out
}
Shape::Vec(v) => v.iter().map(describe).collect::<Vec<_>>().join(" | "),
Shape::Mesh(m) => {
let mut out = String::from("Mesh");
for v in &m.vertices {
out.push_str(&format!(" v{:?}{:?}", v.pos, v.color));
}
out
}
other => format!("{other:?}"),
}
}
/// The shapes the window paints where it can be seen: those whose clip
/// reaches into the window. (The page under a short bar is laid out far
/// below it and holds the time now, "Nov 21 2026 04:26 UTC", which no
/// picture shows: it is clipped away.)
fn shown_shapes(h: &Harness<'_, App>) -> Vec<String> {
let screen = h.ctx.content_rect();
h.output()
.shapes
.iter()
.filter(|s| s.clip_rect.intersects(screen))
.map(|s| format!("{:?} {}", s.clip_rect, describe(&s.shape)))
.collect()
}
/// A hash of every shape the window paints where it can be seen (FNV-1a
/// over their debug form): the same shapes paint the same pixels, on any
/// renderer. What the picture shows (colours, text and where each lies) is
/// in them; how a renderer rasterizes their edges is not.
fn shapes_of(h: &Harness<'_, App>) -> u64 {
let mut hash: u64 = 0xcbf2_9ce4_8422_2325;
for shape in shown_shapes(h) {
for b in shape.bytes() {
hash ^= b as u64;
hash = hash.wrapping_mul(0x100_0000_01b3);
}
}
hash
}
/// The look of the window, compared as sidenav.rs compares its sidebar's:
/// the shapes painted are the check everywhere
/// (`tests/snapshots/<name>.shapes`; `TABS_BLESS=1` writes them), for
/// another renderer rasterizes the same shapes differently (CI's software
/// one differs from a GPU in antialiasing, by thousands of faint pixels
/// and some dozens of strong ones along glyph edges). The pixels
/// (`tests/snapshots/<name>.png`, tolerant of antialiasing) are compared
/// as well on the machine that made them and any with its renderer:
/// `TABS_PIXELS=1`.
fn picture(h: &mut Harness<'_, App>, name: &str) {
let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/snapshots");
let file = dir.join(format!("{name}.shapes"));
let shapes = format!("{:016x}", shapes_of(h));
if std::env::var("TABS_BLESS").is_ok() {
std::fs::write(&file, format!("{shapes}\n")).unwrap();
} else {
let want = std::fs::read_to_string(&file)
.unwrap_or_else(|e| panic!("{}: {e} (TABS_BLESS=1 writes it)", file.display()));
assert_eq!(shapes, want.trim(), "the shapes of {name} changed");
}
if std::env::var("TABS_PIXELS").is_err() {
return;
}
if h.render().is_err() {
eprintln!("no renderer: {name} not compared");
eprintln!("no renderer: {name} pixels not compared");
return;
}
let options = egui_kittest::SnapshotOptions::new()
@@ -1390,6 +1482,41 @@ fn the_tab_bar_with_one_two_and_many_tabs() {
}
}
/// What the window shows depends on the books and the theme alone: not on
/// the name of the temporary folder they sit in, the clock, or the
/// machine. The same companies made in two worlds whose folders are named
/// unlike paint the same shapes and the same pixels (where there is a
/// renderer), with the badge hue chosen from the id of the books.
#[test]
fn the_bar_is_the_same_from_differently_named_folders() {
let names = ["Wanderland Labs LLC", "Fernhill Studio"];
let mut seen: Vec<(u64, Option<Vec<u8>>, Vec<String>)> = Vec::new();
for (prefix, dark) in [
("a-", false),
("zzzz-a-much-longer-name-", false),
("a-", true),
("zzzz-a-much-longer-name-", true),
] {
let w = World::named(prefix);
let mut h = shown(&w, &names, dark, BAR_SIZE);
let keys: Vec<String> = (0..names.len())
.map(|i| h.state().views()[i].hue_key())
.collect();
let pixels = h.render().ok().map(|img| img.into_raw());
seen.push((shapes_of(&h), pixels, keys));
}
for pair in [(0, 1), (2, 3)] {
let (a, b) = (&seen[pair.0], &seen[pair.1]);
assert_eq!(a.2, ["co-0", "co-1"], "a company's hue key is its book id");
assert_eq!(
a.2, b.2,
"the hue key is the book id, not the folder's name"
);
assert_eq!(a.0, b.0, "the shapes differ with the folder's name");
assert!(a.1 == b.1, "the pixels differ with the folder's name");
}
}
#[test]
fn the_empty_window_and_the_plus_list() {
for dark in [false, true] {
+1 -1
View File
@@ -337,7 +337,7 @@ impl Git {
}
/// This git, sharing `sink` for the lock files it deals with
/// (INVARIANT 5), which the caller takes with [`take_lock_notes`]:
/// (INVARIANT 5), which the caller takes with [`Self::take_lock_notes`]:
/// every git made from the same sink reports into it.
#[must_use]
pub fn with_lock_notes(mut self, sink: LockNotes) -> Self {