Commit Graph
72 Commits
Author SHA1 Message Date
dotCooCoo 415905859e Merge main into feat/craft-testkit-corpus
Native-only helper names use code spans in documentation for Wasm targets.
2026-11-26 16:58:28 -08:00
dotCooCoo 30fc207650 craft-testkit: write the skip line past the test output capture 2026-11-26 00:14:54 -08:00
dotCooCoo 4bdac469e1 craft-testkit: fail pinned on a folder variable name that cannot be read
pinned now fails the test when the folder variable name is empty or
holds `=` or a NUL character, before the environment is read, instead
of reading it as unset and skipping. The docs of verify and the README
also state what the containment check after the open covers on each
platform, that an Apple path query error fails verification, and that
the manifest parser does not check names against a file system's rules.
2026-11-25 22:14:02 -08:00
dotCooCoo 0c80737af7 Merge feat/craft-testkit-skip into feat/craft-testkit-corpus
# Conflicts:
#	Cargo.lock
#	README.md
#	crates/testkit/Cargo.toml
#	crates/testkit/README.md
#	crates/testkit/src/lib.rs
2026-11-25 21:10:10 -08:00
dotCooCoo 3814174538 craft-testkit: take skrifa from the workspace, behind the font-coverage feature
skip::craft_fonts_cover and its tests need the new font-coverage feature,
so a crate that dev-depends on craft-testkit no longer builds skrifa
unless it asks for the feature. skrifa comes from the workspace
dependency. skip::required is the one parser for a required variable:
unset or empty is optional, 1 is required, and every other value is a
configuration error.
2026-11-25 19:32:15 -08:00
dotCooCoo b3476c5455 craft-testkit: skip an unset corpus with skip::skip
`corpus::pinned` no longer reads `<VAR>_REQUIRED` itself or prints its
own SKIPPED line. With the folder variable unset it calls `skip::skip`,
so the required variable follows the same rule as every other skip:
unset or empty skips, `1` fails the test, and any other value, `0`
included, fails the test as a configuration error.
2026-11-25 19:30:36 -08:00
dotCooCoo 926191f175 Merge main into feat/craft-testkit-skip 2026-11-25 19:30:20 -08:00
dotCooCoo d5d9b4cab2 Merge main into feat/craft-testkit-corpus 2026-11-25 19:24:43 -08:00
dotCooCoo ea681d8c1b Merge feat/craft-testkit-skip into feat/craft-testkit-corpus 2026-11-25 19:21:06 -08:00
BFlat 5a77c51821 Merge pull request #1405 from dotCooCoo/feat/craft-testkit-rng
craft-testkit: add seeded xorshift64 and xorshift64* generators for test input
2026-11-26 10:08:27 +07:00
BFlat 9ad5469bd4 Merge pull request #1388 from dotCooCoo/feat/craft-testkit-serial
craft-testkit: add the serial module with a reentrant test lock
2026-11-26 10:08:03 +07:00
dotCooCoo 793744d7ce Testkit: a nested library loaded by its own targets stays a crate root
A `src/lib.rs` below another package's `src` folder was treated as a
module whenever any declaration named it, including one in its own
package's binary. Its `extern crate muda as m;` then did not reach its
modules, and a `::m::PredefinedMenuItem::quit` call there was missed.
Only a declaration outside the package's `build.rs` and its `src`,
`tests`, `examples` and `benches` folders now makes it a module.
2026-11-25 16:53:01 -08:00
dotCooCoo dc2e7e8a54 Merge main into feat/craft-testkit-guards 2026-11-25 15:09:52 -08:00
dotCooCoo d791d9c893 testkit: describe below's modulo bias over the nonzero draw range
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.
2026-11-24 16:14:37 -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 f802a2ce73 craft-testkit: reject a required variable name that cannot be read
`skip::required`, `skip` and `or_skip!` now return or fail with
`RequiredError::BadName` when the variable name is empty or holds `=`
or a NUL character, before the environment is read. The `deadline` and
`hostile` modules already reject such names the same way.
2026-11-22 00:46:24 -08:00
dotCooCoo b6c5cf4fb3 craft-testkit: fail a skip on a required variable set to 0
When a prerequisite is missing, only an unset or empty variable now
skips the test, and `1` fails it. `0` joins the other values that fail
the test as a configuration error, in `skip::required`, `skip` and
`or_skip!`. The error text no longer lists `0` as a skip value.

The tests check `0` as an invalid value directly and through `skip` and
`or_skip!` in a child process. The crate docs, its README and the root
README's `craft-testkit` entry list the new values.
2026-11-22 00:42:15 -08:00
dotCooCoo 843018f742 craft-testkit: fail a skip on a required variable that is not empty, 0 or 1
skip and or_skip! now read the required variable as follows: unset,
empty and 0 skip the test, 1 fails it, and any other value, including
true, yes, " 1", "1\n" and a value that is not valid Unicode, fails the
test as a configuration error that names the variable and its value.
skip::required returns Result<bool, RequiredError> with the same rule.

The README's skip section lists the values in a table, and the
migration notes say which values change for apps that read any value
or accept true, yes and on today.
2026-11-21 22:17:10 -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
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
dotCooCoo da52b002d2 Merge main into feat/craft-testkit-rng 2026-11-17 18:17:00 -08:00
dotCooCoo d9832bc8ce Merge main into feat/craft-testkit-skip 2026-11-17 18:11:51 -08:00
dotCooCoo 5c5b529480 Merge main into feat/craft-testkit-serial 2026-11-17 18:09:17 -08: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 aea1ee6860 craft-testkit: refuse corpus files opened outside the folder and control characters in paths
On Unix, verify checks after the open that the opened file is inside the corpus folder: by the path the kernel reports for the open file on Linux, Android and Apple platforms, otherwise by resolving the path again and comparing device and inode. Manifest paths that hold a control character are refused.
2026-11-16 21:50:31 -08:00
dotCooCoo c0845ba8d3 craft-testkit: open corpus files without waiting on a named pipe
Manifest::read and verify checked a path's type and then opened it. A path replaced by a named pipe between the two blocked the open until a writer appeared. On Unix both now open with O_NONBLOCK and check the opened file's type again.
2026-11-16 21:38:39 -08:00
dotCooCoo 80fd8e3b64 Merge main into feat/craft-testkit-corpus 2026-11-16 21:30:33 -08:00
dotCooCoo 7938b7f578 craft-testkit: state that every GPU test must take the shared lock 2026-11-16 19:57:29 -08:00
dotCooCoo 3f00bc2078 Merge main into feat/craft-testkit-skip 2026-11-16 19:40:02 -08:00
dotCooCoo 8ec8e6b3c8 Merge main into feat/craft-testkit-guards 2026-11-16 19:39:49 -08:00
dotCooCoo d837d459ef Merge main into feat/craft-testkit-rng 2026-11-16 19:39:25 -08:00
dotCooCoo c9c4e4da65 Merge main into feat/craft-testkit-serial 2026-11-16 19:36:54 -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 8f3fa35375 Merge feat/craft-testkit-guards into feat/craft-testkit-rng 2026-11-14 20:27:53 -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