Skip to content

test: replace custom cfg with TEST_SKIP environment variable#372

Draft
KSXGitHub wants to merge 2 commits intomasterfrom
claude/review-test-skip-mechanism-eEIPx
Draft

test: replace custom cfg with TEST_SKIP environment variable#372
KSXGitHub wants to merge 2 commits intomasterfrom
claude/review-test-skip-mechanism-eEIPx

Conversation

@KSXGitHub
Copy link
Owner

Summary

This PR replaces the custom --cfg pdu_test_skip_* mechanism with a simpler TEST_SKIP environment variable for skipping tests at runtime. This avoids unnecessary recompilation when tests need to be skipped based on runtime conditions.

Key Changes

  • test.sh: Added support for TEST_SKIP environment variable that accepts space-separated test names and passes them to cargo test via --skip flags
  • tests/cli_errors.rs: Removed #[cfg_attr(pdu_test_skip_fs_errors, ignore)] and updated the error hint to use TEST_SKIP='fs_errors' instead of RUSTFLAGS='--cfg pdu_test_skip_fs_errors'
  • Cargo.toml: Removed the [lints.rust] section that declared the pdu_test_skip_fs_errors cfg as expected
  • CONTRIBUTING.md: Updated test skipping guidance to recommend TEST_SKIP for runtime environment conditions and removed the example using custom cfg flags
  • Documentation: Updated CONTRIBUTING.md, CLAUDE.md, AGENTS.md, and shared AI instructions to reference TEST_SKIP instead of RUSTFLAGS and custom cfg flags

Implementation Details

The test.sh script now:

  1. Reads the TEST_SKIP environment variable as a space-separated list
  2. Converts each test name into a --skip argument
  3. Passes these arguments to cargo test only when skip arguments are present

This approach allows tests to remain compiled on all configurations (catching type errors early) while being skipped at runtime based on environment conditions, without requiring recompilation.

https://claude.ai/code/session_01UBzLwHNmqEC2SafFKjEqYz

…` env var

The custom cfg flag required `RUSTFLAGS` which forced full recompilation
just to skip a test. The new `TEST_SKIP` env var passes `--skip` to the
test binary at runtime, avoiding any recompilation.

https://claude.ai/code/session_01UBzLwHNmqEC2SafFKjEqYz
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Performance Regression Reports

commit: 35df1aa

There are no regressions.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the repo’s “skip certain integration tests” workflow from compile-time custom --cfg pdu_test_skip_* flags to a runtime TEST_SKIP environment variable, aiming to avoid recompilation when skipping environment-dependent tests.

Changes:

  • Add TEST_SKIP handling to test.sh, translating names into libtest --skip arguments.
  • Update the fs_errors test hint to reference TEST_SKIP and remove the custom cfg-based ignore.
  • Remove the Cargo.toml unexpected_cfgs allowance and update developer/AI docs to the new mechanism.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/cli_errors.rs Removes cfg-based ignore and updates the root-run hint to use TEST_SKIP.
test.sh Parses TEST_SKIP and conditionally appends libtest --skip args to cargo test.
template/ai-instructions/shared.md Updates guidance to reference TEST_SKIP instead of custom cfg flags.
README.md Documents the new TEST_SKIP environment variable for test.sh.
Cargo.toml Removes unexpected_cfgs configuration for the deleted custom cfg.
CONTRIBUTING.md Updates test-skipping guidance to prefer TEST_SKIP for runtime-environment skips.
CLAUDE.md Syncs AI instructions to reference TEST_SKIP.
AGENTS.md Syncs AI instructions to reference TEST_SKIP.
.github/copilot-instructions.md Syncs AI instructions to reference TEST_SKIP.

"{}\n{}",
"error: This test must not be run as root because running with elevated privileges would affect its accuracy.",
"hint: Either run this test as a non-root user or set `RUSTFLAGS='--cfg pdu_test_skip_fs_errors'` to skip this test.",
"hint: Either run this test as a non-root user or set `TEST_SKIP='fs_errors'` to skip this test.",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The panic hint suggests setting TEST_SKIP='fs_errors', but TEST_SKIP is only interpreted by ./test.sh (and is otherwise ignored by cargo test). Consider adjusting the hint to explicitly mention rerunning via ./test.sh (or alternatively, check TEST_SKIP within the test and return early when it contains fs_errors) so the guidance works regardless of how the test is invoked.

Suggested change
"hint: Either run this test as a non-root user or set `TEST_SKIP='fs_errors'` to skip this test.",
"hint: Either run this test as a non-root user or rerun via `TEST_SKIP='fs_errors' ./test.sh` to skip this test.",

Copilot uses AI. Check for mistakes.
The TEST_SKIP variable is only interpreted by test.sh, not by cargo
test directly. Update the hint to say "rerun via ./test.sh" so users
know exactly how to invoke it.

https://claude.ai/code/session_01UBzLwHNmqEC2SafFKjEqYz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants