test(store-types): reach the HOME tier on every platform, cover APPDATA on Windows - #18
Conversation
|
What the first commit proved. The Windows failure moved from What was still red, and why nothing in the resolver should move. Tier 4 is The daemon's So the assertions were wrong, not the code. They now select platform-specific literals: #[cfg(not(windows))]
assert_eq!(got, "/tmp/home-test/.local/share/cortexkit/astrocyte/store.db");
#[cfg(windows)]
{
// PathBuf joins the data-home tier while module paths retain the
// daemon's forward slashes, so this mixed form is byte-identical.
assert_eq!(got, "/tmp/home-test\\.local\\share/cortexkit/astrocyte/store.db");
}Literals rather than rebuilding the expectation with 85 lines added, zero removed, across both commits. No production function touched. Locally: tests, clippy |
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/cortexkit-store-types/src/lib.rs">
<violation number="1" location="crates/cortexkit-store-types/src/lib.rs:340">
P2: On Windows these tests now reach the HOME tier (the new APPDATA/USERPROFILE removal forces it), but they still assert forward-slash paths like "/tmp/home-test/.local/share/...". On Windows the resolver's HOME branch does `PathBuf::from(home).join(".local").join("share")`, and PathBuf joins use the platform separator `\`. The crate's own golden fixture pins this: `windows_empty_appdata_userprofile_falls_to_home` → `C:/golden-home\.local\\share`. So on Windows `module_store_path` returns a string containing a backslash-joined `.local\share` component (e.g. `\tmp\home-test\.local\share/cortexkit/...`), which never equals the asserted forward-slash string — the asserted changed tests (`module_store_path_defaults_to_home_local_share` and `empty_env_values_count_as_unset`) will still fail on Windows CI. The fix needs to assert a Windows-aware expected string (or gate the forward-slash expectation off Windows) to match the golden/daemon contract.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| std::env::remove_var("XDG_DATA_HOME"); | ||
| #[cfg(windows)] | ||
| { | ||
| std::env::remove_var("APPDATA"); |
There was a problem hiding this comment.
P2: On Windows these tests now reach the HOME tier (the new APPDATA/USERPROFILE removal forces it), but they still assert forward-slash paths like "/tmp/home-test/.local/share/...". On Windows the resolver's HOME branch does PathBuf::from(home).join(".local").join("share"), and PathBuf joins use the platform separator \. The crate's own golden fixture pins this: windows_empty_appdata_userprofile_falls_to_home → C:/golden-home\.local\\share. So on Windows module_store_path returns a string containing a backslash-joined .local\share component (e.g. \tmp\home-test\.local\share/cortexkit/...), which never equals the asserted forward-slash string — the asserted changed tests (module_store_path_defaults_to_home_local_share and empty_env_values_count_as_unset) will still fail on Windows CI. The fix needs to assert a Windows-aware expected string (or gate the forward-slash expectation off Windows) to match the golden/daemon contract.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/cortexkit-store-types/src/lib.rs, line 340:
<comment>On Windows these tests now reach the HOME tier (the new APPDATA/USERPROFILE removal forces it), but they still assert forward-slash paths like "/tmp/home-test/.local/share/...". On Windows the resolver's HOME branch does `PathBuf::from(home).join(".local").join("share")`, and PathBuf joins use the platform separator `\`. The crate's own golden fixture pins this: `windows_empty_appdata_userprofile_falls_to_home` → `C:/golden-home\.local\\share`. So on Windows `module_store_path` returns a string containing a backslash-joined `.local\share` component (e.g. `\tmp\home-test\.local\share/cortexkit/...`), which never equals the asserted forward-slash string — the asserted changed tests (`module_store_path_defaults_to_home_local_share` and `empty_env_values_count_as_unset`) will still fail on Windows CI. The fix needs to assert a Windows-aware expected string (or gate the forward-slash expectation off Windows) to match the golden/daemon contract.</comment>
<file context>
@@ -330,9 +330,29 @@ mod resolver_tests {
std::env::remove_var("XDG_DATA_HOME");
+ #[cfg(windows)]
+ {
+ std::env::remove_var("APPDATA");
+ std::env::remove_var("USERPROFILE");
+ }
</file context>
|
Windows is green. All four checks pass on That is the part I could not verify locally, so recording the outcome rather than leaving the PR asserting an untested claim:
Both halves needed Windows to prove anything. The tier-2 test cannot run anywhere else, and the tier-4 tests were passing on Linux the whole time while asserting something that was never exercised there. Master is still red until this merges — the two failures on master are the same two tests, and PR #14's Windows check is inheriting them through its merge commit rather than from anything in that branch. One note for whoever reads the diff later: the is correct and load-bearing. |
|
Reviewed and merging. The substance is exactly right: the two HOME-tier tests never controlled APPDATA/USERPROFILE, which Windows runners always set — so the resolver's (correct) Windows preference shadowed the tier the tests meant to reach, and master went red on a platform the authoring machine cannot run. Your save/clear/restore under the existing lock is the right shape, the mixed-separator assertion comment (PathBuf joins the data-home tier, module paths keep the daemon's forward slashes) documents a byte-level fact the next reader would otherwise misread as a bug, and the APPDATA-preference test closes the arm that had no coverage at all — the missing-coverage half of this incident, since a Windows-arm test would have caught the original commit at authoring time. One note for the record rather than a change request: the save/restore boilerplate now appears three times; if a fourth env-sensitive test lands, an RAII guard is the move (restore-on-drop also survives assert panics, which the manual restores do not — a failing assertion currently leaks the cleared vars into later tests on the same thread). Not blocking on it. This unblocks the cortexkit-provider-usage-v0.7.0 publish, which failed precisely because your target was red — the tag rides the merge. |
|
Thanks for merging, and for the RAII note — the conclusion is right and I want to correct the reason, because the version in the note would send someone hunting for a bug that is not there. Assert panics do not currently leak. Every env-sensitive test in the module, including the two I touched and the one I added, follows the same order: mutate, capture the result, restore, then assert. Checked against the merged file at
There is still a real leak window, and RAII still closes it. If the code under test panics — Your trigger is also already met, by a count. You read three instances of the boilerplate; there are five env-sensitive tests, three of them carrying the full save/clear/restore. The fourth-test condition has effectively arrived. Happy to send the guard as a follow-up if you want it — Good to hear it unblocks the |
Fixes #17. Test-only: Windows CI has been red on master since
ecaec0f.What was wrong
resolve_data_home_pathhas four tiers —XDG_DATA_HOME, thenAPPDATAandUSERPROFILEunder#[cfg(windows)], thenHOME+.local/share. Two tests setHOMEand assert the tier-4 result, but a Windows runner always hasAPPDATAset, so tier 2 fires and tier 4 is never reached.The resolver is correct and this change does not touch it. The subc seat confirmed the daemon's
default_data_homeat source: same four tiers, same order,XDG_DATA_HOMEoutrankingAPPDATAeven on Windows. Removing the#[cfg(windows)]block — which the issue's original framing left open as a possibility — would have created the divergence this crate exists to prevent.The forward-slash
format!joining inmodule_data_dir/sqlite_store_pathis also untouched. It looks like a POSIX assumption and is deliberate byte-identity with the daemon's wire descriptors; aPathBuf::jointhere would break byte-match with the daemon and with every store already on disk.What changed
1. The HOME-tier tests now reach the HOME tier on every platform. Under
#[cfg(windows)]they clear and restoreAPPDATAandUSERPROFILEso tier 4 is actually exercised, using the sameENV_LOCKdiscipline the module already has. The assertions are unchanged — they were always testing the right thing, just only where the Windows tiers happen not to exist.2. Tier 2 gains its first test.
module_store_path_prefers_appdata_over_homesets bothAPPDATAandHOMEand asserts the APPDATA-derived result wins. That is the tier every real Windows deployment uses and it had no coverage at all — which is why nothing caught the precedence mismatch from the other direction either.Gating the two failing tests behind
#[cfg(not(windows))]would also turn CI green, and would leave that hole open. Both parts land together for that reason.68 lines added, 0 removed, confined to the
resolver_testsmodule.Verification, and one honest gap
Locally verified on Linux:
cargo test -p cortexkit-store-typesgreen,cargo clippy -- -D warningsclean,cargo fmt --checkclean.The Windows behaviour is not locally verified. This box has no rustup and no Windows target installed, so I could not even cross-compile-check the new
#[cfg(windows)]test. CI is the only thing that can prove either part works there, and I would rather say so than imply I tested it. If the Windows job is still red after this, the diagnosis in #17 is right but my fix for it is not, and I will take another pass.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Exercises the HOME tier in resolver tests on Windows and adds APPDATA precedence coverage; updates Windows assertions to match platform separators. Stabilizes Windows CI without changing resolver behavior.
APPDATAandUSERPROFILE, clear them to reach HOME, usingENV_LOCK.module_store_path_prefers_appdata_over_homeasserting APPDATA outranks HOME.crates/cortexkit-store-types/src/lib.rs).Written for commit 634a2d4. Summary will update on new commits.