fix(cli): run unit and integration tests, and every mutant, in a throwaway home - #832
Merged
Merged
Conversation
…waway home A test that relocated only AIDD_USER_CONFIG_DIR was one mutant away from the real profile: a mutant dropping that override sent it to ~/.config/aidd of whoever ran the mutation. The mutant was killed, and the file was already written. One run left a test marketplace entry in a real registry, and another overwrote a real auth.json with a test token. A global setup, shared by the suite's and the mutation run's unit and integration projects, points HOME, USERPROFILE and APPDATA at a temp home and unsets the overrides, so every route to a profile ends there. It runs in the main process because Stryker runs vitest in worker threads: a thread's own process.env never reaches os.homedir(), so a per-file setup left that route on the real home. One test proves what a test sees, in threads and in forks. One proves all four projects declare the setup. Fixes #831 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb AIDD-Session-Id: 4acc9a1c-19bc-4468-b8b6-e86644bcba60
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.
🎯 What & why
A unit or integration test that relocated only
AIDD_USER_CONFIG_DIRwas one mutant away from the real profile. A Stryker mutant that drops that override sends the test to~/.config/aiddof whoever runs the mutation. The mutant is killed, because the test fails, but the file is already written. On one machine this left a test marketplace entry (/src/framework) in the real registry, and replaced the realauth.jsonwith a test token (#831).🛠️ How it works
tests/helpers/throwaway-profile.tsis a global setup. It pointsHOME,USERPROFILEandAPPDATAat a temp home, and unsetsAIDD_USER_CONFIG_DIR,AIDD_TELEMETRY_DIRandXDG_CONFIG_HOME. Every route to a profile then ends in that temp home, which is removed on teardown.unitandintegrationprojects of bothvitest.workspace.tsandvitest.mutation.config.ts.process.envnever reachesos.homedir(). A first version withsetupFilespassed in forks and still leftos.homedir()on the real home under threads. The guard test caught it with--pool threads.🧪 How to verify
tests/helpers/throwaway-profile.unit.test.ts: every resolver (os.homedir(),resolveHomeDir(),resolveAiddConfigDir(),userConfigDir()) lands under the temp directory, and no override is set./Users/<me>: expected false to be true.--pool threads.tests/architecture/throwaway-profile-wiring.arch.test.ts: all four projects declare the setup. It was red before the wiring.if (process.env.AIDD_USER_CONFIG_DIR) returntoif (false) returninsrc/runtime/user-config-dir.ts, then runmarketplace-register-framework-use-case.integration.test.tswithHOMEset to a stand-in developer home..config/aidd/marketplaces.json.node scripts/run-mutation.mjs tools-copilot --forcepasses its initial run. The real~/.config/aiddis unchanged before and after it.Local results on this branch:
tools-copilot~/.config/aiddunchangedtests/. With test(cli): kill the surviving mutants of the telemetry context #815 and test(cli): kill the surviving mutants of the kernel and the runtime #819 the count reaches 2987, exactly the baseline.🔗 Linked issue
Fixes #831
✅ I certify
🤖 Generated with Claude Code
https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb