From 3092d3b6f974f438e355adf08c9851cc2d6bb528 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 10 Oct 2026 20:03:30 +0200 Subject: [PATCH] Tests: line-tables-only dev debuginfo, nextest GPU group, faster loop docs (#2204) (#2414) - [profile.dev] debug = "line-tables-only", matching CI's CARGO_PROFILE_DEV_DEBUG; halves link time and PDB size for test binaries. - .config/nextest.toml: optional cargo-nextest runs with the GPU tests capped at 4 concurrent processes (unlimited ones time out in wgpu). - AGENTS.md / docs/development.md: iteration commands (--lib --tests, --test , nextest, doctests separately). CI is unchanged. Co-authored-by: Claude Opus 5.5 (1M context) Co-authored-by: Brandon Thomas --- .config/nextest.toml | 15 +++++++++++++++ AGENTS.md | 2 ++ Cargo.toml | 4 ++++ docs/development.md | 15 +++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 000000000..2585577ec --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,15 @@ +# cargo-nextest (https://nexte.st): runs every test in its own process, in parallel across test +# binaries. Optional for local runs; `cargo test` keeps working and stays what CI runs (#2204). +# +# cargo nextest run --workspace # all tests except doctests +# cargo test --doc --workspace # nextest does not run doctests +# +# GPU tests: each test is its own process here, so the in-process `gpu_lock()` mutexes no longer +# serialize them. Too many concurrent wgpu devices time out (`PollError: ... Wait timed out`), so +# this group caps them at 4. +[test-groups] +gpu = { max-threads = 4 } + +[[profile.default.overrides]] +filter = 'package(photocraft-gpu) | (package(photocraft-ui-egui) & (kind(test) | test(/canvas|gpu|mip|type_tool/)))' +test-group = 'gpu' diff --git a/AGENTS.md b/AGENTS.md index 746b8fb51..d7de9b354 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -99,6 +99,8 @@ cargo xtask perf --quick # if you touched a hot path; `cargo xtask perf --upd cargo xtask test-corpus # if you touched psd, io, codecs, compose, gpu, text or format (or: --changed decides) ``` +While iterating, run less and keep the full commands above as the final gate: `cargo test -p --lib --tests` skips the examples and doctests plain `cargo test` builds every time (ui-egui has 11 examples), and `cargo test -p --test ` runs one integration-test file. `cargo nextest run` runs tests in parallel across binaries; see `docs/development.md` › Faster test loops. + **Test corpora.** Real-file corpora live in `corpus/` (gitignored, never committed), fetched at pinned commits and sha256-verified by `cargo xtask corpus --all`: our Photoshop-authored oracles from https://github.com/storytold/photocraft-corpus plus psd-tools, ag-psd and PngSuite from their upstreams. Pins: `xtask/src/corpus_pins.rs`. The corpus tests are opt-in (cargo feature `corpus`): plain `cargo test` skips them, and with the feature on a missing corpus fails ("run `cargo xtask corpus --all`"). `cargo xtask test-corpus` fetches and runs them all. CI always runs them (the `corpus` job, cached by pin). Never commit corpus files; new oracles go to photocraft-corpus (its `AGENTS.md`), then a pin bump here. Details: `docs/development.md` › Test corpora. Commands must **never panic** on bad input (Rule 9): every `run` closure and the code it calls returns `Err`, not a panic, for any params or document state. New commands come with a graceful-failure test (empty/out-of-range/wrong-type params → `Err`, not a crash). diff --git a/Cargo.toml b/Cargo.toml index 06acab2b6..afcfdd152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,10 @@ opt-level = 2 [profile.dev] opt-level = 1 +# Line tables keep file:line in panic backtraces but drop variable info, which roughly halves link +# time and PDB size for the ~260 test binaries (#2204). CI sets the same through +# CARGO_PROFILE_DEV_DEBUG. To inspect locals in a debugger, build with CARGO_PROFILE_DEV_DEBUG=true. +debug = "line-tables-only" [profile.release] lto = "thin" diff --git a/docs/development.md b/docs/development.md index 85d8f8739..7d2f09bf0 100644 --- a/docs/development.md +++ b/docs/development.md @@ -42,6 +42,21 @@ cargo xtask parity # Photoshop menu cove Image code is slow at `opt-level 0`, so the workspace profile builds dependencies at `opt-level 2`. Use `--release` for anything interactive. +The dev profile builds with `debug = "line-tables-only"`: panic backtraces keep file and line, and test binaries link about twice as fast. To inspect local variables in a debugger, build with `CARGO_PROFILE_DEV_DEBUG=true`. + +### Faster test loops + +Most of a `cargo test` run is linking test binaries and running them one after another. While iterating: + +```sh +cargo test -p --lib --tests # skip examples and doctests (ui-egui has 11 examples) +cargo test -p --test # one integration-test file +cargo nextest run --workspace # parallel across binaries (cargo install cargo-nextest --locked) +cargo test --doc --workspace # nextest does not run doctests +``` + +[cargo-nextest](https://nexte.st) runs each test in its own process. `.config/nextest.toml` puts the GPU tests (`photocraft-gpu`, and ui-egui's integration and canvas/GPU tests) in a group of at most 4 at a time, because each process opens its own wgpu device and the in-process `gpu_lock()` no longer serializes them. On a 32-thread Windows machine the full workspace went from 297 s (`cargo test`) to about 120 s (#2204). Ignored tests run with `cargo nextest run --run-ignored only`. CI still runs `cargo test`, and a full `cargo test` stays the final check before a PR. + ## Fonts (craft-fonts) Font assets shared by the Crafting Apps live in [storytold/craft-fonts](https://github.com/storytold/craft-fonts), never in this repo: don't commit font files here (Inter and JetBrains Mono in `assets/fonts/` are the only exceptions; new fonts go to craft-fonts). The rules are in `craftrules/standards/fonts.md` in a sibling `craftrules` checkout (see below); that repository is not public, so outside contributors can ask a maintainer for the rules that apply to their change.