Commit Graph
40 Commits
Author SHA1 Message Date
dotCooCoo dc2e7e8a54 Merge main into feat/craft-testkit-guards 2026-11-25 15:09:52 -08:00
dotCooCoo c48164d045 craft-testkit: skip brace-delimited macro input in predefined_quit
A macro's input in braces, `m! { ... }`, is skipped like one in
parentheses or brackets, so a `mod` or `extern crate` written there no
longer carries a crate root's extern prelude names to other files.
2026-11-24 00:04:42 -08:00
dotCooCoo c6b28caf8e craft-testkit: skip mod declarations in macro input and nested src roots loaded as modules
predefined_quit no longer follows a `mod` declaration in a macro's
input, an attribute or a `macro_rules!` body when it carries a crate
root's extern prelude names to other files. A `src/lib.rs` or
`src/main.rs` below a package's `src` folder that a declaration loads
is read as a module, not as a crate root of its own.
2026-11-24 00:01:22 -08:00
dotCooCoo ba150c85dc craft-testkit: keep extern crate in argument blocks and module target folders in their package
An `extern crate` in a block inside a call's arguments or an array is a
real declaration, so predefined_quit now reads it. The tokens skipped are
a macro's input in parentheses or brackets, an attribute's input and the
body of a `macro_rules!` definition.

A file in a `tests`, `bin`, `examples` or `benches` folder inside a known
package is a crate root only where cargo_target places it, so a module
that a `#[path]` attribute loads from `src/foo/tests/` no longer adds its
`extern crate` names to the crate's extern prelude.
2026-11-23 23:56:42 -08:00
dotCooCoo 99cdde8d71 craft-testkit: read target folders at their place in a known package only
With a package folder found among the scanned files, `cargo_target`
accepts only Cargo's own target places below it (`build.rs`,
`src/bin/*.rs`, `src/bin/*/main.rs`, and the same in `tests`, `examples`
and `benches`), so `src/foo/tests/helper.rs` and `src/foo/src/bin/x.rs`
stay modules. A folder that holds files directly in `src/bin` is also a
package folder, unless it is inside the `src` folder of a package with a
`src/lib.rs` or `src/main.rs`, so a binary-only package keeps its binaries
as crate roots.
2026-11-19 21:49:17 -08:00
dotCooCoo 1b5bcc24f0 craft-testkit: predefined_quit skips never-compiled and macro-input root aliases
- A `mod` or `extern crate` declaration in an item whose `cfg` is false on
  every configuration (`cfg(any())`, `cfg(false)`, `cfg(not(all()))`) no
  longer carries a crate root's `extern crate muda as m;` alias to other
  files or binds `m` in its own file. A predicate that is false only on
  some targets still counts.
- An `extern crate` inside parentheses or brackets, such as a macro's
  input, is not read as a declaration.
- A `mod.rs` directly in `src/bin`, `tests`, `examples` or `benches` is a
  crate root, as Cargo's auto-discovery builds it as a target.
- Target folders are read below the package folder only: the nearest
  folder above a file that holds a `src/lib.rs` or `src/main.rs` among the
  scanned files. A package under a folder named `tests` keeps its
  `build.rs` and test files as crate roots.
