Skip to content

test: replace custom cfg with TEST_SKIP environment variable#372

Merged
KSXGitHub merged 3 commits intomasterfrom
claude/review-test-skip-mechanism-eEIPx
Mar 25, 2026
Merged

test: replace custom cfg with TEST_SKIP environment variable#372
KSXGitHub merged 3 commits intomasterfrom
claude/review-test-skip-mechanism-eEIPx

Conversation

@KSXGitHub
Copy link
Copy Markdown
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
Copy Markdown

github-actions bot commented Mar 24, 2026

Performance Regression Reports

commit: c4a33e3

--quantity=apparent-size --max-depth=1 --min-ratio=0.01
Command Mean [ms] Min [ms] Max [ms] Relative
pdu 120.1 ± 13.3 95.1 132.3 1.25 ± 0.14
pdu-0.20.0 95.8 ± 0.4 95.1 97.0 1.00
Logs
Benchmark 1: pdu
  Time (mean ± σ):     120.1 ms ±  13.3 ms    [User: 88.6 ms, System: 286.5 ms]
  Range (min … max):    95.1 ms … 132.3 ms    23 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark 2: pdu-0.20.0
  Time (mean ± σ):      95.8 ms ±   0.4 ms    [User: 93.0 ms, System: 280.8 ms]
  Range (min … max):    95.1 ms …  97.0 ms    31 runs
 
Summary
  pdu-0.20.0 ran
    1.25 ± 0.14 times faster than pdu
JSON
{
  "results": [
    {
      "command": "pdu",
      "mean": 0.12006047361217392,
      "stddev": 0.013343557065973555,
      "median": 0.12705781496000002,
      "user": 0.08860871739130434,
      "system": 0.28654005217391304,
      "min": 0.09510904396,
      "max": 0.13226357696000002,
      "times": [
        0.12774852796000002,
        0.12691368096000002,
        0.12205733196,
        0.12771803096,
        0.12698449196000003,
        0.12590222896000003,
        0.13226357696000002,
        0.12772239096000002,
        0.12743405396000002,
        0.12705781496000002,
        0.12684034196000002,
        0.12713915596000003,
        0.12754833296,
        0.12750079696000002,
        0.12771375496,
        0.12733985696000003,
        0.12743210996,
        0.11984200396,
        0.09606498796,
        0.09659742696,
        0.09530366496,
        0.09515728596,
        0.09510904396
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    },
    {
      "command": "pdu-0.20.0",
      "mean": 0.0958133803470968,
      "stddev": 0.00044423652271469643,
      "median": 0.09582443196,
      "user": 0.09303498387096773,
      "system": 0.28079410967741936,
      "min": 0.09505560496,
      "max": 0.09696005896,
      "times": [
        0.09518470396,
        0.09599715196,
        0.09564958696,
        0.09586240196,
        0.09598966796,
        0.09640742096,
        0.09532143996,
        0.09547397796,
        0.09531694296,
        0.09532619696,
        0.09600397496,
        0.09598114196,
        0.09696005896,
        0.09505560496,
        0.09534498196,
        0.09585327496,
        0.09608002596,
        0.09582443196,
        0.09615227996,
        0.09627631996,
        0.09563300696,
        0.09543804396,
        0.09588356896,
        0.09559013596,
        0.09546652696,
        0.09611445896,
        0.09582058696,
        0.09662026896,
        0.09549784596,
        0.09561676596,
        0.09647199396
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    }
  ]
}

Copy link
Copy Markdown
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.

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
Copy link
Copy Markdown
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

@KSXGitHub KSXGitHub marked this pull request as ready for review March 25, 2026 01:33
@KSXGitHub KSXGitHub marked this pull request as draft March 25, 2026 01:37
The paragraph framed TEST_SKIP as a general policy for writing new
tests, but there is only one such test. The test's own panic hint
and the existing note in the test-running section already provide
sufficient guidance.

https://claude.ai/code/session_01UBzLwHNmqEC2SafFKjEqYz
@KSXGitHub KSXGitHub requested a review from Copilot March 25, 2026 01:49
@KSXGitHub KSXGitHub marked this pull request as ready for review March 25, 2026 01:52
Copy link
Copy Markdown
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

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

@KSXGitHub KSXGitHub merged commit d4a9774 into master Mar 25, 2026
16 of 17 checks passed
@KSXGitHub KSXGitHub deleted the claude/review-test-skip-mechanism-eEIPx branch March 25, 2026 01:58
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