mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
xtask: test-lint fails on four rules; all-unguarded skips collections that cannot be empty
Replayed over the last 300 merges of main, all-unguarded failed good
pull requests on collections that cannot be empty. It now leaves out:
- plain locals bound to an array type of a positive length, to a
non-empty array literal or vec![...], or to a literal range followed
only by methods that keep an item (map, iter, rev, collect into a
known collection ...); counts may be consts of the file
- locals filled by a push or insert on every pass of a loop over such a
source
- fields and const or static items the file declares only as arrays of
a positive length
- collections compared with a non-empty literal through such methods,
directly or through a local built from them, and assertions on a
local bound to a count or length
- .windows(k) and .chunks_exact(k) when the collection has k items
Later code that may remove items or replace the collection cancels the
exemption.
Only only-weak, self-compare, ignore-without-reason and sleep fail the
check now. The other rules list their hits on changed lines without
failing. On the same 300 merges, 1 would fail (an only-weak test), and
the 3 all-unguarded hits are tests an empty result passes. On main at
07037afda8, all-unguarded lists 392 hits instead of 433.
This commit is contained in:
1 parent
d9db04748b
commit
25756e1b8d
3 files changed
+1065
-108
No files matched your search
+1
-1
@@ -351,7 +351,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`) fails on tests that a wrong result can pass, in the lines and tests changed since a base: `assert!(….all(…))` with no length or emptiness check, a test whose only checks are `is_ok`, `is_some` or `!is_empty`, `assert_eq!(x, x)`, 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, `#[ignore]` without a reason, an environment variable that no CI leg sets, `thread::sleep` in test code, 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 a test whose only checks are `is_ok`, `is_some` or `!is_empty` (`only-weak`), `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: `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.
|
||||
|
||||
## Tests
|
||||
|
||||
|
||||
+4
-3
@@ -34,9 +34,10 @@ commands:
|
||||
brands check that user-visible text (labels, params docs, MCP, docs, packaging) names no other vendor's products
|
||||
cursors warn about Cursor values with no entry in crates/tools/src/cursors.toml (never fails)
|
||||
test-lint [--base <rev>] [--all]
|
||||
fail on weak tests (unguarded .all(), only is_ok/is_some checks, no assertion, early
|
||||
returns, unset env gates, sleeps...) in the lines changed since the base
|
||||
(xtask/src/test_lint.rs); --all lists every hit by crate and never fails
|
||||
weak tests in the lines changed since the base: fail on only is_ok/is_some checks,
|
||||
self-compares, reasonless #[ignore] and sleeps; list unguarded .all(), no assertion,
|
||||
early returns, unset env gates... (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)
|
||||
ui-commands regenerate crates/mcp/src/ui_catalog.rs from desktop UI_COMMANDS; --check fails on drift
|
||||
|
||||
+1060
-104
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user