fix(tests): add USERPROFILE override for Windows HOME sandboxing

On Windows, os.homedir() reads USERPROFILE instead of HOME. The 6
tests using { HOME: tmpDir } to sandbox ~/.gsd/ lookups failed on
windows-latest because the child process still resolved homedir to
the real user profile.

Pass USERPROFILE alongside HOME in all sandboxed test calls.
This commit is contained in:
Diego Mariño
2026-03-20 14:56:28 +01:00
parent 2d8e3b4791
commit a1852fef33

View File

@@ -83,7 +83,7 @@ describe('config-ensure-section command', () => {
fs.mkdirSync(gsdDir, { recursive: true });
fs.writeFileSync(path.join(gsdDir, 'brave_api_key'), 'test-key', 'utf-8');
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir });
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);
@@ -100,7 +100,7 @@ describe('config-ensure-section command', () => {
commit_docs: false,
}), 'utf-8');
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir });
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);
@@ -119,7 +119,7 @@ describe('config-ensure-section command', () => {
workflow: { research: false },
}), 'utf-8');
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir });
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);
@@ -340,7 +340,7 @@ describe('config-new-project command', () => {
model_profile: 'balanced',
workflow: { research: true, plan_check: true, verifier: true, nyquist_validation: true },
});
const result = runGsdTools(['config-new-project', choices], tmpDir, { HOME: tmpDir });
const result = runGsdTools(['config-new-project', choices], tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);
@@ -388,7 +388,7 @@ describe('config-new-project command', () => {
model_profile: 'quality',
workflow: { research: false, plan_check: false, verifier: true, nyquist_validation: false },
});
const result = runGsdTools(['config-new-project', choices], tmpDir, { HOME: tmpDir });
const result = runGsdTools(['config-new-project', choices], tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);
@@ -407,7 +407,7 @@ describe('config-new-project command', () => {
});
test('works with empty choices — all defaults materialized', () => {
const result = runGsdTools(['config-new-project', '{}'], tmpDir, { HOME: tmpDir });
const result = runGsdTools(['config-new-project', '{}'], tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const config = readConfig(tmpDir);