2026-11-19 21:39:24 -08:00
dotCooCoo c451df07ae craft-testkit: a src folder above the package keeps its targets crate roots
`rust_sources` returns paths that include the folder it was given, so a
package under a folder such as `~/src` made every `src/bin` file and its
`build.rs` look nested, and predefined_quit missed `::menu` calls after
their `extern crate muda as menu;`. Files directly in `src/bin`, and
`main.rs` one folder below it, are now always crate roots, and another
target folder counts as nested only directly inside `src` or below a
`bin`, `tests`, `examples` or `benches` folder.
2026-11-19 20:40:23 -08:00
dotCooCoo 7120e4a2e5 craft-testkit: a package's build.rs and binary main.rs stay crate roots
Cargo builds a package's `build.rs` and `src/bin/<name>/main.rs` (and
`main.rs` one folder inside `tests`, `examples` or `benches`) as crates
of their own, also when another file loads them through `#[path]`.
predefined_quit now reads their `extern crate muda as menu;` as a crate
root's.
2026-11-19 20:35:59 -08:00
dotCooCoo fa829e4a37 craft-testkit: read identifier characters with std only
The guards need only std, so the unicode-ident dependency is removed.
Outside literals and comments Rust allows a non-ASCII character only in
an identifier or as white space, so the lexer reads every non-ASCII
character other than white space as part of an identifier. The
left-to-right and right-to-left marks and a byte order mark are read as
white space, so `t\u{200F}::Instant::now()` is still reported.
2026-11-19 20:31:49 -08:00
dotCooCoo 2477df8c86 craft-testkit: files in a package's target folders stay crate roots
Cargo builds every file in a package's `src/bin`, `tests`, `examples`
and `benches` folder as its own crate, also when another target
declares it as a module. predefined_quit now reads such a file's
`extern crate muda as menu;` as a crate root's. A target folder inside
`src` or inside another target folder still holds modules.
2026-11-19 20:27:34 -08:00
dotCooCoo abaaa097f9 craft-testkit: a crate root's extern crate alias reaches modules beside it
A crate root such as `src/bin/tool.rs` or `tests/foo.rs` declares its
modules in its own folder, so `mod child;` names `src/bin/child.rs`.
predefined_quit looked for them under `src/bin/tool/` and missed
`::menu::PredefinedMenuItem::quit` in the child after
`extern crate muda as menu;` in the root.
2026-11-19 20:21:13 -08:00
dotCooCoo ccaf31d4c9 craft-testkit: guards read identifiers that hold combining marks
The guards' lexer split an identifier at a nonspacing mark such as
U+0301, so `use std::time as t\u{301};` bound `t` and a later
`t\u{301}::Instant::now()` was not reported. Identifiers now follow the
Unicode XID_Start and XID_Continue properties, as rustc reads them,
through the unicode-ident crate that the workspace already locks.
2026-11-19 20:17:01 -08:00
FredApps 62f44de3d6 Consolidate related support tests 2026-11-19 13:07:16 +01:00
FredAppsandFredApps 50fbf2bd0c testkit: share exact format mutation corpus across DEX WASM and TAR (#2106)
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
2026-11-18 11:07:00 +07:00
Dylan M. Taylor a784f2e716 Merge main while retaining EVM and XFDF provenance 2026-11-17 19:41:50 -05:00
aiongg ff502fb75f ci: run a fraction of the fuzz-style tests on pull requests, all of them nightly
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.
2026-11-17 19:09:17 +00:00
Dylan M. Taylor 29fdd49d6d Use fixed-size chunks in fixture-order regression 2026-11-17 13:07:57 -05:00
51aadf525f Share deterministic parser damage fixtures without changing their corpus
Preserve the fixture helpers originally authored in Craft Anything testkit and extracted by FredApps for TAR. EVM and TAR now reuse craft-testkit with unchanged mutation sequences. Add sequence and stride regressions.

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2026-11-17 13:06:31 -05:00
dotCooCoo 8ec8e6b3c8 Merge main into feat/craft-testkit-guards 2026-11-16 19:39:49 -08:00
.CooCoo c91e32eb67 craft-media-testkit: run hostile and with_deadline on craft-testkit (#1462) 2026-11-16 21:34:35 -05:00
dotCooCoo f50e7dceb9 craft-testkit: open CACHEDIR.TAG and sources on Windows without following a reparse point
On Windows, open_regular_file checked the path with symlink_metadata and
then opened it with File::open, which follows a symbolic link or junction
put in place between the two calls. It now opens with
FILE_FLAG_OPEN_REPARSE_POINT, so a link opens as the link itself and is
refused by the type check on the opened handle.

A CACHEDIR.TAG whose opened handle is a reparse point of any kind, cloud
placeholders included, does not count as a cache marker, so its folder is
listed.

The Unix path is unchanged.
2026-11-15 16:00:33 -08:00
dotCooCoo 70275fe34d craft-testkit: guards read absolute paths through the extern prelude and step over an if or match in a native cfg head
- std_instant no longer reads `::m::Instant` or `use ::m::Instant;` through a local alias `m` of
  `std::time`; a path that starts with `::` names an external crate.
- predefined_quit reads a name that `extern crate muda as m;` outside any braces of a crate root adds
  to the extern prelude like `muda`, with or without a leading `::`, in the root and in every file
  that a chain of `mod` declarations from it names.
- An `if` or `match` expression in the condition, scrutinee or iterator of a native cfg `if`, `while`,
  `match` or `for` is read to its last block, so the body that follows is covered.
2026-11-15 13:32:52 -08:00
dotCooCoo 989a055a6f craft-testkit: check CACHEDIR.TAG and source files as they are opened
is_cache_dir checked CACHEDIR.TAG with symlink_metadata and then opened
it in a second step, so a symbolic link or a FIFO put in its place
between the two was still opened, and a FIFO could block the open. The
same gap applied to each .rs file rust_sources reads.

Both now go through open_regular_file. On Unix it opens with O_NOFOLLOW,
O_NONBLOCK and O_CLOEXEC through rustix and reads the type from the
opened file, so a symbolic link, FIFO or other special file is skipped.
On other platforms a symbolic link is skipped before the open and the
opened file must be a regular file. Reads stay bounded by the signature
length and max_file_bytes.
2026-11-15 12:50:11 -08:00
dotCooCoo da534b341f craft-testkit: guards follow names the muda crate is imported under
predefined_quit reports menu::PredefinedMenuItem::quit after use muda as menu;, use muda::{self as menu}; or extern crate muda as menu;, and reads those names in the scope of each path and import. A leading :: names an external crate, an extern crate of another crate shadows the name, and use muda as menu; binds menu to the crate only where muda names it.
2026-11-14 20:23:09 -08:00
dotCooCoo 2ec3ffee2b craft-testkit: the CACHEDIR.TAG FIFO test runs without a timeout
The test opens the FIFO for reading and writing and puts the signature
in the pipe before the scan. A scan that opened the FIFO would read the
signature and leave out `kept.rs` instead of blocking, so the test no
longer waits on a thread with a 30-second bound.
2026-11-14 20:12:06 -08:00
dotCooCoo 7ce5c2cc3d craft-testkit: guards read blocks in a native cfg if condition, renames through a local muda and cfg-gated time shadows
- A native-only `if`, `while`, `match` or `for` whose condition holds a
  block expression (`if { ready } { ... }`, `while !{ x }`, `unsafe`,
  `loop`, `async` and labeled blocks) is covered up to its real body, so
  `std_instant` skips the body.
- `predefined_quit` no longer follows `use muda::PredefinedMenuItem as
  Item;` or `type Alias = muda::PredefinedMenuItem;` when the braces
  around it bind `muda` to something else (`use other_menu as muda;`).
  `::muda::` still names the crate.
- In `std_instant`, a `use` or `mod` that binds an alias name to
  something else and carries its own `cfg` attribute that may be false
  on `wasm32-unknown-unknown` no longer hides an outer
  `use std::time as clock;`.
2026-11-14 20:08:41 -08:00
dotCooCoo 7da619dc4e craft-testkit: guards keep names past the use-path limits, report underscore imports in groups and keep crate roots in module cycles
- A `use` whose path is longer than the copy limits still binds its name,
  and keeps its first segment, so another crate's long path no longer reads
  as an unbound `PredefinedMenuItem` and a long `crate::` path still reads as
  a possible re-export.
- `std_instant` reports `use std::{time::Instant as _};`; `_` only stops the
  name from being bound.
- `std_instant` checks the leaves read without aliases as well as the ones
  read through them, so an alias in a nested module no longer hides an outer
  `use std::{time::Instant};`.
- A cycle of `mod` declarations that no other file names keeps a crate
  root: its `lib.rs` or `main.rs`, or every member when it has neither. A
  `lib.rs` that names itself through a disabled `#[path]` declaration is
  checked again.
- `predefined_quit` does not report `muda::PredefinedMenuItem::quit` where
  a `use` or a `mod` in scope binds `muda` to something else
  (`use other_menu as muda;`); `::muda::` is still reported.
2026-11-14 19:15:51 -08:00
dotCooCoo 97f970c58c craft-testkit: guards keep generic-bracket blocks in a native cfg item, read only a regular CACHEDIR.TAG and read names in their scope
std_instant ended a native-only fn, impl, trait, struct, enum or union item
at the closing brace of a block inside its angle brackets, such as the
const generic default in `struct Native<const N: usize = { 1 + 2 }>`, a
`Foo<{ N }>` argument, a return type or a `where` clause. The rest of the
item was then checked as web code. Blocks inside those angle brackets no
longer end the item, and the `>` of `->` does not close a bracket.

rust_sources opened a folder's CACHEDIR.TAG without checking its file
type, so it followed a symbolic link and could block on a FIFO. It now
reads the marker only when symlink_metadata reports a regular file;
any other marker is not read and the folder is listed.

predefined_quit reported a bare `PredefinedMenuItem::quit` when the file
imported another crate's type under that name or defined its own, and
applied a rename of muda's type (`use muda::PredefinedMenuItem as Item`)
to the whole file. A name used on its own is now read in the innermost
braces around it, within its module, that bind it: it is reported when
they import or alias muda's type, and not when they only bind another
type. An import or alias through `crate::`, `self::` or `super::`, a
binding inside an item with a `cfg` attribute and an associated type in
an `impl` or `trait` do not bind the name.

std_instant applied an alias of `std::time` (`use std::time as clock`)
to the whole file. A path or `use` through the alias is now reported
only where the alias is in scope by the same rule, so another module's
`use web_time as clock` is not read as `std::time`.
2026-11-14 18:36:00 -08:00
dotCooCoo 7082905431 craft-testkit: guards read paths through a long std::time alias and after arrows
A use path whose first segment is longer than 32 bytes was dropped by the
use-path copying limit. With `use std::time as <long name>;`, std_instant
missed `use <long name>::{Instant as Clock};` and `use <long name>::*;`.
std_instant now reads the use declarations a second time with the names
bound to std::time, and a path that starts with one of them is read as a
path that starts with std::time. The alias is not copied into the leaves,
so the limits still bound every other path.

The `>` of `->` and `=>` was read as the end of a path, so both guards
skipped an absolute path after it: `fn now() -> ::std::time::Instant` and
`_ => ::muda::PredefinedMenuItem::quit(None)`. Those paths are now checked.
2026-11-14 17:39:06 -08:00
dotCooCoo e1b53c6b44 craft-testkit: guards end a native cfg if let at its body and read only muda's qualified type
- 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.
2026-11-14 17:01:49 -08:00
dotCooCoo 811baa83c1 craft-testkit: test std_instant on items that follow a native cfg item on the same line
A native-only item ends at its closing brace or `;`, so an item after it
on the same line is checked, and a second native-only item there stays
exempt. The tests cover `fn`, `impl`, `mod`, braced and tuple `struct`
items, and a `use` with a native cfg after another gated item.
2026-11-14 16:40:52 -08:00
dotCooCoo 4739754009 craft-testkit: guards read cfg literals, escapes and deep nesting, and bound use-path copies
- 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.
2026-11-14 15:34:50 -08:00
dotCooCoo a7b24b109a Testkit: std_instant keeps a native cfg on the whole statement it covers
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.
2026-11-14 14:58:16 -08:00
dotCooCoo 2abb1c6a80 craft-testkit: test the guards on split use groups, brace literals, escaped line breaks, deep nesting and broken links
New tests cover cases the guards already handle:

- wgsl_float_literals checks a literal that follows a hex literal and an
  operator (0x1.0p0+1e39, 0xFF+1e39, 0x1f-4e38).
- std_instant reports Instant in a use group split over several lines.
- '{' and '}' character literals do not end a native cfg item early.
- An escaped line break in a string keeps the line numbers after it.
- Use groups and cfg predicates nested 100,000 deep return without
  exhausting the stack.
- rust_sources skips a broken symbolic link to a file or a folder.
2026-11-14 13:03:11 -08:00
dotCooCoo 5c53194e40 craft-testkit: a native cfg on a block statement covers the block and its method-call suffix
item_end now ends a cfg-gated statement that starts with a bare block at the block's closing brace, so code after it is checked. When a `.` or `?` follows the closing brace of a block item, the item runs on to its `;` or `,`, so a method call after a cfg-gated block or `unsafe` block stays covered by the cfg.
2026-11-14 12:12:08 -08:00
dotCooCoo 836433ccb9 craft-testkit: wgsl_float_literals docs say the limit check uses the value rounded to f64
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.
2026-11-14 12:01:40 -08:00
dotCooCoo b89076646d craft-testkit: rust_sources docs name the CACHEDIR.TAG signature it checks
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.
2026-11-14 11:55:02 -08:00
dotCooCoo b9d451674e craft-testkit: std_instant skips module files a native-only mod declares
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.
2026-11-14 11:40:45 -08:00
dotCooCoo 52b917fce5 craft-testkit: guards read Rust tokens, check hex and f16 floats, and bound rust_sources
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.
2026-11-14 11:16:07 -08:00
Zach Shallbetter 87bbc1c711 craft-testkit: add source-level platform regression guards (closes #139)
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.
2026-11-14 10:53:15 -08:00