Repository navigation
feat(testkit): register tests and add the openshell-test program - #5138
matthewgrossman wants to merge 3 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test ca412d5 |
|
Label |
|
🌿 Preview your docs: https://nvidia-preview-pr-5138.docs.buildwithfern.com/openshell |
|
/ok to test 592a748 |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. cli — No explicit risk acceptance foundopenshell-test-runner replaces
Review details
Advisory review; publication gates are unchanged. |
592a748 to
2fecde6
Compare
|
/ok to test 2fecde6 |
2fecde6 to
f945820
Compare
|
/ok to test f945820 |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. cli — No explicit risk acceptance foundWith unchanged environment, installer, family and package arguments,
Review details
Advisory review; publication gates are unchanged. |
#[testkit::test] now also registers each test in a link-time registry, alongside the existing #[tokio::test] wrapper, so suites keep running under cargo test and nextest unchanged. testkit::main() runs the registered tests a binary links. Without a subcommand it speaks libtest's interface, so a harness = false target works under cargo test and nextest. Its subcommands are: - list: print each test's family, name, and description - ready: wait for the gateway, sharing its check with testkit-ready, and exit 2 if it is not ready in time - run (Unix only): run tests one at a time, each in its own process group with a timeout (SIGTERM, grace, SIGKILL), write a JUnit report, and exit 1 when a test failed or 2 when tests could not run A stopped test does not clean up its sandboxes yet; the README notes this. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Cargo builds each file in tests/ as its own test executable, which no other program can link. Move the conformance suites into src/ as modules of a library, so a test program can link them. Test code is unchanged; cargo test and nextest run the same 15 tests as the library's unit tests. Nextest now names them as binary `conformance`, test `<suite>::<fn>`, so filters that selected a suite by binary select it by test name instead. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
tests/openshell-test/ builds openshell-test, a binary whose main calls testkit::main() and links the conformance suite. It lists, waits for the gateway, and runs the conformance tests without cargo or nextest. Its list matches what nextest lists for the suite. It is its own workspace because later families live in other workspaces. Its lockfile is aligned with the root's, and Branch Checks and the mise tasks format, lint and test it. It is not published, and CI does not run it against a gateway yet. A dependency that is never named is not linked, so a suite the program forgets to name would silently go missing. testkit::main() now fails with exit 2 when a program links no tests, under every command. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
f945820 to
8835ce6
Compare
|
/ok to test 8835ce6 |
Summary
Turn the conformance tests into one program,
openshell-test, that anyone can run against their own gateway without a Rust toolchain, cargo or nextest.#[testkit::test]now also registers each test, andtestkit::main()turns a binary into a test program withlist,readyandrun. The conformance suite becomes a library, andtests/openshell-test/links it into the program. Existing suites still run undercargo testand nextest.Switching CI rows or host lanes to the program, publishing it, and adding other families are later PRs.
Related Issue
Part of #3954
Changes
Three commits (the crate rename to
conformancelanded in #5078):feat(testkit): register tests and add a standalone test program.#[testkit::test]keeps its#[cfg(test)] #[tokio::test]wrapper and also adds a link-time registry entry (linkme) with the test's family, name, description and#[ignore]reason.tests/suites/. The name is the same name libtest and nextest use.cfgand lint attributes (allow,warn,deny,forbid).#[should_panic],#[cfg_attr]and#[expect]are rejected with an error explaining why.testkit::main():libtest-mimic), so it also works as aharness = falsetarget undercargo testand nextest.list [FILTER]...prints family, name and description, with ignored tests marked.ready [--timeout SECS]waits for the gateway, sharing its check withtestkit-ready. It exits 2 if the gateway isn't ready in time.run [FILTER]... [--include-ignored] [--timeout SECS] [--grace SECS] [--junit PATH]runs tests one at a time. Each test is a new process (<name> --exact --nocapture) in its own process group, so nothing a test starts outlives it. A test that runs past its timeout (900s by default) gets SIGTERM, then SIGKILL after the grace period (10s). Interruptingrunstops the current test and runs no more tests; a second interrupt skips the grace period. Output is shown live and kept (the last 4 MiB per stream) for the JUnit report.runexits 1 when a test failed and 2 when tests couldn't run or the run was interrupted. It is Unix-only; on other platforms it says to use cargo test or nextest.tests/testkit/README.mddocuments the program and its limits.refactor(conformance): move the conformance suites into a library. Cargo builds each file intests/as its own test executable, which no other program can link.tests/suites/conformance/tests/*.rsmove tosrc/as modules of alib.rs; test code is unchanged.cargo testand nextest run the same 15 tests as the library's unit tests.conformance::smoke create_exec_delete(binaryconformance::smoke) becomes binaryconformance, testsmoke::create_exec_delete. Filters that picked a suite by binary now pick it by test name, e.g.--filter 'test(/^policy_advisor::/)'.CI.md,e2e/policy-advisor/README.md, the runner's--filterhelp and the suite README are updated.e2e/support/conformance.sh),mise run e2e:testkitand the tmachine runner select the suite by workspace or package, so they still select every test. Thekind(test)archive filters intests/tmachine/artifacts.nixaren't used for conformance.feat(test): add the openshell-test program.tests/openshell-test/is its own workspace (later families live in other workspaces). Itsmaincallstestkit::main()and names the suite crate withuse conformance as _;. A test checks thatlistshows the conformance tests.ALIGNED_WORKSPACES), and Branch Checks and the mise tasks format, lint and test it.TESTING.mdand the testkit README mention it.Limits:
Release Notes
For discussion with @elezar
This reverses two decisions from #4629: "no custom harness" and "one binary per suite". The reason is that
openshell-testshould run where the user has no cargo or nextest. The design still keeps the standard tooling (the libtest interface, so nextest andcargo testwork as before), per-test process isolation, and nextest archives in CI. I'd like to agree on this here before the program becomes what CI runs.Testing
--all-targets -D warnings) are clean for testkit, conformance, features, support, the runner andopenshell-test.openshell-test1/1; runner 10/10. testkit doctests pass.openshell-test listmatchescargo nextest listfor the conformance workspace (15 tests, none ignored) in debug and release builds, before and after rebasing onto the rename. Removing the suite'suseline gives the empty-program error.rust:1.95-bookworm): testkitcargo test,openshell-testclippy and test, and a releaselist(15 tests).testkit/tests/program.rs) run fixture tests through the subcommands. They cover pass, fail, timeout, SIGTERM ignored, interrupt during and between tests, leftover helper processes, JUnit output, and a program with no tests.testkit/tests/attribute.rschecks that the registry agrees with libtest's--listand--list --ignored.e2e/with-docker-gateway.sh), nextest ran the conformance workspace with--no-tests fail: 15/15 passed.openshell-test readyexited 0, andopenshell-test runpassed 15/15 and exited 0. Its JUnit report has oneconformancesuite with 15 test cases.CI coverage: Rust format, Rust lint and Rust test (x86_64-linux, aarch64-linux, aarch64-darwin) in Branch Checks build and test
tests/testkitandtests/openshell-testand lint the conformance suite. Branch E2E's conformance lanes run the moved suite under its new names; onf945820cf(the same three patches before #5078 merged) all five tmachine conformance rows and every host lane that runs conformance ran 15/15.Not verified locally: Linux x86_64 and musl, the non-Unix
runpath, and a plaintext gateway.Checklist
tests/testkit/README.md,TESTING.md,tests/suites/conformance/README.md