Skip to content

test: incremental coverage improvement iteration#32

Open
unhappychoice wants to merge 49 commits intomainfrom
coverage-up-20260503-062728
Open

test: incremental coverage improvement iteration#32
unhappychoice wants to merge 49 commits intomainfrom
coverage-up-20260503-062728

Conversation

@unhappychoice
Copy link
Copy Markdown
Owner

@unhappychoice unhappychoice commented May 3, 2026

Summary

  • Bump line/branch coverage across cache.rs, config.rs, display.rs, image_display.rs, main.rs, steam/{client,error,models,native}.rs via 50+ incremental commits (≈+4,250 / −22 LoC, almost entirely test code).
  • Sole production-code change: demo_stats in src/main.rs is now pub(crate) so the new mod tests can call it (the "visibility tweak" the PR description allows).
  • New #[cfg(test)] src/test_support.rs module exposing lock_env() — a single crate-wide mutex used by every env-mutating test sub-module, with poisoning recovered via into_inner so a panic in one test cannot cascade-fail unrelated tests.

Highlights

  • steam/client.rs — adds an in-process HTTP server (spawn_n_shot_server / spawn_sequential_server) to drive request_with_retry through 200 / 400 / 403 / 429 / 500 / connection-refused / timeout / truncated-body / retry-then-success paths.
  • steam/native.rs — covers NativeSteamClient::try_new None / load-failure / CreateInterface symbol-missing branches via a system-lib symlink, plus query_cell_size_ioctl short-circuits.
  • config.rs / image_display.rs / display.rs / cache.rs — exercise XDG_CACHE_HOME / HOME env precedence, create_default_config parent-missing & write-failure branches, AchievementCache serde round-trip incl. NaN/Inf, and image cache fs round-trips.
  • main.rs — adds demo_stats invariants (descending playtime, achievements ≤ possible, etc.) and Cli clap parsing tests.

Test plan

  • cargo build --tests — clean
  • cargo clippy --all-targets --all-features — clean
  • cargo fmt -- --check — clean
  • cargo test (default parallel scheduler) → 266 passed, 0 failed across 30 consecutive runs
  • CI on this branch: all 7 checks green (Check / Format / Clippy / Test / Build ubuntu+macos+windows)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 16 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f15e5333-82fb-4a8f-91e6-b7970af76e56

📥 Commits

Reviewing files that changed from the base of the PR and between 5a04225 and 2c8890a.

📒 Files selected for processing (10)
  • src/cache.rs
  • src/config.rs
  • src/display.rs
  • src/image_display.rs
  • src/main.rs
  • src/steam/client.rs
  • src/steam/error.rs
  • src/steam/models.rs
  • src/steam/native.rs
  • src/test_support.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch coverage-up-20260503-062728

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 13 minutes and 16 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@unhappychoice unhappychoice marked this pull request as ready for review May 3, 2026 15:38
…stable

Tests in cache.rs, config.rs, display.rs, image_display.rs, and steam/native.rs
each owned a private `static ENV_LOCK: Mutex<()>`, but they all mutate the same
process-wide environment (XDG_CACHE_HOME, HOME, STEAM_API_KEY, TERM_PROGRAM,
...). Module-local mutexes don't serialize across modules, so the default
parallel scheduler raced on env state — one panic poisoned a per-module
ENV_LOCK and cascaded into ~10 PoisonError failures in subsequent tests.

Introduce `crate::test_support::lock_env()`, a `#[cfg(test)]`-only helper that
returns a guard from a single crate-wide mutex and recovers from poisoning via
`unwrap_or_else(|e| e.into_inner())` — env state is restored by the existing
RAII scope guards even on panic, so a poisoned lock is safe to reuse. Each
test sub-module now imports `lock_env` instead of declaring its own static.

`cargo test` (default parallel) now passes 266/266 across 30 consecutive runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant