mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
test: fix Windows CI execution and resolve exposed platform failures (#24476)
This commit is contained in:
@@ -5,11 +5,13 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, afterEach, vi } from 'vitest';
|
||||
import path from 'node:path';
|
||||
import { FileSearchFactory, AbortError, filter } from './fileSearch.js';
|
||||
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils';
|
||||
import * as crawler from './crawler.js';
|
||||
import { GEMINI_IGNORE_FILE_NAME } from '../../config/constants.js';
|
||||
import { FileDiscoveryService } from '../../services/fileDiscoveryService.js';
|
||||
import { escapePath } from '../paths.js';
|
||||
|
||||
describe('FileSearch', () => {
|
||||
let tmpDir: string;
|
||||
@@ -789,11 +791,12 @@ describe('FileSearch', () => {
|
||||
|
||||
// Search for the file using a pattern that contains special characters.
|
||||
// The `unescapePath` function should handle the escaped path correctly.
|
||||
const results = await fileSearch.search(
|
||||
'src/file with \\(special\\) chars.txt',
|
||||
);
|
||||
const searchPattern = escapePath('src/file with (special) chars.txt');
|
||||
const results = await fileSearch.search(searchPattern);
|
||||
|
||||
expect(results).toEqual(['src/file with (special) chars.txt']);
|
||||
expect(results.map((r) => path.normalize(r))).toEqual([
|
||||
path.normalize('src/file with (special) chars.txt'),
|
||||
]);
|
||||
});
|
||||
|
||||
describe('DirectoryFileSearch', () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
|
||||
type FileFilteringOptions,
|
||||
} from '../config/constants.js';
|
||||
import { GEMINI_DIR, homedir, normalizePath } from './paths.js';
|
||||
import { GEMINI_DIR, homedir, normalizePath, isSubpath } from './paths.js';
|
||||
import type { ExtensionLoader } from './extensionLoader.js';
|
||||
import { debugLogger } from './debugLogger.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
@@ -791,15 +791,8 @@ export async function loadJitSubdirectoryMemory(
|
||||
|
||||
// Find the deepest trusted root that contains the target path
|
||||
for (const root of trustedRoots) {
|
||||
const resolvedRoot = normalizePath(root);
|
||||
const resolvedRootWithTrailing = resolvedRoot.endsWith(path.sep)
|
||||
? resolvedRoot
|
||||
: resolvedRoot + path.sep;
|
||||
|
||||
if (
|
||||
resolvedTarget === resolvedRoot ||
|
||||
resolvedTarget.startsWith(resolvedRootWithTrailing)
|
||||
) {
|
||||
if (isSubpath(root, targetPath)) {
|
||||
const resolvedRoot = normalizePath(root);
|
||||
if (!bestRoot || resolvedRoot.length > bestRoot.length) {
|
||||
bestRoot = resolvedRoot;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user