From 3ebc9bd3d2de3e2754452055dc45b24301459e09 Mon Sep 17 00:00:00 2001 From: Karim Farahat <47497813+karimfarahat@users.noreply.github.com> Date: Fri, 2 Oct 2026 15:05:45 +0400 Subject: [PATCH] test: isolate HOME in state-store CLI tests The status CLI reconciles install-state discovered under $HOME. The state-store tests spawned it with the developer's real environment, so on any machine with ECC installed the real ~/.claude install was counted as an extra warning and four status/work-items assertions failed (3 attention items instead of 2). CI stays green only because runners have no install. Point HOME and USERPROFILE at an empty temp dir for spawned CLIs, cleaned up on exit. Callers can still override via options.env. Co-Authored-By: Claude Opus 5.5 --- tests/lib/state-store.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/lib/state-store.test.js b/tests/lib/state-store.test.js index 80ac95ec9..bf0a26c09 100644 --- a/tests/lib/state-store.test.js +++ b/tests/lib/state-store.test.js @@ -38,12 +38,19 @@ function cleanupTempDir(dirPath) { fs.rmSync(dirPath, { recursive: true, force: true }); } +// The status CLI reconciles install-state found under $HOME, so CLI runs get an +// empty home instead of the developer's real ~/.claude. +const ISOLATED_HOME = createTempDir('ecc-state-home-'); +process.on('exit', () => cleanupTempDir(ISOLATED_HOME)); + function runNode(scriptPath, args = [], options = {}) { return spawnSync('node', [scriptPath, ...args], { encoding: 'utf8', cwd: options.cwd || process.cwd(), env: { ...process.env, + HOME: ISOLATED_HOME, + USERPROFILE: ISOLATED_HOME, ...(options.env || {}), }, });