diff --git a/tests/install.test.cjs b/tests/install.test.cjs index acf762dc5..2e9af2860 100644 --- a/tests/install.test.cjs +++ b/tests/install.test.cjs @@ -2084,6 +2084,30 @@ describe('Bug #3181: normalizeNodePath — Apple Silicon Homebrew Cellar paths }); }); +// #2185: Linuxbrew + any custom HOMEBREW_PREFIX — the Cellar prefix is derived +// from the path itself, so one branch covers every Homebrew layout. +describe('Bug #2185: normalizeNodePath — Linuxbrew + custom-prefix Cellar paths → /bin/node', () => { + test('Linuxbrew Cellar path maps to the stable linuxbrew symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node/26.0.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('Linuxbrew Cellar path after a version bump (26.5.0) maps to stable symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node/26.5.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('Linuxbrew versioned formula Cellar path (node@22) maps to stable symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node@22/22.11.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('custom HOMEBREW_PREFIX Cellar path maps to its stable symlink', () => { + const result = normalizeNodePath('/custom/brew/Cellar/node/25.8.1/bin/node'); + assert.equal(result, '/custom/brew/bin/node'); + }); +}); + describe('Bug #3181: normalizeNodePath — non-Homebrew paths are returned unchanged', () => { test('NVM path is unchanged', () => { const nvm = '/Users/dev/.nvm/versions/node/v20.11.0/bin/node'; @@ -6075,6 +6099,30 @@ describe('Bug #3181: normalizeNodePath — Apple Silicon Homebrew Cellar paths }); }); +// #2185: Linuxbrew + any custom HOMEBREW_PREFIX — the Cellar prefix is derived +// from the path itself, so one branch covers every Homebrew layout. +describe('Bug #2185: normalizeNodePath — Linuxbrew + custom-prefix Cellar paths → /bin/node', () => { + test('Linuxbrew Cellar path maps to the stable linuxbrew symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node/26.0.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('Linuxbrew Cellar path after a version bump (26.5.0) maps to stable symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node/26.5.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('Linuxbrew versioned formula Cellar path (node@22) maps to stable symlink', () => { + const result = normalizeNodePath('/home/linuxbrew/.linuxbrew/Cellar/node@22/22.11.0/bin/node'); + assert.equal(result, '/home/linuxbrew/.linuxbrew/bin/node'); + }); + + test('custom HOMEBREW_PREFIX Cellar path maps to its stable symlink', () => { + const result = normalizeNodePath('/custom/brew/Cellar/node/25.8.1/bin/node'); + assert.equal(result, '/custom/brew/bin/node'); + }); +}); + describe('Bug #3181: normalizeNodePath — non-Homebrew paths are returned unchanged', () => { test('NVM path is unchanged', () => { const nvm = '/Users/dev/.nvm/versions/node/v20.11.0/bin/node';