Repository navigation
fix(test): add TestMain to isolate cmd/opencodereview from the real home - #1707
Open
JasonBuildAI wants to merge 1 commit into
Open
JasonBuildAI wants to merge 1 commit into
JasonBuildAI wants to merge 1 commit into
Conversation
Contributor
|
✅ OpenCodeReview: Review skipped: no items were selected. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Running the
cmd/opencodereviewtest binary on Windows no longer writes review session files into the developer's real~/.opencodereview/sessions/. A package-levelTestMainredirectsHOMEandUSERPROFILEto a temporary directory for every test in the package.Value: anyone running
go test ./cmd/opencodereview/(ormake test) on Windows keeps their real session history, and theocr viewersession list, free of test-generated entries.os.UserHomeDir()resolvesUSERPROFILEon Windows, notHOME, so the 13t.Setenv("HOME", t.TempDir())call sites in this package never redirected the home there. Follow-up to #1416, which added this guard tointernal/session,internal/agent,internal/llmloopandinternal/scan:cmd/opencodereviewwas the remaining package without it.Fixes #1706
Type of Change
How Has This Been Tested?
Windows 11 (NT 10.0.26200.0), Go 1.26.9 windows/amd64, at commit 357c3f0. Method: snapshot the file list under
%USERPROFILE%\.opencodereview, run the command, compare.Unmodified
main, targeted run:go test -count=1 -run 'TestRunSessionCompare|TestSessionCompareCompletesBothPositionals|TestScanBudgetJSON|TestValidateResumeIdentity' ./cmd/opencodereview/-> 23 files added under
%USERPROFILE%\.opencodereview\sessions\, e.g.\sessions\D_Temp-TestRunSessionCompare_TextShowsCounts4049144688-002\153542f9-98b3-45b3-8ec2-841d065d66f1.jsonl\sessions\D_Temp-TestScanBudgetJSONbudget_stop_sets_budget_exceeded724104049-003\40e1a7a3-1ee4-4aaf-ab8b-4d4aaa3e82ba.jsonlWith this change:
go test -count=1 ./cmd/opencodereview/->ok github.com/alibaba/open-code-review/cmd/opencodereview 145.738s, 0 files added, 0 removedmake test(full suite,-race) -> exit 0, all 24 packagesok, 0 files added, 0 removedmake check-> exit 0;make build-> exit 0%USERPROFILE%\.opencodereview\config.jsonunchanged: sha256156BEFAFC67A6C486910E9D6D42D72EEB4DF705B2A71CE2481B3675A3E7F5C0Cbefore and aftermake testpasses locallyChecklist
go fmt,go vet) -make checkpassedAI/LLM disclosure: investigated and drafted with the OpenAI Codex desktop agent (Codex CLI 0.162.0-alpha.17.2, GPT-5-class model), used at my request under constraints I set. I reproduced the leak, ran every command quoted above, and reviewed the full diff and this description before requesting review.
Related Issues
Fixes #1706