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 <noreply@anthropic.com>
This commit is contained in:
Karim Farahat
2026-10-02 15:05:45 +04:00
co-authored by Claude Opus 5.5
parent ef648e0189
commit 3ebc9bd3d2
+7
View File
@@ -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 || {}),
},
});