fix(tests): sandbox HOME in runGsdTools to prevent flaky assertions
buildNewProjectConfig() merges ~/.gsd/defaults.json when present, so tests asserting concrete config values (model_profile, commit_docs, brave_search) would fail on machines with a personal defaults file. - Pass HOME=cwd as env override in runGsdTools — child process resolves os.homedir() to the temp directory, which has no .gsd/ subtree - Update three tests that previously wrote to the real ~/.gsd/ using fragile save/restore logic; they now write to tmpDir/.gsd/ instead, which is cleaned up automatically by afterEach - Remove now-unused `os` import from config.test.cjs
This commit is contained in:
@@ -18,17 +18,22 @@ const TOOLS_PATH = path.join(__dirname, '..', 'get-shit-done', 'bin', 'gsd-tools
|
||||
function runGsdTools(args, cwd = process.cwd()) {
|
||||
try {
|
||||
let result;
|
||||
// Override HOME so buildNewProjectConfig() doesn't pick up ~/.gsd/defaults.json
|
||||
// from the developer's machine, which would cause flaky value assertions.
|
||||
const env = { ...process.env, HOME: cwd };
|
||||
if (Array.isArray(args)) {
|
||||
result = execFileSync(process.execPath, [TOOLS_PATH, ...args], {
|
||||
cwd,
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
env,
|
||||
});
|
||||
} else {
|
||||
result = execSync(`node "${TOOLS_PATH}" ${args}`, {
|
||||
cwd,
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
env,
|
||||
});
|
||||
}
|
||||
return { success: true, output: result.trim() };
|
||||
|
||||
Reference in New Issue
Block a user