PhotoCraft: An open-source, photo editor written by scratch in pure Rust
CI: run the tests with cargo nextest (#6117)
David Manne22c4ec7ab28
diff --git a/.config/nextest.toml b/.config/nextest.tomlindex 2585577ec..a082d1351 100644--- a/.config/nextest.toml+++ b/.config/nextest.toml@@ -1,5 +1,6 @@# 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).+# binaries. CI runs it with the `ci` profile below (#6117); locally it is optional and `cargo test`+# keeps working (#2204).## cargo nextest run --workspace # all tests except doctests# cargo test --doc --workspace # nextest does not run doctests@@ -13,3 +14,11 @@ 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'++# CI (`--profile ci`, .github/workflows/ci.yml). Stops at the first failure so a red PR frees its+# runner, fails a test that hangs instead of letting it hold the runner, and repeats every failure+# at the end of the log. The default profile's GPU override still applies.+[profile.ci]+fail-fast = true+slow-timeout = { period = "60s", terminate-after = 10 }+failure-output = "immediate-final"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex dfc2564a5..31323da70 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -115,15 +115,24 @@ jobs:if: runner.os == 'Linux'run: cargo fmt --all -- --check+ # cargo-nextest runs the test binaries in parallel (`cargo test` runs them one at a time) and+ # its `ci` profile (.config/nextest.toml) stops at the first failure and fails hung tests.+ - uses: taiki-e/install-action@83ac0ad63c0167e6f06796fab0fce28db1bf3db0 # v2.87.22+ with:+ tool: [email protected]+# `--features heif`: official builds open HEIC photos via the optional photocraft-heif crate.+ # nextest doesn't run doctests, so `cargo test --doc` does, with the same selection.- name: Test- run: cargo test --workspace --locked --features heif+ run: |+ cargo nextest run --workspace --locked --features heif --profile ci+ cargo test --doc --workspace --locked --features heif# The same codecs without the optional decoder: HEIC must stay a clear "not in this build"# error for distributors who leave it out.- name: Test without heifif: runner.os == 'Linux'- run: cargo test -p photocraft-heif -p photocraft-codecs -p photocraft-io --locked+ run: cargo nextest run -p photocraft-heif -p photocraft-codecs -p photocraft-io --locked --profile ci# The same tests built with the optional craft-fonts input (crates/text/build.rs), so the# Japanese font tests that skip without it run here. Linux only. Keep the exact `--workspace@@ -143,7 +152,7 @@ jobs:env:CRAFT_FONTS_DIR: ${{ github.workspace }}/craft-fontsCRAFT_FONTS_REQUIRED: "1"- run: cargo test --workspace --locked --features heif+ run: cargo nextest run --workspace --locked --features heif --profile ci- name: Clippyrun: cargo clippy --workspace --all-targets --locked --features heif -- -D warningsdiff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rsindex f56829c6d..c7b54c887 100644--- a/crates/ui-egui/src/type_tool_tests.rs+++ b/crates/ui-egui/src/type_tool_tests.rs@@ -1288,6 +1288,9 @@ fn font_styles_keep_metadata_names_and_numeric_labels() {#[test]fn postscript_only_style_shows_actual_subfamily() {+ // selected_style reads the engine only once the font scan is done (try_shared). Under nextest+ // this test runs in a process of its own, where nothing else has started the scan, so start it.+ let _ = photocraft_text::shared();let style = photocraft_doc::text::CharStyle { font_family: "Inter".into(), postscript_name: Some("Inter-SemiBold".into()), ..Default::default() };assert_eq!(super::selected_style(&style), "SemiBold");}diff --git a/docs/development.md b/docs/development.mdindex ceb679f5f..3e7f5fb66 100644--- a/docs/development.md+++ b/docs/development.md@@ -59,7 +59,7 @@ cargo nextest run --workspace # parallel across binaries (cargo inscargo 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.+[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 runs it with `--profile ci` (fail-fast, a 10-minute hang timeout), plus `cargo test --doc` for the doctests (#6117); a full `cargo test` stays the final check before a PR.## Fonts (craft-fonts)