Test victory config policy exit status through the CLI #3074

Open
github-bot wants to merge 2 commits from github-bot/gh-3074 into main AGit
Owner

@⁠kyle7908 on GitHub · 2026-11-26 06:29 UTC · original
kyle7908:test/config-policy-cli → main · +149 −0 · 1 files · 2 commits · open

Summary

Add process-level regression coverage for victory config as a follow-up to #1830 and #831. Thanks to Ingenioeren for the production fix and for [inviting me to submit the CLI tests separately](#1830). These tests come from my earlier work in kyle7908/VIctory@a91e4dba5e, recovered from local commit 10ebac0.

The tests launch Cargo's built victory executable in a temporary directory. They cover clean paths, a single game_dir violation, a single test_title violation, and multiple cache/data violations.

They check the actual exit code, the resolved configuration and per-path diagnostics on stdout, and the counted error summary on stderr.

Following reviewer feedback, the tests now use unique temporary directories through std::env::temp_dir(), with reliable cleanup and no additional dependencies.

Both Cargo.toml and Cargo.lock match upstream main. The PR changes only apps/victory/tests/config.rs. #1830's production implementation is unchanged.

Validation

  • Native Windows 11, Rust 1.98.1, MSVC. Before #1830 (49761f9), the clean case passed and all three violation cases failed because the executable printed the policy diagnostics but exited 0.
  • On main at 63bcca4, all 41 tests in victory, victory-core, and xtask passed, including all four new CLI cases.
  • The four CLI cases also passed with --all-features.
  • Temporary-directory cleanup was verified after both successful runs and assertion failures.
  • Workspace Clippy passed with -D warnings for all targets under default and all features.
  • Package formatting, git diff --check, and staged and full asset-policy checks passed.
  • Hosted Windows CI passed for the updated commit 311a72c.

Local validation covered the relevant packages on Windows. The fixtures contain only temporary TOML, directories and empty repository markers. No game files or game-derived data were used.

AI disclosure. OpenAI Codex assisted with recovering the patch, source review, implementation, validation and preparation of this description.

**@⁠kyle7908** on GitHub · 2026-11-26 06:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074) `kyle7908:test/config-policy-cli` → `main` · +149 −0 · 1 files · 2 commits · open ## Summary Add process-level regression coverage for `victory config` as a follow-up to #1830 and #831. Thanks to Ingenioeren for the production fix and for [[inviting me to submit the CLI tests separately](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1830)](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1830). These tests come from my earlier work in kyle7908/VIctory@a91e4dba5e28a44bb54c8a30af61bd2978faf3d8, recovered from local commit `10ebac0`. The tests launch Cargo's built `victory` executable in a temporary directory. They cover clean paths, a single `game_dir` violation, a single `test_title` violation, and multiple cache/data violations. They check the actual exit code, the resolved configuration and per-path diagnostics on stdout, and the counted error summary on stderr. Following reviewer feedback, the tests now use unique temporary directories through `std::env::temp_dir()`, with reliable cleanup and no additional dependencies. Both `Cargo.toml` and `Cargo.lock` match upstream `main`. The PR changes only `apps/victory/tests/config.rs`. #1830's production implementation is unchanged. ## Validation - Native Windows 11, Rust 1.98.1, MSVC. Before #1830 (`49761f9`), the clean case passed and all three violation cases failed because the executable printed the policy diagnostics but exited `0`. - On `main` at `63bcca4`, all 41 tests in `victory`, `victory-core`, and `xtask` passed, including all four new CLI cases. - The four CLI cases also passed with `--all-features`. - Temporary-directory cleanup was verified after both successful runs and assertion failures. - Workspace Clippy passed with `-D warnings` for all targets under default and all features. - Package formatting, `git diff --check`, and staged and full asset-policy checks passed. - Hosted Windows CI passed for the updated commit `311a72c`. Local validation covered the relevant packages on Windows. The fixtures contain only temporary TOML, directories and empty repository markers. No game files or game-derived data were used. **AI disclosure.** OpenAI Codex assisted with recovering the patch, source review, implementation, validation and preparation of this description.
Exercise clean paths, single violations and multiple violations through the built CLI. Check the process exit code, resolved configuration and per-path diagnostics on stdout, and violation count on stderr.

Recover the CLI tests from 10ebac00ec21559948780c9941af8a99579f1794, adapted from kyle7908/VIctory@a91e4dba5e. Cover the implementation by Ingenioeren in Marvisak/VIctory#1830.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:54:52 +00:00
Author
Owner

@⁠kyle7908 on GitHub · 2026-11-26 06:37 UTC · original

@⁠kotekompotek Thanks for the thorough review and approval! Really appreciate your time.

**@⁠kyle7908** on GitHub · 2026-11-26 06:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074#issuecomment-7184614696) @⁠kotekompotek Thanks for the thorough review and approval! Really appreciate your time.
Follow the census fixture convention with a standard-library directory guard. Reserve a unique path for parallel tests, remove it on success or unwind, and keep the original CLI assertions. Restore both Cargo files to upstream.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 06:34 UTC · original · approved these changes

Verified: real end-to-end coverage — spawns CARGO_BIN_EXE_victory in a tempdir, asserts exit 0 vs 1, the exact one-line stderr summary (Option iterator eq trick is neat), each resolved path on stdout, and one POLICY VIOLATION line per marked dir. Env scrubbing covers the overrides that would make it nondeterministic.

**@⁠kotekompotek** on GitHub · 2026-11-26 06:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074#pullrequestreview-6069553119) · **approved these changes** Verified: real end-to-end coverage — spawns CARGO_BIN_EXE_victory in a tempdir, asserts exit 0 vs 1, the exact one-line stderr summary (Option iterator eq trick is neat), each resolved path on stdout, and one POLICY VIOLATION line per marked dir. Env scrubbing covers the overrides that would make it nondeterministic.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:23 UTC · original

