mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 04:52:54 -05:00
The `sleep` rule reported every `thread::sleep` in test code, so 24 of the
30 hits across the workspace were the pause of a loop that waits for a
condition (a search's progress, a flag's `load`, a tool's `poll`) with a
long deadline, or a spawned thread that opens a gate after 10 s in case
the test never does. None of those make a test pass or fail on time.
The rule now leaves out:
- a sleep in a `while` or `loop` whose condition or body calls a function
or method other than one that reads or converts a time, also when the
sleep sits under an `if` or `match` inside that loop;
- a sleep in a closure passed to `spawn` when the call is a whole
statement, so the test drops the thread's handle.
A loop that only waits for the clock (`elapsed`, `as_millis` and other
`Duration` reads), a counted loop, a `for` loop, a sleep under an `if`
outside a loop, and a spawned thread whose handle is kept, returned,
passed on or joined are still reported. Macros such as `println!` in a
loop do not count as a condition. The loop's head is read as a whole
statement, so braces inside it, as in `json!({})`, do not cut it short.
`cargo xtask test-lint --all` now lists 6 sleep hits instead of 30; each
of the 6 delays a gate or a poll that the test's result depends on.