Commit Graph
117 Commits
Author SHA1 Message Date
dotCooCoo ca9f44cb0c Merge main into feat/craft-testkit-fixtures 2026-11-28 05:22:27 -08:00
BFlat f83e228e81 Merge pull request #1459 from dotCooCoo/feat/craft-testkit-mcp
craft-testkit: add the mcp feature, an MCP stdio test client with deadlines and line limits
2026-11-28 17:51:42 +07:00
BFlat f7e0ec5f4a Merge pull request #3942 from dotCooCoo/fix/testkit-deadline-hang-guard
craft-testkit: deadline limits only catch hangs; wait_until waits on a Signal
2026-11-28 17:51:19 +07:00
dotCooCoo aa95babe21 Testkit: fixtures skip or fail through craft_testkit::skip
generate and generate_with no longer keep their own required variable
and skip_or_fail. A fixture that cannot be made now goes through
skip::skip with the variable generate is given (default
CRAFT_TEST_REQUIRED): unset or empty prints `SKIPPED: <reason>`, `1`
fails the test, and any other value, `0` included, fails it as a
configuration error. generate_with keeps the caller's required value
and prints the same skip line. The README paragraph and the test of the
variable's values follow the new rule.
2026-11-28 02:21:04 -08:00
dotCooCoo 92ab88d441 craft-testkit: crate docs describe late results and shared rechecks
with_deadline returns a result that arrives before the limit is checked,
and wait_until checks its condition once for any number of raises that
came during one call of it.
2026-11-28 02:17:04 -08:00
dotCooCoo 68ab810760 Merge main into feat/craft-testkit-mcp 2026-11-28 02:16:39 -08:00
dotCooCoo f41b28a53c craft-testkit: wait_until's limit counts from the start of the call
The limit restarted after every call of the condition, so a thread that
kept raising the signal while the condition stayed false held wait_until
forever. The limit now counts from the start of the call, and each wait
lasts at most the time left. The condition is still called before the
limit is checked, so a condition that holds never fails.

Two tests cover it: an injected clock with a wait that always reports a
raise, and a real thread raising in a loop under with_deadline. Both
fail without the change.
2026-11-28 02:15:25 -08:00
dotCooCoo dab898760e Merge main into feat/craft-testkit-fixtures
# Conflicts:
#	Cargo.lock
#	README.md
#	crates/testkit/README.md
2026-11-28 02:09:48 -08:00
dotCooCoo 0cc7c2d8f9 Merge main into fix/testkit-deadline-hang-guard 2026-11-28 01:51:38 -08:00
dotCooCoo 361a035e08 Merge main into feat/craft-testkit-fonts 2026-11-28 01:39:11 -08:00
dotCooCoo 19c3356e78 craft-testkit: deadline limits only catch hangs; wait_until waits on a Signal
with_deadline failed a body that returned or panicked after its limit, and
hammer failed a case that finished after its per-case limit, so a slow
runner could fail a test whose code was correct. Both now take whatever the
body or case produced, however late it arrives, and fail on the limit only
when nothing has arrived by then.

wait_until polled its condition with sleeps against a clock and failed a
true that came after the limit. It now takes a Signal: the condition is
called at once and again each time another thread calls Signal::raise, and
the limit only fails a wait that saw no raise in that time. A raise made
while the condition runs is not lost. No crate in this workspace calls
wait_until.

