- reads-source checks the format string of a format!(...) path, so a
format argument ending in .rs is not taken for the file name.
- never-run combines only the mod declarations that load the same file;
a declaration inside another inline module loads a file under that
module's directory.
- exact-pixel treats a comma inside a call's arguments like the closing
parenthesis, so f(rect.min.x, 3) is a coordinate passed on.
- census keeps the polarity of a negation: `!parse(x).is_ok()` is a
rejection, while `!xs.is_empty()` stays a presence check.
- reads-source looks at the last path literal of a read_to_string
argument, so `root.join("fixtures.rs").join("input.json")` is not a hit.
- never-run reads an escaped cfg string value as unknown, takes every
`mod` declaration of a module (`#[cfg(windows)]` and `#[cfg(unix)]`
both count), and ties a change to an attribute only when that
attribute excludes a CI target.
- exact-pixel does not count a coordinate passed to a function.
- docs/development.md says when never-run can decide a cfg.
- never-run reads cfg predicates with comments removed, finds a module
declared inside an inline module of its parent's parent, stops when
several files declare a module with different attributes, and counts a
change to a cfg on a mod declaration in another file against the tests
it turns off. The lines between a module's cfg and the test no longer
count as changes to the test.
- reads-source ignores paths in comments.
- census bounds weak_predicate at 64 levels and does not take a lookup
with an operator before it as a round trip.
- fixture-only treats a for-loop binding that shadows a fixture as
unknown.
- exact-pixel skips ratios and scaled values.
- docs/development.md lists reads-source and never-run as failing rules.
A loop over a table that also calls unwrap_err or expect_err checks that
some inputs are rejected, so it is no longer reported as census. Calls in
failure messages do not count, and a panic! that only enforces success
does not exempt the loop.
An asserting helper called in an .all(...) predicate also counts as a
check, unless a presence check can pass without the helper running
(the other side of an ||). Helpers called with a turbofish are matched
too.
- assert_ne!, debug_assert_ne! and prop_assert_ne! in a table loop are not
round trips.
- A round trip counts only when the compared operand is the parsed or
looked-up entry itself, optionally unwrapped, borrowed or wrapped in
Some(...); parse(..).unwrap().children.len() is a real check.
- An .all(...) presence check over a table is reported only when the whole
condition holds on presence checks: joined by && to a real check it is
not reported, while an || that lets the presence branch pass alone still
is.
- filter_map, take_while, skip_while and map_while pick a subset, as do a
bounded iterator zipped in or returned by flat_map. Adapters inside a
closure on the outer chain do not count.
A new report-only rule, census, lists tests that loop over a whole table
(a SCREAMING_CASE constant, Type::ALL, Type::iter(), or a call named like
a catalog such as presets() or all_swatches()) and assert only that each
entry is present, non-empty, or parses back to itself. Such tests walk
every color, swatch or preset and check a property each entry has by
construction. Loops over a few entries (take, skip, filter, a slice),
loops that call an asserting helper, and comparisons with an expected
value written in the table are not reported.
cargo xtask test-lint --all lists 53 census hits on main.
* SVG import: refuse an SVG the memory can't hold instead of running out
The element limit now follows the installed memory, or the process's
cgroup limit where that is lower: about 8 KB an element, up to the
999,999 elements usvg reads. Past it the SVG is refused with an error
naming the memory, before usvg makes its tree.
Fixes#10165
* Tests: the shared element limit test follows the machine's limit
Moves craft-libs to a5669ed2f, which places overlays in the room of the
monitor the window is on (craft-libs f31beb26d, merged in #4506). The
old room assumed monitors tile the desktop by their size, so on a
landscape monitor to the right of a portrait one the File menu opened
at (726, 442), far from its title, with scroll arrows.
The new pin is craft-libs main just before #4278, whose dialog changes
need VectorCraft test updates that come with a later pin bump.
The new test menu_on_second_monitor opens the File menu with the window
on the landscape monitor at 1x and 1.5x; it fails on the old pin with
the menu at (726, 442).
- Functions and macros declared inside a test no longer count as its
assertions or calls; a call to one still counts as a helper call.
- `should_panic` exempts a test only as an applied attribute:
`#[should_panic]`, or inside `#[cfg_attr(test, ...)]`.
- `only-weak` strips parentheses around the whole condition, so
`assert!((x.is_ok()))` is classified like `assert!(x.is_ok())`.
- `#[ cfg(test)]` and attributes with comments between `#`, `[` and
`cfg` mark test code like the compact form.
test_regions matched only the exact `#[cfg(test)]`, so helpers in a
module under `#[cfg(all(test, windows))]` or
`#[cfg(all(test, not(target_arch = "wasm32")))]` (as in
apps/vectorcraft-web/src/file_drops.rs) were not test code: a sleep in
such a helper passed the check, and its asserting helpers were not found.
A cfg predicate now counts when it is `test` or an `all(...)` with such a
predicate among its arguments, at any depth and with any spacing.
`any(test, ...)`, `not(test)` and `feature = "test"` do not count.
Replayed over the last 300 merges to main, only-weak would have failed
3 merges on 4 hits, and all 4 were tests where an is_ok or is_some check
is the behavior under test (a lease or start file that can be taken
again, a never-panic property test, a label found by a search with the
row's position in its predicate). Of the 39 only-weak hits in the whole
workspace, most are the same kinds: registry and label lookups,
still-imports and never-panic tests.
only-weak now lists its hits without failing, like all-unguarded. The
check fails on self-compare, ignore-without-reason and sleep. With this
change the replay fails 0 of 272 merges that change Rust files.
- The module docs and docs/development.md name the four rules that fail
the check, and describe `only-weak` and `self-compare` by what they
match (`len() > 0`, `assert_ne!`).
- The changed-lines diff passes `--inter-hunk-context=0`, so a clone's
`diff.interHunkContext` cannot mark unchanged lines between two edits.
- Single-letter workflow variables count as set.
- Test names with non-ASCII letters are read whole.
- An allow in a block comment needs a reason before `*/`.
- `all-unguarded` uses only a binding still in scope at the assertion,
treats a `const` declared with different values as unknown, and drops
a counted local once its collection may shrink or be replaced.
- `only-weak` ignores `unwrap_err`, `expect_err` and `panic!` in failure
messages.
- `self-compare` leaves out operands that call a method returning the
next value each time (`next`, `pop_front`, `recv` and others).
- An `ignore-without-reason` span reaches the attribute's `]`, so a
change to a reason on the next line counts.
- Changed mode decodes `+++` labels (the tab after a path with a space,
C-quoted paths), and the file inventories read `git ls-files -z`, so
files with spaces, quotes or non-ASCII names are linted.
- `#[test_case(1; "one")]` arguments and other attributes no longer end
the item before its `fn`, and an inner `#![...]` attribute before the
first test is not part of that test's span.
- A helper name counts as asserting only when every function of that
name in the crate's test code asserts.
- `.stdout(file)` and other stream builder calls count as configuration
whatever their argument, so `exit-status-only` still reports.
- A `return` inside `async { ... }` or `async move { ... }` ends the
future, not the test, for `early-return`.
- `env-gate-unset` looks for setters in code only, not in string
literals, ignores `echo` and `printf` output that is not written to
`$GITHUB_ENV`, and its span reaches the variable name on a later line.
- `sleep` reports `thread::sleep`, or a bare `sleep(...)` only where the
file imports `thread::sleep`.
- `reads-source` checks raw string paths in `include_str!` and
`ends_with`.
- A test pins that a collection changed after its `assert_eq!` loses
that guard for `all-unguarded`.
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.
`cargo xtask test-lint` reads the Rust files changed since a base and
fails on tests that a wrong result can pass: `.all()` with no length or
emptiness check, only is_ok/is_some/non-empty checks, `assert_eq!(x, x)`,
a process test that checks only the exit status, 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 listed source audits.
Only hits on changed lines, or in a test with a changed line for the
rules about a whole test, fail it; older hits in the same files are
counted. The base is --base or TEST_LINT_BASE, the first parent of the
checked-out commit in CI (a shallow checkout fetches it), else the merge
base with upstream/main or origin/main. `// test-lint: allow <rule>
<reason>` exempts a line. `--all` lists every hit by crate and rule and
does not fail. `cargo xtask ci` runs it after cursors, so it runs in the
checks shard.
craft-libs main at 2680a3b3f adds #4364 (its egui pin moves to
07c20531, which VectorCraft's egui lines now match), #4425, #4409, #4414,
#4406, #4349, #4393, #4392, #4398, #4415, #4411, #4402, #4400, #4417,
#4399, #4407, #4375, #4428 and #4451. winit stays at 0dfcec0e, the rev
craft-libs pins. craft-nightly and craft-web-api move with the other
craft-libs crates, and xtask pdf-deps checks the new rev. Cargo.lock:
epaint_default_fonts now depends on brotli 9.1.3 and brotli-decompressor
6.3.2.
Test selection in the shared gate (`select-tests`) runs the tests of the
crates a change reaches. A crate that compiles or reads another crate's
files lists them under `[package.metadata.craft]` in its Cargo.toml:
- vectorcraft-plugins sets `reads-every-member = true`, because
`tests/grant_sites.rs` reads the sources of every crate.
- vectorcraft-cli, vectorcraft-affinity, vectorcraft-engine,
vectorcraft-mcp, vectorcraft-ui-egui and xtask list the files they
compile through `#[path]` or read with `include_str!`/`include_bytes!`
or from `CARGO_MANIFEST_DIR`.
Cargo ignores this table. Only the gate's selection step reads it, and that
step fails when a read is missing from it.
The Layers panel built its row order again on every selection change:
each change made a new Tracked for the rows, and the rows reported no
order revision, so the panel asked every row for the rows inside it
(7 calls for the 6 rows of the new test's document).
- LayerRows reports LayerTree::order_revision: a hash of the document,
the open rows, Show Layers Only and the isolated node. The selection,
the highlighted rows, the current layer and the names are not in it.
- refresh_rows writes new rows into the kept Tracked while the document
(uid and revert count) stays the same, and makes a new Tracked for
another document or after File > Revert.
- The craft-libs pin moves from 186a229c8 to aa7e668ec, current
craft-libs main, which has craft-libs#4319 (LayerTree::order_revision).
The winit rev moves to 0dfcec0eb, as craft-libs pins it; egui stays
at 14c39fed1. xtask pdf-deps checks the new rev. craft-nightly keeps
the rev main pins it at.
Two tests failed on the new craft-libs:
- canvas::tests::a_selection_drag_draws_its_marks_in_the_frame_the_pointer_moves:
since craft-libs#4143 a frame runs one pass where it ran two, and the
bounding box, Live Corners, hollow corners and shape widgets were drawn
before the tool host took the frame's pointer event, so the box showed
at the old corner. They are now drawn after it, into paint slots kept
in their old order.
- tests::nativemenu::applying_a_dialog_preview_reads_the_menus: since
craft-libs#4350 the closed dialog's angle field gives up the keys one
frame sooner, so the menus are sent again without the text-editing
gate within the frames the test ran. The test now waits for the gate
and counts the read and that send apart.
`cargo xtask ci warm` built each test shard with `--lib --bins --no-run`,
while the shards run `--lib --bins --tests`. The warm build left out the
integration test executables the shards then build, and cargo warned
`unused dependency vectorcraft-testkit` for apps/vectorcraft-cli, whose
only use is in tests/it.
The warm build now selects the same targets as the test shards, through
one `TARGETS` list that both use.
- apps/vectorcraft-web: egui_extras moves to the wasm32 dependencies.
Its only use is src/web.rs, which builds only for wasm32, so cargo
reported it unused on native builds.
- apps/vectorcraft: drop the socket2 dev-dependency. Its loopback
tests left control_server in #8800 and nothing uses it now.
- xtask: the doc-test steps (`cargo xtask ci shard` and the workspace
doctests) leave out packages whose only library target is a cdylib,
dylib or staticlib. Cargo printed "doc tests are not supported for
crate type(s) `cdylib`" for vectorcraft-thumbnail-handler. Packages
without a library stay selected, so the shard keeps its features.
Warnings on the build host, before and after (cache warm shard
`cargo test -p vectorcraft-mcp -p vectorcraft -p vectorcraft-cli
-p vectorcraft-web -p xtask --lib --bins --no-run` on a fresh build, and
`cargo test -p vectorcraft-thumbnail-handler --doc`): 4 before, 1 after.
The one left is `vectorcraft-testkit` in apps/vectorcraft-cli: only the
integration tests use it, and the warm step builds only library and
binary tests.
Each ui-egui part ran its pinned tests with --test-threads 3 beside its
counted share with --test-threads 1. On the 4-CPU runners the pinned
tests finished in about 40 s, and the counted share of about 2,640 tests
then ran on one thread for 9 to 12 minutes (run 46267439238).
A part now runs its counted share and then its pinned tests, one after
the other, each with nextest's default thread count. The help F1 test
moves to part 1's pinned list, which leaves the two parts with closer
test totals.
vectorcraft-ui-egui's tests were one leg that set the pull request run's
length (33.2 min median over 20 runs: about 19 min compiling and 11.9 min
running 5,288 tests). The gate now has six legs. Shards 1 and 2 each
build vectorcraft-ui-egui's tests and run half of them with nextest's
count partition. Each part also runs its own pinned slow tests, so the
slowest tests do not land on one leg. Part 1 alone runs the doctests and
the i18n report, and `cargo xtask ci warm` builds the split once.
Before running, a part lists the tests and stops with an error when a
pinned test name no longer exists. The xtask shard tests check that
every test of a split runs on exactly one part.
The nightly signing policy and its preparation doc list the new job
names (`test N/6`).
`cargo xtask ci warm` builds only shard GATE_SHARD of GATE_SHARDS when the gate sets them, and
every shard when neither is set; one set without the other, a non-number, a count other than the
shard count, or a shard out of range is an error. ci.yml turns on the gate's `warm-split`, so
main's warm runs as five `cache warm <k>/5` legs and a `cache warm` leg that saves the entry.
The cold-cache cleanup waits for the split legs before it times the saving leg's start, and fails
when a split leg fails. The cache-prune watch and both jobs' timeouts cover a split leg followed
by the saving leg.
Keep the native and web craft-libs pins, Cargo.lock and PDF source checks on 57c8c8d4. Preserve the matching egui pin. Consult the shared Standard-mode chrome state for visibility and for show-panel requests; the dock already honors that state when drawing.
Keep native and web manifests, the lockfile, and the PDF source guard on the same craft-libs revision. Align the egui patch revision with craft-libs to retain one crate source.
Every craft-libs crate moves from f762f98a to 81bca5c8e2 (craft-libs
main). The new rev adds the title bar's item gap, docking of part of a
collapsed column, the tool rail's footer rule, disabled accessibility
nodes that ignore actions, and built-in themes that load without a
cycle search. VectorCraft builds on it without other changes.
- Every craft-libs crate moves from 610c86792a to f762f98a (craft-libs
main), which adds the fixed corner-widget inset, the ruler corner's
plus, popover padding, and a native window's move recorded once.
- The status bar's Zoom field uses ZoomField::status_bar, so it draws
without an outline in the status bar's look.
- The Rotate View compass is placed in CanvasScrollbars::clear_of
instead of a copy of the scroll bars' sizes.
- The tools' corner-widget inset is public, and a test holds it equal
to CornerWidgets::INSET, the inset the canvas draws the widgets at.
Every storytold/craft-libs crate and the hayro, krilla and linesweeper
patches move from 51fcc3b041 to 610c86792a, the head of craft-libs main.
xtask pdf-deps expects the new rev.
The new apps/vectorcraft-thumbnail-handler crate builds
vectorcraft_thumbnail_handler.dll, a thumbnail handler (IThumbnailProvider
with IInitializeWithStream) for .vectorcraft, .drawcraft and .vctemplate
files. Explorer passes it the file's bytes. It writes them to a file in
%USERPROFILE%\AppData\LocalLow\VectorCraft\Thumbnails (the temp folder when
that can't be made), runs `vectorcraft-cli thumbnail --size N` from the DLL's
folder on that file, and returns the PNG as a top-down 32-bit bitmap with
premultiplied alpha, at most 1024 pixels on its longer side. A file larger
than 256 MiB, a failed run, or a run longer than 25 seconds returns an error,
and Explorer shows the file's icon. Explorer gives the handler the file's
bytes and not its path, so a linked image found only relative to the
document's folder shows the preview saved with it.
`regsvr32 vectorcraft_thumbnail_handler.dll` registers the handler for the
current user under HKCU\Software\Classes, and `regsvr32 /u` removes the class
key and each extension's ShellEx key that names it. The Windows packages do
not build, ship or register the DLL yet.
The COM code is Windows-only and has a module-scoped unsafe_code allowance.
The registry values, the stream limit, the PNG conversion and the
vectorcraft-cli run build on every system, and their tests run in CI.
The plug-in runtime keeps main's JavaScript plug-ins beside the web worker's module bytes and checked loads: a JavaScript plug-in's bundle is kept for the worker like a module, and load_checked loads it from its bundle.