From 73e9a44c0b78e4918eae95ebfad4461108afac34 Mon Sep 17 00:00:00 2001 From: haelyra <49814733+haelyra@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:20:01 -0400 Subject: [PATCH] test(install): compare canonical PowerShell install roots --- tests/scripts/install-ps1.test.js | 39 +++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/scripts/install-ps1.test.js b/tests/scripts/install-ps1.test.js index 66c6d423d..81fbdd102 100644 --- a/tests/scripts/install-ps1.test.js +++ b/tests/scripts/install-ps1.test.js @@ -24,6 +24,18 @@ function normalizePathForOutput(value) { return process.platform === 'win32' ? normalized.toLowerCase() : normalized; } +function canonicalizePlannedPath(value) { + const resolved = path.resolve(String(value).trim()); + const canonicalParent = fs.realpathSync.native(path.dirname(resolved)); + return normalizePathForOutput(path.join(canonicalParent, path.basename(resolved))); +} + +function extractInstallRoot(stdout) { + const match = String(stdout).match(/^Install root:\s*(.+?)\r?$/m); + assert.ok(match, `dry-run output should include an Install root field:\n${stdout}`); + return match[1]; +} + function resolvePowerShellCommand() { const candidates = process.platform === 'win32' ? ['powershell.exe', 'pwsh.exe', 'pwsh'] @@ -94,6 +106,23 @@ function runTests() { assert.strictEqual(packageJson.bin['ecc-install'], 'scripts/install-apply.js'); })) passed++; else failed++; + if (test('compares planned install roots by canonical path instead of leaf name', () => { + const fixtureRoot = createTempDir('install-ps1-paths-'); + const expectedProject = path.join(fixtureRoot, 'expected', 'same-project'); + const unrelatedProject = path.join(fixtureRoot, 'unrelated', 'same-project'); + + try { + fs.mkdirSync(expectedProject, { recursive: true }); + fs.mkdirSync(unrelatedProject, { recursive: true }); + assert.notStrictEqual( + canonicalizePlannedPath(path.join(expectedProject, '.agents')), + canonicalizePlannedPath(path.join(unrelatedProject, '.agents')) + ); + } finally { + cleanup(fixtureRoot); + } + })) passed++; else failed++; + if (!powerShellCommand) { console.log(' - skipped delegation test; PowerShell is not available in PATH'); } else if (test('delegates to the Antigravity installer while preserving the project cwd', () => { @@ -108,13 +137,9 @@ function runTests() { assert.strictEqual(result.code, 0, result.stderr); assert.ok(result.stdout.includes('Dry-run install plan')); - // PowerShell can expand a Windows temp root from its 8.3 form, while - // preserving the unique project directory leaf created by mkdtempSync. - const expectedProjectRoot = `/${path.basename(projectDir)}/.agents`; - assert.ok( - normalizePathForOutput(result.stdout).includes( - normalizePathForOutput(expectedProjectRoot) - ), + assert.strictEqual( + canonicalizePlannedPath(extractInstallRoot(result.stdout)), + canonicalizePlannedPath(path.join(projectDir, '.agents')), `dry-run output should target the project .agents directory:\n${result.stdout}` ); assert.ok(!fs.existsSync(path.join(projectDir, '.agents')));