The tests use an injected wait for the limit and an injected clock instead
of real 50 ms limits, and new tests cover a value or panic that arrives
after the limit, a case that finishes after its limit, and a raise during
the condition. The tests of the removed behavior (a late result fails, the
pause schedule of the polling loop) are replaced by these.
2026-11-27 14:48:11 -08:00
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 565513eab9 Validate MCP tool results and drain output during shutdown 2026-11-26 16:57:19 -08:00
dotCooCoo 48b9770c15 testkit: bound retained notification bytes 2026-11-26 15:41:25 -08:00
dotCooCoo 284c3a9941 testkit: document initialization and failure cleanup 2026-11-26 15:26:09 -08:00
dotCooCoo ce2f746e4c testkit: validate MCP replies and stop failed queued writes 2026-11-26 15:22:47 -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 0265dd5f52 Testkit: an empty table inside name or head no longer fails rename_family
The overlap check treated a table of length 0 whose offset points inside
the name or head table as sharing bytes, so rename_family returned
MalformedFont for a valid face. An overlap now needs at least one shared
byte. Nonempty overlapping tables are still refused.
2026-11-25 21:15:05 -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 6db18d9089 craft-testkit: connect and close docs say when the MCP reading thread stops 2026-11-25 20:13:19 -08:00
dotCooCoo 3a4427a57f craft-testkit: close waits for the rest of the MCP child's stderr after it exits
close waited for the stderr thread only as long as close_grace, so with a
short or zero grace the bytes still in the pipe when the child exited could
be missing from CloseOutcome::stderr. It now waits up to 5 s after the child
exits, and only a process that keeps the child's stderr open waits that long.
2026-11-25 20:07:39 -08:00
dotCooCoo 20f1cddbc9 Merge main into feat/craft-testkit-mcp 2026-11-25 19:54:43 -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 216dd09cd4 Merge main into feat/craft-testkit-fixtures 2026-11-25 19:26:51 -08:00
dotCooCoo d5d9b4cab2 Merge main into feat/craft-testkit-corpus 2026-11-25 19:24:43 -08:00
dotCooCoo 3c7f7d5c8b Merge main into feat/craft-testkit-fonts 2026-11-25 19:23:06 -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 16e4310bee craft-testkit: do not return an output that links to its temporary file
When a generator made `out` a symbolic link to its claimed temporary
file, `publish` refused the pair as the same entry and kept the
temporary file, and `generate` had already stopped owning it. The final
check then found `out` complete through the link and returned it, with
the temporary file left beside it. `generate` now checks for this before
publishing, removes the temporary file and skips (or fails when the
fixture is required).
2026-11-25 17:23:36 -08: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 454d67c642 Merge main into feat/craft-testkit-fixtures 2026-11-25 14:01:41 -08:00
dotCooCoo 120a254837 craft-testkit: keep fixture folders inside the root through links
fixtures_dir checked sub lexically and then ran create_dir_all, so a
symbolic link or junction under the root that points elsewhere let
fixtures_dir("link/new") create a folder outside the root. It now
creates one folder at a time and returns InvalidInput, without
creating the rest, when a folder resolves outside the canonical root
or is not a folder. A link that stays inside the root still works.
The README and doc comment state the rule and that the check uses
paths.
2026-11-24 20:39:54 -08:00
dotCooCoo 1bede88dab craft-testkit: check the fixture again after removing its temporary
publish now removes the temporary entry first and then checks whether the
output is still a complete file. An output that reached its file through a
link at the temporary path, directly or through a linked folder, no longer
counts as published, so generate does not return a dangling link. A Unix
test covers both cases.
2026-11-24 17:56:27 -08:00
dotCooCoo fbc52de393 craft-testkit: harden fixture roots, names and publication
- Parse each Cargo.toml with the toml crate to find the workspace, and
  honor an explicit package.workspace before searching ancestors.
- Reject a fixture folder part such as group\C:outside that would
  replace the root on Windows.
- Reject outputs whose name ends with .fixture-lock in any letter case.
- Remove a temporary link that points at the published winner.
- Start the stderr reader with thread::Builder and reap the child when
  the thread cannot start.
- The cross-process test pauses a publisher inside the lock and checks
  that the lock is held; the env test compares with a snapshot.
- Document generate_with, the metadata-only output check and the
  Command state that run_generator leaves on cmd; the crate docs no
  longer link the native-only fixtures module.
2026-11-24 17:25:21 -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