Skip to content

fix(test): point USERPROFILE at the temp home on Windows - #1261

Open
anhtahaylove wants to merge 1 commit into
rohitg00:mainfrom
anhtahaylove:fix/windows-test-homedir
Open

fix(test): point USERPROFILE at the temp home on Windows#1261
anhtahaylove wants to merge 1 commit into
rohitg00:mainfrom
anhtahaylove:fix/windows-test-homedir

Conversation

@anhtahaylove

@anhtahaylove anhtahaylove commented Aug 26, 2026

Copy link
Copy Markdown

Two tests in test/slots-flag-gate.test.ts fail on Windows for anyone whose own ~/.agentmemory/.env sets AGENTMEMORY_SLOTS or AGENTMEMORY_REFLECT to false.

Cause

beforeEach creates a temp home and points HOME at it, but src/functions/slots.js resolves the config path through os.homedir() — and on Windows that reads USERPROFILE, ignoring HOME entirely:

> process.env.HOME = 'C:/tmp/fake-home'
> os.homedir()
'C:\Users\Administrator'

So the flag is read from the developer's real .env rather than the temp file the test just wrote. CI is green because HOME and USERPROFILE agree on Linux.

Fix

Set USERPROFILE alongside HOME in both describe blocks and restore it in afterEach.

Verification

On a clean checkout of main, Windows:

before: Tests  2 failed | 2 passed (4)
after:  Tests  4 passed (4)

slots-flag-gate is the only test file that overrides HOME without USERPROFILE — the other nine already set both, so this brings it in line with them.

Summary by CodeRabbit

  • Tests
    • Improved cross-platform test reliability by ensuring temporary home-directory settings work correctly on Windows.
    • Added cleanup to restore the original environment after each test.

`os.homedir()` reads USERPROFILE on Windows and ignores HOME, so these
two tests read the developer's real ~/.agentmemory/.env instead of the
temp one they wrote. Anyone whose own .env sets AGENTMEMORY_SLOTS or
AGENTMEMORY_REFLECT to false fails them; CI passes because HOME and
USERPROFILE agree on Linux.

Sets both, and restores both afterwards.

Signed-off-by: anhtahaylove <everest.kill1@gmail.com>
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@anhtahaylove is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 52446778-db5c-4deb-afb0-2d41c3d7b48a

📥 Commits

Reviewing files that changed from the base of the PR and between e04ba88 and ff96b87.

📒 Files selected for processing (1)
  • test/slots-flag-gate.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The test setup now controls both HOME and USERPROFILE. This ensures os.homedir() uses the temporary directory on Windows. Each test restores the original environment values.

Changes

Cross-platform test isolation

Layer / File(s) Summary
Home directory environment setup
test/slots-flag-gate.test.ts
Both test suites capture, set, and restore USERPROFILE alongside HOME.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ff96b

This change makes the Windows tests use the temporary home directory consistently; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: setting USERPROFILE to the temporary home directory for Windows tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@anhtahaylove

Copy link
Copy Markdown
Author

Context for this one: #1264 audits the whole Windows test picture — 30 failures, what causes each group, and which PR covers it.

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