From c3b26fad309076bca8059a6b6be667e48aadbf55 Mon Sep 17 00:00:00 2001 From: olaservo Date: Tue, 28 Oct 2025 21:23:32 -0700 Subject: [PATCH] Fix platform-dependent relative path test in filesystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was expecting forward slashes to always be converted to backslashes, but normalizePath() only does this on Windows (process.platform === 'win32'). On Linux/Unix, forward slashes are preserved. Improved the fix by: 1. Removing relative path assertion from the "as is" test since it doesn't match intent 2. Adding a dedicated test that validates platform-specific behavior naturally without mocking 3. Using the actual platform instead of unreliable Object.defineProperty mocking This approach is more reliable and clearly documents expected behavior per platform. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/filesystem/__tests__/path-utils.test.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/filesystem/__tests__/path-utils.test.ts b/src/filesystem/__tests__/path-utils.test.ts index 495d128d..868d8f08 100644 --- a/src/filesystem/__tests__/path-utils.test.ts +++ b/src/filesystem/__tests__/path-utils.test.ts @@ -196,11 +196,8 @@ describe('Path Utilities', () => { }); it('returns normalized non-Windows/WSL/Unix-style Windows paths as is after basic normalization', () => { - // Relative path - const relativePath = 'some/relative/path'; - expect(normalizePath(relativePath)).toBe(relativePath.replace(/\//g, '\\')); - // A path that looks somewhat absolute but isn't a drive or recognized Unix root for Windows conversion + // These paths should be preserved as-is (not converted to Windows C:\ format or WSL format) const otherAbsolutePath = '\\someserver\\share\\file'; expect(normalizePath(otherAbsolutePath)).toBe(otherAbsolutePath); }); @@ -350,5 +347,19 @@ describe('Path Utilities', () => { expect(result).not.toContain('C:'); expect(result).not.toContain('\\'); }); + + it('should handle relative path slash conversion based on platform', () => { + // This test verifies platform-specific behavior naturally without mocking + // On Windows: forward slashes converted to backslashes + // On Linux/Unix: forward slashes preserved + const relativePath = 'some/relative/path'; + const result = normalizePath(relativePath); + + if (originalPlatform === 'win32') { + expect(result).toBe('some\\relative\\path'); + } else { + expect(result).toBe('some/relative/path'); + } + }); }); });