Repository navigation
testkit: add xtp-testkit crate with visible test skip helper - #21
Conversation
simnJS
left a comment
There was a problem hiding this comment.
Thanks for picking up #1. The crate is small and tidy, and the workspace wiring is right: the members glob, [workspace.dependencies], Cargo.lock, and the AREAS/labeler entries the xtask test requires. Requesting changes for one functional problem and a few smaller ones.
1. The skip line is invisible in a normal run (blocking). skip() prints with eprintln!, and libtest captures print!/eprint! output for passing tests. CI runs plain cargo test --workspace --locked, so a skipped test shows as ok and the SKIPPED line never reaches the log. That is the silent pass #1 is meant to remove. The child tests don't catch it because both runs pass --nocapture. xtp-gpu/src/testgpu.rs already avoids this by writing to the stderr handle directly:
use std::io::Write;
let _ = writeln!(std::io::stderr().lock(), "{}", format_skip(&test, reason));Please also drop --nocapture from the child_skip_other_reason run, so the test proves the marker shows under default capture. With eprintln! that test would fail.
2. Docs. The PR adds a testkit area and an XTP_REQUIRE variable, but these are unchanged:
- CONTRIBUTING.md: the area list under "Commits and pull request titles", and the skip example under "Tests", which should now use
xtp_testkit::skip; - docs/dev/START_HERE.md: "Map of the crates";
- docs/architecture.md: the crate table.
A short usage example in the crate docs would help too (xtp_testkit::skip("no-gpu"); return;), since skip() doesn't stop the test by itself.
3. Description and title.
- Please restore the template's
AI assistance:line, and say whether you read xcl'sskip_test(CONTRIBUTING rule 6). - The body has stray BEL characters where PowerShell ate a backtick followed by
a("(or ll / *)"). - The PR is squashed into one commit, so
testkit: …would describe it better thantests:, which meanstests/.
Suggestions (non-blocking):
- a set of
pub constreasons (docs/analysis/tooling.md 4.5 asks for a fixed set), so that call sites andXTP_REQUIREvalues can't drift apart; - a note that
XTP_REQUIRE_GPUwill becomeXTP_REQUIRE=no-gpuin B3; - in the panic check, asserting on "cannot skip" rather than just "no-gpu".
The CI runs for this head are now approved. We'll look again once the changes are in and CI is green.
|
Addressed all review items and suggestions:
|
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
|
Thanks, this addresses everything. The CI runs for this head are approved; I'll approve and merge once they're green. Optional follow-ups, fine in B2:
|
What and why
Add a small dev-dependency crate
xtp-testkitproviding one visible, countable way to skip host- or sample-dependent tests:xtp_testkit::skip(reason)writesSKIPPED <test>: <reason>directly tostd::io::stderr().lock()(bypassinglibtestcapture so skips stay visible under plaincargo test) and returns.XTP_REQUIRE=<reason,...>(orall/*) turns matching skip reasons into a panic on machines that must execute those tests.xtp_testkit::reasondefines standard reason constants (NO_GPU,NO_SM66,NO_DXC,NO_DXIL,NO_CONSOLE_DXC).xtp-testkitin[workspace.dependencies],xtask/src/conventions.rs,.github/labeler.yml,CONTRIBUTING.md,docs/dev/START_HERE.md, anddocs/architecture.md.Fixes: #1
Depends on: none
Area
crates/xtp-testkit(new)Cargo.toml,Cargo.lockxtask/src/conventions.rs,.github/labeler.ymlCONTRIBUTING.md,docs/dev/START_HERE.md,docs/architecture.mdTests
cargo xtask pr-checkpasses on my machineUnit tests in
crates/xtp-testkit/src/lib.rsverify:SKIPPED <test>: no-gpu);XTP_REQUIREmatching handles single, comma-separated, case-insensitive, and wildcard values;XTP_REQUIRE=no-gpu,skip("no-gpu")panics reportingcannot skipandno-gpu, whileskip("no-dxc")(run without--nocapture) exits cleanly and writes the canonicalSKIPPEDline to stderr under default capture.Provenance
Written from scratch for XTP. I did not read xcl's
skip_test.AI assistance: Antigravity assisted with implementation, review fixes, and unit tests; all changes were reviewed and verified locally.
Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above