test: update glob tool test to cover case-insensitive path comparison on macOS

This commit is contained in:
xuewenjie
2025-12-08 18:15:40 +08:00
parent 5fa87e6fbb
commit dd7f9ed489

View File

@@ -198,12 +198,15 @@ describe('GlobTool', () => {
); );
}); });
it('should find files even if workspace path casing differs from glob results (Windows)', async () => { it('should find files even if workspace path casing differs from glob results (Windows/macOS)', async () => {
// Only relevant for Windows // Only relevant for Windows and macOS
if (process.platform !== 'win32') { if (process.platform !== 'win32' && process.platform !== 'darwin') {
return; return;
} }
let mismatchedRootDir = tempRootDir;
if (process.platform === 'win32') {
// 1. Create a path with mismatched casing for the workspace root // 1. Create a path with mismatched casing for the workspace root
// e.g., if tempRootDir is "C:\Users\...", make it "c:\Users\..." // e.g., if tempRootDir is "C:\Users\...", make it "c:\Users\..."
const drive = path.parse(tempRootDir).root; const drive = path.parse(tempRootDir).root;
@@ -213,8 +216,15 @@ describe('GlobTool', () => {
} }
const lowerDrive = drive.toLowerCase(); const lowerDrive = drive.toLowerCase();
const mismatchedRootDir = mismatchedRootDir = lowerDrive + tempRootDir.substring(drive.length);
lowerDrive + tempRootDir.substring(drive.length); } else {
// macOS: change the casing of the path
if (tempRootDir === tempRootDir.toLowerCase()) {
mismatchedRootDir = tempRootDir.toUpperCase();
} else {
mismatchedRootDir = tempRootDir.toLowerCase();
}
}
// 2. Create a new GlobTool instance with this mismatched root // 2. Create a new GlobTool instance with this mismatched root
const mismatchedConfig = { const mismatchedConfig = {