Repository navigation
Run tests/common selftests once, not in 118 binaries - #2000
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
The oracle, cache_env and jvm_env selftests (20 tests) sat ungated in tests/common, so every one of the 118 integration binaries that declares `mod common` compiled and re-ran them, and the 25 that include cache_env.rs directly ran its 10 again: about 2,600 redundant test runs per `cargo test`, each failure reported once per binary. Move the three modules verbatim into tests/common_selftests.rs, which includes common/mod.rs once. The four private cache_env items they use become pub(crate). The envelope re-exports in common/mod.rs were only used everywhere because of the oracle selftest; allow unused_imports there so includers that never read envelopes don't warn. Drop the comments claiming integration crates lack cfg(test); they do set it, so the gate would not have helped either. Fixes #1957. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aePuuKNcXTPE2Z4nq1H
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 31b91ca. Configure here.
|
Labeled Ready for review by the burn-down agent.
Slack announcement could not be sent this run (Slack send tool unavailable); a later run will retry. Generated by Claude Code |
Final review briefWhat it does: Moves the 20 self-tests for the shared test helpers (oracle ×8, Risk: low. The diff only touches test files, the moved test bodies are unchanged, and the new target is auto-discovered by Look here
Verified
Changes I made: none. Open questions: none. The follow-up the PR mentions (dropping the 25 direct Auto-merge is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Problem
Fixes #1957. The 20 selftests for the shared test helpers (
oracle_selftests×8 incommon/mod.rs,cache_env_selftests×10,jvm_env_selftests×2) were left ungated, so every integration binary that declaresmod common(118 of them) compiled and re-ran all 20. The 25 binaries that also includecommon/cache_env.rsdirectly ran its 10 a second time. That adds up to about 2,600 redundant test runs percargo test, and a broken helper was reported once per binary rather than once. (The issue says 21; one of those#[test]matches is inside a comment.)CI context for this run: the merge queue is empty, nothing is queued or in progress, and main push and merge_group are green. Every nightly failure from the last 5 days is already fixed on main (#1994, #1914, #1891, #1905) or covered by the open #1999. No flakes or reruns turned up since 10-31. That leaves redundancy (priority 3) as the highest-value target.
Fix
tests/common_selftests.rs, which includescommon/mod.rsonce. The only change inside them isuse super::*→use crate::common::{,cache_env::,jvm_env::}*plus the std imports they used to inherit.cache_envitems those tests touch (TOOLCHAIN_ROOTS,parent_var_names,scrub_parent_vars,is_ambient_vlt_tool_var) topub(crate).common/mod.rs'spub use envelope::{…}was "used" in every binary only because of the oracle selftest. It now carries#[allow(unused_imports)], so includers that never read envelopes don't get a new warning.cfg(test)" comments inmod.rs,cache_env.rsandbundler_e2e.rs. They do set it; gating still wouldn't help, because every includer is a test crate.Not done here: dropping the 25 direct
#[path = "common/cache_env.rs"]includes. They no longer run tests, so that change only saves compile time and touches 25 files. It can go in a follow-up.Proof
cargo test -p socket-patch-cli --test common_selftests: 20 passed (8 + 10 + 2, which matches the count of real#[test]attributes in the three modules on main).cargo test -p socket-patch-cli --test cli_apply_silent -- --list: 0 selftests listed (the issue measured 27 listed for 7 owned on main).cargo check -p socket-patch-cli --all-targets --all-features: no warnings or errors intests/common/*or the new file across every test target.cargo clippy -p socket-patch-cli --test common_selftests --test cli_apply_silent --test e2e_bun_lockb --test e2e_golang_workspace_build -- -D warnings: clean except for 7 pre-existing lints in the untouchedprebuilt_common/mod.rs(CI's clippy job doesn't lint test targets).rustfmt --checkon the touched files passes.Where the moved tests run
Same place as before:
test/coverageruncargo testover every test target, andcommon_selftestsis auto-discovered. They now run once per leg instead of about 130 times. No test was removed and no assertion changed.Generated by Claude Code
Note
Low Risk
Test-harness refactor only; no production or CLI behavior changes, and assertions were moved verbatim.
Overview
Fixes redundant execution of shared test-helper selftests (#1957) by moving 20 checks (oracle,
cache_env,jvm_env) out oftests/common/*into a dedicatedtests/common_selftests.rsintegration target that includescommon/mod.rsonce.Integration binaries that only
mod commonno longer compile or run those selftests (~2,600 duplicate runs per fullcargo test); failures surface once instead of per binary. Test logic is unchanged aside from import paths (crate::common::…).Supporting tweaks:
pub(crate)on fourcache_envsymbols the selftests need,#[allow(unused_imports)]on envelope re-exports now unused in most binaries, and trimmed misleadingcfg(test)comments inbundler_e2e.rs. The bundlerversion_grammarselftest stays inbundler_e2e.rs.Reviewed by Cursor Bugbot for commit 31b91ca. Configure here.
Generated by Claude Code