Skip to content

testkit: add xtp-testkit crate with visible test skip helper - #21

Merged
simnJS merged 2 commits into
MiamiGame:mainfrom
PrivacyOnion:tests/xtp-testkit
Nov 24, 2026
Merged

simnJS merged 2 commits into
MiamiGame:mainfrom
PrivacyOnion:tests/xtp-testkit

Conversation

@PrivacyOnion

@PrivacyOnion PrivacyOnion commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Add a small dev-dependency crate xtp-testkit providing one visible, countable way to skip host- or sample-dependent tests:

  • xtp_testkit::skip(reason) writes SKIPPED <test>: <reason> directly to std::io::stderr().lock() (bypassing libtest capture so skips stay visible under plain cargo test) and returns.
  • XTP_REQUIRE=<reason,...> (or all / *) turns matching skip reasons into a panic on machines that must execute those tests.
  • xtp_testkit::reason defines standard reason constants (NO_GPU, NO_SM66, NO_DXC, NO_DXIL, NO_CONSOLE_DXC).
  • Register xtp-testkit in [workspace.dependencies], xtask/src/conventions.rs, .github/labeler.yml, CONTRIBUTING.md, docs/dev/START_HERE.md, and docs/architecture.md.

Fixes: #1
Depends on: none

Area

  • crates/xtp-testkit (new)
  • Cargo.toml, Cargo.lock
  • xtask/src/conventions.rs, .github/labeler.yml
  • CONTRIBUTING.md, docs/dev/START_HERE.md, docs/architecture.md

Tests

  • cargo xtask pr-check passes on my machine
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on the title: no

Unit tests in crates/xtp-testkit/src/lib.rs verify:

  • the formatted marker names the current test (SKIPPED <test>: no-gpu);
  • XTP_REQUIRE matching handles single, comma-separated, case-insensitive, and wildcard values;
  • in child processes of the test binary with XTP_REQUIRE=no-gpu, skip("no-gpu") panics reporting cannot skip and no-gpu, while skip("no-dxc") (run without --nocapture) exits cleanly and writes the canonical SKIPPED line to stderr under default capture.

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:

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

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

@github-actions github-actions Bot added area/xtask xtask/ area/ci .github/, .githooks/ area/deps Cargo.lock area/build workspace manifest, toolchain, repository files size/M 100 to 399 changed lines labels Nov 24, 2026

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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's skip_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 than tests:, which means tests/.

Suggestions (non-blocking):

  • a set of pub const reasons (docs/analysis/tooling.md 4.5 asks for a fixed set), so that call sites and XTP_REQUIRE values can't drift apart;
  • a note that XTP_REQUIRE_GPU will become XTP_REQUIRE=no-gpu in 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.

@PrivacyOnion PrivacyOnion changed the title tests: add xtp-testkit crate with visible test skip helper testkit: add xtp-testkit crate with visible test skip helper Nov 24, 2026
@PrivacyOnion

Copy link
Copy Markdown
Contributor Author

Addressed all review items and suggestions:

  1. \skip()\ now writes directly via \writeln!(std::io::stderr().lock(), ...)\ so skips remain visible under default \libtest\ capture; removed --nocapture\ from the child test so default capture is exercised directly.
  2. Updated \CONTRIBUTING.md\ (areas + skip example), \docs/dev/START_HERE.md, and \docs/architecture.md, plus added a usage example, \xtp_testkit::reason\ constants, and the B3 note in crate docs.
  3. Renamed PR title to \ estkit: ..., fixed the PowerShell escape typos in the description, stated that xcl's \skip_test\ was not read, restored \AI assistance:, and tightened the panic assertion to check \cannot skip\ as well.

@github-actions github-actions Bot added the overlap another open PR changes the same files label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

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.

Pull request Files changed by both
#20 docs/dev/START_HERE.md

This comment is kept up to date automatically and removed when the overlap ends.

@github-actions github-actions Bot added area/docs docs/, Markdown policy changes the rules, licence or automation: a maintainer reviews labels Nov 24, 2026
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
7 of 9 tasks
@simnJS

simnJS commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks, this addresses everything. skip() now writes to the stderr handle directly, and child_skip_other_reason runs without --nocapture, so the test proves the marker shows under default capture (it would fail with eprintln!). The docs, crate example, reason constants, B3 note, title and description are all done.

The CI runs for this head are approved; I'll approve and merge once they're green. Optional follow-ups, fine in B2:

  • CONTRIBUTING's example uses "no-sample XTP_XMA_STREAMS", which XTP_REQUIRE=no-sample won't match; a reason::NO_SAMPLE constant, or matching on the part before the first space, would keep it in the fixed set.
  • Mention adding xtp-testkit = { workspace = true } under [dev-dependencies].
  • .env_remove("RUST_TEST_NOCAPTURE") on the child command would keep the regression guard meaningful on machines that set it.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is green on 2e0aff4. Approving and merging; the optional follow-ups (a NO_SAMPLE reason, the dev-dependency line in CONTRIBUTING, env_remove of RUST_TEST_NOCAPTURE) can come in B2. Thank you!

@simnJS
simnJS merged commit 8a83328 into MiamiGame:main Nov 24, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build workspace manifest, toolchain, repository files area/ci .github/, .githooks/ area/deps Cargo.lock area/docs docs/, Markdown area/xtask xtask/ overlap another open PR changes the same files policy changes the rules, licence or automation: a maintainer reviews size/M 100 to 399 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test kit: one visible way to skip a test (xtp-testkit)

2 participants