Merge main into fix/test-lint-sleep-polls

This commit is contained in:
dotCooCoo committed 2026-12-01 14:09:10 -08:00
commit 009406a696
8 files changed
+1206 -34

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ pub(crate) fn panel_body(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) {
| "blend"
| "character"
| "color"
| "docInfo"
| "magicWand"
| "openType"
| "paragraph"
+3
View File
@@ -1838,6 +1838,9 @@ fn a_heavy_filter_plugin_runs_from_its_shortcut_as_from_its_menu_item() {
// the key is still running when Cancel stops it, however long the frames take.
let jobs = std::sync::Arc::new(craft::host::ManualJobs::new());
app.host = std::sync::Arc::new(craft::host::Host::builder(app.host.app().clone()).i18n(crate::i18n::shared()).jobs(jobs).build());
// The clock stands still: the run's progress window, which opens once the run is old enough
// and takes the keys, stays closed however slowly the frames run.
app.now_override = Some(0.0);
app.session.allow_plugin_grants_from_requests();
app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
let (at_once, asks) = ("test.UI.heavy_filter-at-once", "test.UI.heavy_filter-asks");
+1
View File
@@ -23,6 +23,7 @@ mod numfields;
mod overprint;
mod paintchips;
pub(crate) mod panel_harness;
mod panel_scroll;
mod pastechords;
mod pathtype;
mod pdfoutput;
+14
View File
@@ -383,6 +383,20 @@ impl Panel {
seen.is_some_and(|r| r.width() >= 0.0 && r.height() >= 0.0)
}
/// The named control the latest frame lays out lowest, where its name finds that control: the control a reader
/// reaches last.
pub(crate) fn lowest(&self) -> Option<String> {
let mut names = self.names();
names.sort();
names.dedup();
names
.into_iter()
.filter_map(|name| self.fixture.by_label(&name).map(|t| (name, t.rect.bottom())))
.filter(|(_, bottom)| bottom.is_finite())
.max_by(|a, b| a.1.total_cmp(&b.1))
.map(|(name, _)| name)
}
/// Whether the control named `name` takes input.
pub(crate) fn enabled(&self, name: &str) -> bool {
!self.fixture.tree().is_disabled_key(self.look(name).node)
+61
View File
@@ -0,0 +1,61 @@
//! Every panel in a dock group shorter than its contents scrolls to its last control (#10262).
use std::cell::RefCell;
use egui::{Ui, pos2, vec2};
use serde_json::json;
use vectorcraft_engine::Session;
use crate::VectorcraftApp;
use crate::tests::panel_harness::Panel;
thread_local! {
/// The panel the harness draws.
static SHOWN: RefCell<String> = const { RefCell::new(String::new()) };
}
fn draw(app: &mut VectorcraftApp, ui: &mut Ui) {
let id = SHOWN.with(|s| s.borrow().clone());
crate::dock::panel_body(app, ui, &id);
}
/// The panels whose last control a short dock group hides and the wheel does not bring into view.
fn unreachable_panels(room_height: f32) -> Vec<String> {
let mut stuck = Vec::new();
for (id, _) in crate::state::all_panels() {
SHOWN.with(|s| *s.borrow_mut() = id.to_owned());
let mut app = VectorcraftApp::new(Session::new(), Default::default());
if let Err(e) = app.run("file.new", json!({"width": 200, "height": 200})) {
panic!("file.new: {e}");
}
// A selected path, so the panels that edit a selection show their controls.
if let Err(e) = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 40})) {
panic!("shape.rectangle: {e}");
}
let mut panel = Panel::new(app, draw);
let Some(last) = panel.lowest() else { continue };
panel.room(vec2(300.0, room_height));
panel.frame();
panel.frame();
if !panel.shows(&last) || panel.in_view(&last) {
continue;
}
for _ in 0..60 {
panel.scroll_at(pos2(150.0, room_height / 2.0), -120.0);
if panel.in_view(&last) {
break;
}
}
if !panel.in_view(&last) {
stuck.push(format!("{id}: {last:?}"));
}
}
stuck
}
#[test]
fn every_panel_in_a_short_dock_group_scrolls_to_its_last_control() {
let mut stuck = unreachable_panels(120.0);
stuck.extend(unreachable_panels(60.0));
assert!(stuck.is_empty(), "panels whose last control the wheel cannot reach: {stuck:?}");
}
+1 -1
View File
@@ -353,7 +353,7 @@ The app decides which cursors exist; whoever draws them works from the list. For
## Test lint
`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on an `assert_eq!` or `assert_ne!` of an expression with itself, such as `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: a test whose only checks are that a value exists or a collection is not empty (`is_ok`, `is_some`, `!is_empty`, `len() > 0`: `only-weak`), `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base <rev>` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow <rule> <reason>` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail.
`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on an `assert_eq!` or `assert_ne!` of an expression with itself, such as `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`), `thread::sleep` in test code (`sleep`), test code that reads Rust source outside the audits listed in `SOURCE_AUDITS` (`reads-source`), and a test that a `cfg` on it or on a `mod` above it excludes from every CI target that builds the crate (`never-run`). `never-run` reports a test only when it can evaluate the `cfg` on every such target; a predicate it does not evaluate, such as a `feature`, counts as unknown, so `#[cfg(all(feature = "gpu", not(feature = "gpu")))]` is not reported. It lists the hits of the other rules without failing: a test whose only checks are that a value exists or a collection is not empty (`is_ok`, `is_some`, `!is_empty`, `len() > 0`: `only-weak`), `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and the hits of `census`, `mirror`, `constant-echo`, `fixture-only` and `exact-pixel`. The base is `--base <rev>` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow <rule> <reason>` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail.
## Tests
+3 -2
View File
@@ -35,8 +35,9 @@ commands:
cursors warn about Cursor values with no entry in crates/tools/src/cursors.toml (never fails)
test-lint [--base <rev>] [--all]
weak tests in the lines changed since the base: fail on self-compares, reasonless
#[ignore] and sleeps; list only is_ok/is_some checks, unguarded .all(), no assertion,
early returns, unset env gates... (xtask/src/test_lint.rs); --all lists every hit
#[ignore], sleeps, reads of Rust source and tests no CI target runs; list only
is_ok/is_some checks, unguarded .all(), no assertion, early returns, unset env
gates, constant echoes, exact pixels... (xtask/src/test_lint.rs); --all lists every hit
by crate and never fails
i18n-report list the strings each language's catalog lacks, shown in English (fails only on a
broken scan; ci runs it too)
+1122 -31
View File
File diff suppressed because it is too large. Load diff