From dae8e70a5a53d295cafc719037f4038d3899a937 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sun, 12 Jul 2026 16:23:54 -0400 Subject: [PATCH] test(#2185): cover Linuxbrew + custom-prefix Cellar paths in normalizeNodePath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the Linuxbrew Cellar layout (/home/linuxbrew/.linuxbrew/Cellar/...), a post-version-bump path, a node@version formula, and a custom HOMEBREW_PREFIX — all mapping to the stable /bin/node symlink. Mirrored in both consolidated describe blocks. --- tests/install.test.cjs | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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';