Fix grep.test to work on windows. (#4889)

This commit is contained in:
Tommaso Sciortino 2025-07-25 14:32:28 -07:00 committed by GitHub
parent 23e0dc6960
commit aa71438684
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -125,7 +125,9 @@ describe('GrepTool', () => {
expect(result.llmContent).toContain('File: fileA.txt'); expect(result.llmContent).toContain('File: fileA.txt');
expect(result.llmContent).toContain('L1: hello world'); expect(result.llmContent).toContain('L1: hello world');
expect(result.llmContent).toContain('L2: second line with world'); expect(result.llmContent).toContain('L2: second line with world');
expect(result.llmContent).toContain('File: sub/fileC.txt'); expect(result.llmContent).toContain(
`File: ${path.join('sub', 'fileC.txt')}`,
);
expect(result.llmContent).toContain('L1: another world in sub dir'); expect(result.llmContent).toContain('L1: another world in sub dir');
expect(result.returnDisplay).toBe('Found 3 matches'); expect(result.returnDisplay).toBe('Found 3 matches');
}); });
@ -235,7 +237,7 @@ describe('GrepTool', () => {
it('should generate correct description with pattern and path', () => { it('should generate correct description with pattern and path', () => {
const params: GrepToolParams = { const params: GrepToolParams = {
pattern: 'testPattern', pattern: 'testPattern',
path: 'src/app', path: path.join('src', 'app'),
}; };
// The path will be relative to the tempRootDir, so we check for containment. // The path will be relative to the tempRootDir, so we check for containment.
expect(grepTool.getDescription(params)).toContain("'testPattern' within"); expect(grepTool.getDescription(params)).toContain("'testPattern' within");
@ -248,12 +250,14 @@ describe('GrepTool', () => {
const params: GrepToolParams = { const params: GrepToolParams = {
pattern: 'testPattern', pattern: 'testPattern',
include: '*.ts', include: '*.ts',
path: 'src/app', path: path.join('src', 'app'),
}; };
expect(grepTool.getDescription(params)).toContain( expect(grepTool.getDescription(params)).toContain(
"'testPattern' in *.ts within", "'testPattern' in *.ts within",
); );
expect(grepTool.getDescription(params)).toContain('src/app'); expect(grepTool.getDescription(params)).toContain(
path.join('src', 'app'),
);
}); });
it('should use ./ for root path in description', () => { it('should use ./ for root path in description', () => {