mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
Merge pull request #10242 from dotCooCoo/fix/xtask-test-lint
xtask: test-lint checks the tests a change touches for weak assertions
This commit is contained in:
3 files changed
+4006
-3
No files matched your search
@@ -351,6 +351,10 @@ The app decides which cursors exist; whoever draws them works from the list. For
|
||||
|
||||
`cargo xtask brands` (part of `cargo xtask ci`) fails when user-visible text names another vendor's products or company: string literals in Rust sources (command labels and params docs, menus, panels, MCP tool definitions), `Cargo.toml` descriptions and packaging files. Comments, test files and `#[cfg(test)]` modules are not checked. Say "the reference app" or name the feature itself. A line that must keep an old name, such as an alias that files or preferences from earlier versions still use, or a name another project defines, such as a shared MIME type, carries a `brand-ok` comment. In the Linux desktop entry, whose comments take whole lines, the comment goes on the `#` line just above it; `MARK_ABOVE` in `xtask/src/brands.rs` lists the files that accept a mark there.
|
||||
|
||||
## 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.
|
||||
|
||||
## Tests
|
||||
|
||||
- `cargo xtask test` runs the workspace's unit and integration tests with
|
||||
|
||||
+11
-3
@@ -18,6 +18,7 @@ mod sha256;
|
||||
mod shards;
|
||||
mod stats;
|
||||
mod test262;
|
||||
mod test_lint;
|
||||
mod ui_commands;
|
||||
mod version;
|
||||
mod web_fonts;
|
||||
@@ -32,6 +33,11 @@ commands:
|
||||
assets check that every icon/image/font/asset is attributed in ASSETS.md
|
||||
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]
|
||||
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
|
||||
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
|
||||
@@ -39,7 +45,7 @@ commands:
|
||||
layers enforce the crate dependency layering (plan/architecture.md §3)
|
||||
wasm cargo check --target wasm32-unknown-unknown for the wasm-safe crates, the web app and its plug-in worker
|
||||
test the workspace tests (cargo nextest when installed, else cargo test), then the doctests
|
||||
ci fmt --check, clippy -D warnings, test, doctests, no-bundled-fonts, pdf-deps, assets, brands, cursors (warnings only), ui-commands --check, layers, wasm (stops at first failure)
|
||||
ci fmt --check, clippy -D warnings, test, doctests, no-bundled-fonts, pdf-deps, assets, brands, cursors (warnings only), test-lint, ui-commands --check, layers, wasm (stops at first failure)
|
||||
ci shard shard $GATE_SHARD of $GATE_SHARDS of ci (xtask/src/shards.rs): a test shard runs
|
||||
the tests and doctests of its crates, the last shard the other steps
|
||||
ci warm build what every shard builds, without running it (fills the gate's cache); with
|
||||
@@ -74,6 +80,7 @@ fn main() -> ExitCode {
|
||||
Some("assets") => assets::run(&root()),
|
||||
Some("brands") => brands::run(&root()),
|
||||
Some("cursors") => cursors::run(&root()),
|
||||
Some("test-lint") => test_lint::run(&root(), &rest),
|
||||
Some("i18n-report") => cmd_i18n_report(),
|
||||
Some("ui-commands") => ui_commands::run(&root(), rest.contains(&"--check")),
|
||||
Some("layers") => cmd_layers(),
|
||||
@@ -118,13 +125,13 @@ pub fn root() -> PathBuf {
|
||||
pub fn repo_files(root: &Path) -> Result<Vec<String>, String> {
|
||||
let out = Command::new("git")
|
||||
.current_dir(root)
|
||||
.args(["ls-files", "--cached", "--others", "--exclude-standard"])
|
||||
.args(["ls-files", "-z", "--cached", "--others", "--exclude-standard"])
|
||||
.output()
|
||||
.map_err(|e| format!("git ls-files: {e}"))?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("git ls-files failed: {}", String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
Ok(String::from_utf8_lossy(&out.stdout).lines().filter(|l| root.join(l).exists()).map(str::to_owned).collect())
|
||||
Ok(String::from_utf8_lossy(&out.stdout).split('\0').filter(|l| !l.is_empty() && root.join(l).exists()).map(str::to_owned).collect())
|
||||
}
|
||||
|
||||
/// A `cargo` command (the one running xtask, else `cargo` on the PATH) run in the workspace root.
|
||||
@@ -525,6 +532,7 @@ fn ci_steps() -> Vec<Step> {
|
||||
("assets", Box::new(|| assets::run(&root()))),
|
||||
("brands", Box::new(|| brands::run(&root()))),
|
||||
("cursors", Box::new(|| cursors::run(&root()))),
|
||||
("test-lint", Box::new(|| test_lint::run(&root(), &[]))),
|
||||
("i18n-report", Box::new(cmd_ci_i18n_report)),
|
||||
("ui-commands", Box::new(|| ui_commands::run(&root(), true))),
|
||||
("layers", Box::new(cmd_layers)),
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user