Skip to content

Commit 4fa4e11

Browse files
committed
itest: Add output capture, metadata emission, proc macro, VM resource capping
Major feature expansion of the itest integration test framework to make it reusable across bootc-dev projects (bcvk, composefs-rs, bootc). Fork-exec output capture: when not under nextest or tmt, the harness re-executes itself per test to capture stdout/stderr, preventing interleaved output from parallel tests. Test metadata: --emit-tmt and --emit-autopkgtest flags generate FMF and DEP-8 metadata from registered tests, enabling tmt and autopkgtest to discover and run individual tests. Per-test TestMeta (timeout, needs_root, isolation, tags, flaky, etc.) maps to format-specific fields. Verified end-to-end with tmt. Proc macro: #[itest::test_attr] attribute macro replaces the declarative macros. Preserves doc comments, auto-converts error types (anyhow/eyre compatible), detects async fn and wraps with a tokio runtime, and accepts all metadata as attribute arguments. VM resource capping: when no explicit --itype is set, itest detects host memory (from /proc/meminfo and cgroup v2/v1 limits) and caps the VM to 70% of available memory. Prevents OOM on constrained CI runners like GHA (7 GiB / 2 vCPU). Override via ITEST_VM_MEMORY_MIB, ITEST_VM_VCPUS, or ITEST_VM_MEMORY_FRACTION. Spiked on composefs-rs: 43 tests migrated, net -120 lines deleted, all tests pass. Assisted-by: OpenCode (Claude Opus 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 4a4f5c6 commit 4fa4e11

File tree

12 files changed

+2432
-66
lines changed

12 files changed

+2432
-66
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ unit *ARGS:
2424
pull-test-images:
2525
podman pull -q {{ALL_BASE_IMAGES}} >/dev/null
2626

27-
# Run integration tests (auto-detects nextest, with cleanup)
27+
# Run integration tests (prefers cargo-nextest, falls back to cargo test with
28+
# built-in fork-exec output capture)
2829
test-integration *ARGS: build pull-test-images
2930
#!/usr/bin/env bash
3031
set -euo pipefail
@@ -36,16 +37,15 @@ test-integration *ARGS: build pull-test-images
3637
# Clean up any leftover containers before starting
3738
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
3839

39-
# Run the tests
40+
# Prefer nextest for better UX (retries, timing, etc.), but the harness
41+
# captures output itself via fork-exec so cargo test works too.
4042
if command -v cargo-nextest &> /dev/null; then
41-
cargo nextest run --release -P integration -p integration-tests {{ ARGS }}
42-
TEST_EXIT_CODE=$?
43+
cargo nextest run --release -P integration -p integration-tests {{ ARGS }} && TEST_EXIT_CODE=0 || TEST_EXIT_CODE=$?
4344
else
44-
cargo test --release -p integration-tests -- {{ ARGS }}
45-
TEST_EXIT_CODE=$?
45+
cargo test --release -p integration-tests -- {{ ARGS }} && TEST_EXIT_CODE=0 || TEST_EXIT_CODE=$?
4646
fi
4747

48-
# Clean up containers after tests complete
48+
# Clean up containers after tests complete (must run even on failure)
4949
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
5050

5151
exit $TEST_EXIT_CODE

crates/itest-macros/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "itest-macros"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
description = "Proc-macro companion crate for itest"
7+
8+
[lib]
9+
proc-macro = true
10+
11+
[dependencies]
12+
proc-macro2 = "1"
13+
quote = "1"
14+
syn = { version = "2", features = ["full", "extra-traits"] }
15+
16+
[lints]
17+
workspace = true

0 commit comments

Comments
 (0)