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.
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.
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.
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.
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.
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.
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.
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.
`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.
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).
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.
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.
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.
- 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.
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.
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.
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.
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.
`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.
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.
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.
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.
- 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.
`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.
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.