A draw from either generator is never 0, so below(n) reduces one of the
2^64 - 1 values from 1 to 2^64 - 1. The README and the module doc now say
that below(n) is unbiased when n divides 2^64 - 1 (below(3) is), that
otherwise the results from 1 to (2^64 - 1) mod n come from one more state
than the others, and that the bias can be large: on a 64-bit target,
below(2^63 + 1) returns 1 twice as often as 0.
craft-testkit's hostile hammer reads CRAFT_HOSTILE_DIVISOR=N: the unmodified
seed, every N-th truncation and 1/N of the rounds. hostile::divisor() gives the
same value to sweeps written without the hammer; craft-image-codecs' TIFF zoo
and malformed-header sweeps use it, with a different offset per input so the
inputs together still reach every position. Proptests without their own case
count read proptest's PROPTEST_CASES.
The Workspace gate and the media, audio, video and PDF workflows set
CRAFT_HOSTILE_DIVISOR=8 and PROPTEST_CASES=64. The longest of these tests
(craft-media's MXF hostile input, 1,310 s on Windows; craft-pdf's crypt
proptests, up to 257 s; the image-codecs sweeps, 140-162 s) drop to about an
eighth or a quarter. nightly.yml runs the whole workspace on Linux without
either variable, so every case still runs once a day.
The gate's test-input setup moves to scripts/ci-test-inputs.sh, shared by both
workflows; it uses a corpus that is already present.
- A native-only `if`, `while`, `match` or `for` now ends at its body's
closing brace, or at the last block of an `else` chain. A `{` in the
pattern of a `let` (also after `&&` in a chain) or a `for` opens a
struct pattern, so `#[cfg(unix)] if let State::Ready { .. } = s { .. }`
no longer ends at the pattern's brace and leaves its body checked.
- A raw identifier spelled like a keyword (`r#let`, `r#in`, `r#match`)
is read as a name. `mod r#match;` still names `match.rs`.
- predefined_quit reports a qualified path only as
`muda::PredefinedMenuItem` (or `::muda::...`), so
`other_crate::PredefinedMenuItem::quit` is not reported. The plain
name and a `use muda::PredefinedMenuItem as X` rename still are.
- A cfg predicate nested more than 64 levels deep is unknown, so its
item is checked instead of skipped.
- cfg(true) and cfg(false) are read as their values; r#true and
r#false stay option names.
- String values in cfg predicates have their escapes decoded; a string
with an invalid escape is unknown.
- The `:` after a field's name starts its type, so a native-only
`callback: fn(),` field ends at its comma and later fields are checked.
- use<...> is read as a capturing bound, not a declaration, and the
guards keep use paths of at most eight segments of at most 32 bytes,
so a long prefix or name shared by many leaves is not copied into each.
- std_instant finds the modules of a file that a #[path] attribute names
next to that file, separately from a plain load of the same file.
- predefined_quit reports <muda::PredefinedMenuItem>::quit.
- wgsl_float_literals ends line comments and counts lines at every WGSL
line break, and skips digits inside Unicode identifiers.
A native-only `let`, `return` or other statement whose value holds an
`if` or `match` block is now exempt up to its `;`, instead of only to the
nested block's closing brace. A match arm whose value holds a block runs
to its comma. Const blocks and labeled blocks at the head of a statement
or arm end at their closing brace, so the next statement is checked.
A `use` split over lines is reported once, on the line where its path
starts.
Adds tests for paths split by line breaks and comments (CRLF included),
cfg attributes with code before and after them on one line, other time
modules and longer names, literals and labels, and a large source.
Add craft_testkit::rng with XorShift64 (shifts 13, 7, 17) and
XorShift64Star (shifts 12, 25, 27, output multiplied by
0x2545_F491_4F6C_DD1D, state kept unmultiplied). Each has new, next,
below, byte and fill.
- new returns SeedError::ZeroSeed for a seed of 0, which would make
either recurrence return 0 forever.
- below takes one draw modulo the bound; a bound of 0 returns 0 after
one draw, as the DNx and JPEG suites do today.
- byte is the low 8 bits of one draw; fill takes one byte() per output
byte in index order, and an empty slice takes no draw.
The module uses no std-only items and builds for wasm32-unknown-unknown.
Its tests pin the first outputs of both generators for the DNx and JPEG
seeds and compare draws with the generators those suites define. The
README gains the module's description and rows for it in the Origin and
Migration tables.
README item 2, the wgsl_float_literals rustdoc and the boundary test comment now say the
scanner compares each literal's value rounded to f64, so a literal that exceeds the maximum
by less than f64 precision, such as 0x1.fffffe000000001p+127f, is not reported. They also say
0x1.fffffep+127f equals f32::MAX and 3.4028234663852886e38 rounds to it.
rust_sources skips a folder only when its CACHEDIR.TAG starts with the line
Signature: 8a477f597d28d172789f06886806bc55. The doc comment and the crate
README now say so instead of naming any CACHEDIR.TAG file.
std_instant read each file on its own, so `#[cfg(not(target_arch =
"wasm32"))] mod native;` in lib.rs did not stop it from reporting
std::time::Instant in native.rs when both came from one rust_sources
call.
std_instant now first collects every `mod name;` declaration and treats
the file it names as native-only when the declaration is inside an item
whose cfg is false on wasm32-unknown-unknown, along with the files that
file declares. A file that a declaration outside such items also reaches
from a crate root is still checked. Module files are found by rustc's
rules: next to lib.rs, main.rs and mod.rs, in the stem folder of any
other file, below enclosing inline modules, and through #[path] on the
declaration or on an enclosing inline module. Declarations inside more
than 64 inline modules are not followed, so their files are checked.
TestLock is a lock a static can hold (TestLock::new is const). The
thread that holds it can take it again, and it is released when the
last of that thread's guards is dropped, in any order. A panic while
it is held does not block the next holder, and a poisoned internal
mutex is recovered. Guards are not Send.
gpu_lock() is the one lock of the process for GPU tests, and
hold_gpu_lock() keeps it until the calling thread ends; a second call
on the same thread does nothing more. The module is native only and
reads no environment variables.
The lock comes from PhotoCraft's crates/testkit/src/gpu.rs and
DeckCraft's crates/ui-egui/src/gpu_lock.rs, with the thread-held form
from EffectCraft's crates/gpu/src/tests.rs.
a_panicked_holder_does_not_block_the_next_test and holders_take_turns
keep their names; holders_take_turns now waits on channels instead of
sleeping 2 ms.
predefined_quit and std_instant now run on a small Rust lexer instead of
a masked line search:
- Character and byte literals such as '"' no longer open a phantom
string that hides the code after them.
- A Quit call split by tabs or a line break around :: is reported, a
different name such as MyPredefinedMenuItem or quitter is not, and a
use muda::PredefinedMenuItem as X rename is followed.
- std_instant reports std::time::Instant, <m>::Instant where a use binds
m to std::time, and each use that imports std::time::Instant or
std::time::*. A line that also names web_time is still reported, and
an unrelated time::Instant is not.
- cfg attributes are read from code, not from strings or comments, and
evaluated for wasm32-unknown-unknown (all, any, not, unix, windows,
target_* keys). An outer attribute covers the item after it, an inner
one the rest of its module. A predicate that depends on a feature or
test is checked.
wgsl_float_literals skips integer literals, reports hexadecimal floats
above f32::MAX, and checks an h-suffixed float against 65504.
rust_sources does not follow symbolic links, skips folders that hold a
CACHEDIR.TAG file, no longer drops every file when the root itself is
under a folder named tests, and returns an error for a file over 8 MiB,
more than 256 MiB in all or more than 50,000 files.
rust_sources_with_limits takes other limits.
The tests use a scratch folder that is never reused and is removed when
a test panics. The crate is not published, and the root README lists
it.
Add craft-testkit with source guards for platform rules that broke before:
- predefined_quit: flags calls of muda PredefinedMenuItem::quit that bypass dirty document save prompts and window teardown on macOS.
- wgsl_float_literals: scans WGSL shaders using PhotoCraft's decimal float scanner and flags literals exceeding f32 finite range that fail on WebGPU compilers (Tint).
- std_instant: flags lines naming std::time::Instant without web_time in code running on the web, preventing wasm32 runtime panics.
- rust_sources: directory crawler discovering a crate's .rs sources while excluding test files and test directories.