Automated triage for the maintainers.

Verdict: needs work. This needs the maintainer's decision. The tests in apps/victory/tests/config.rs check what they should against main's show_config/check_policy (apps/victory/src/main.rs) and victory_core::ensure_outside_repo:

  • the exit code;
  • the per-path POLICY VIOLATION: lines;
  • the N configured path(s) violate the asset policy summary;
  • the .victory-root marker.

That is useful coverage of rule 1.

The PR adds a dev-dependency (tempfile) to apps/victory/Cargo.toml and changes Cargo.lock. Triage leaves dependency changes to the maintainer, even for a crate already in the workspace. The existing CLI tests (tests/census.rs) need no extra crate. A unique directory under std::env::temp_dir(), removed at the end, would avoid the dependency. That change, or the maintainer's approval of tempfile here, would make this a merge candidate.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074#issuecomment-7186538439) <!-- victory-triage v1 head=6f1141e6bd226cf67d8fe8cb37335da23fd6dd87 verdict=needs-work at=2026-11-26T08:18:50Z --> Automated triage for the maintainers. **Verdict: needs work. This needs the maintainer's decision.** The tests in `apps/victory/tests/config.rs` check what they should against main's `show_config`/`check_policy` (`apps/victory/src/main.rs`) and `victory_core::ensure_outside_repo`: - the exit code; - the per-path `POLICY VIOLATION:` lines; - the `N configured path(s) violate the asset policy` summary; - the `.victory-root` marker. That is useful coverage of rule 1. The PR adds a dev-dependency (`tempfile`) to `apps/victory/Cargo.toml` and changes `Cargo.lock`. Triage leaves dependency changes to the maintainer, even for a crate already in the workspace. The existing CLI tests (`tests/census.rs`) need no extra crate. A unique directory under `std::env::temp_dir()`, removed at the end, would avoid the dependency. That change, or the maintainer's approval of `tempfile` here, would make this a merge candidate. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kyle7908 on GitHub · 2026-11-26 08:32 UTC · original

Thanks for flagging the dependency concern.

I've removed tempfile and switched the four CLI tests to unique directories under std::env::temp_dir(), following the existing census test convention. All four tests and their assertions are preserved, and both Cargo.toml and Cargo.lock now match upstream main.

All 41 relevant tests passed locally on Windows, including the four CLI cases with all features enabled. Temporary-directory cleanup, formatting, Clippy and asset-policy checks also passed.

The latest hosted Windows CI check is now passing.

Thanks again for the review!

**@⁠kyle7908** on GitHub · 2026-11-26 08:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074#issuecomment-7186726256) Thanks for flagging the dependency concern. I've removed `tempfile` and switched the four CLI tests to unique directories under `std::env::temp_dir()`, following the existing census test convention. All four tests and their assertions are preserved, and both `Cargo.toml` and `Cargo.lock` now match upstream `main`. All 41 relevant tests passed locally on Windows, including the four CLI cases with all features enabled. Temporary-directory cleanup, formatting, Clippy and asset-policy checks also passed. The latest hosted Windows CI check is now passing. Thanks again for the review!
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:56 UTC · original · approved these changes

Verified 311a72c3 locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings and --all-features: clean (0.77s / 3.57s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory -p victory-core -p xtask --locked: 41 passed, 0 failed (22 in victory including all 4 tests/config.rs cases, 13 in victory-core, 6 in xtask, 2.73s).
  • cargo test -p victory --all-features --locked: 22 passed, 0 failed (2.64s).
  • rustfmt --edition 2024 --check apps/victory/tests/config.rs: clean.

Cargo.toml and Cargo.lock now match main cleanly, leaving apps/victory/tests/config.rs as the sole file. ScratchDir allocates unique per-test directories atomically via create_dir retry with AtomicUsize + PID + timestamp and cleans up cleanly in Drop without masking test panics. (Optional nit: in the panicking() branch of Drop, let _ = writeln!(std::io::stderr(), ...); avoids any theoretical double-panic if stderr write fails.)

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3074#pullrequestreview-6071053490) · **approved these changes** Verified `311a72c3` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings` and `--all-features`: clean (`0.77s` / `3.57s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). - `cargo test -p victory -p victory-core -p xtask --locked`: 41 passed, 0 failed (`22` in `victory` including all 4 `tests/config.rs` cases, `13` in `victory-core`, `6` in `xtask`, `2.73s`). - `cargo test -p victory --all-features --locked`: 22 passed, 0 failed (`2.64s`). - `rustfmt --edition 2024 --check apps/victory/tests/config.rs`: clean. `Cargo.toml` and `Cargo.lock` now match `main` cleanly, leaving `apps/victory/tests/config.rs` as the sole file. `ScratchDir` allocates unique per-test directories atomically via `create_dir` retry with `AtomicUsize` + PID + timestamp and cleans up cleanly in `Drop` without masking test panics. (Optional nit: in the `panicking()` branch of `Drop`, `let _ = writeln!(std::io::stderr(), ...);` avoids any theoretical double-panic if stderr write fails.) LGTM.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3074/head:github-bot/gh-3074'
git switch 'github-bot/gh-3074'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3074'
git switch 'github-bot/gh-3074'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3074'
git switch 'github-bot/gh-3074'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3074'
git switch 'main'
git merge --squash 'github-bot/gh-3074'
git switch 'main'
git merge --ff-only 'github-bot/gh-3074'
git switch 'main'
git merge 'github-bot/gh-3074'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3074
No description provided.