From acda87a2470dfc84fb600c3a2c114c4c170ceb08 Mon Sep 17 00:00:00 2001 From: jiangnan <1394485448@qq.com> Date: Fri, 6 Mar 2026 05:19:14 +0800 Subject: [PATCH] test(csharp): remove try/catch that masked query compilation failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C# integration test wrapped parseAndQuery in a try/catch that accepted TSQueryError as a passing condition. This meant the broken simple_base_type query compiled, failed silently, and the test still passed — hiding the fact that zero C# symbols were being extracted. Removed the try/catch so query compilation errors are caught by CI. Also added specific assertions for class, method, and namespace extraction from the C# fixture. --- .../integration/tree-sitter-languages.test.ts | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gitnexus/test/integration/tree-sitter-languages.test.ts b/gitnexus/test/integration/tree-sitter-languages.test.ts index 4f2e59d10..d6c7c85e5 100644 --- a/gitnexus/test/integration/tree-sitter-languages.test.ts +++ b/gitnexus/test/integration/tree-sitter-languages.test.ts @@ -149,17 +149,20 @@ describe('Tree-sitter multi-language parsing', () => { }); describe('C#', () => { - it('parses class, method, and property declarations', async () => { + it('parses class, method, and namespace declarations', async () => { await loadLanguage(SupportedLanguages.CSharp); const content = readFixture('simple.cs'); - try { - const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[SupportedLanguages.CSharp]); - const defs = extractDefinitions(matches); - expect(defs.length).toBeGreaterThan(0); - } catch (e: any) { - // Some tree-sitter-c-sharp versions don't support all query node types - expect(e.message).toContain('TSQueryError'); - } + const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[SupportedLanguages.CSharp]); + const defs = extractDefinitions(matches); + + expect(defs.length).toBeGreaterThan(0); + const defTypes = defs.map(d => d.type); + expect(defTypes).toContain('definition.class'); + expect(defTypes).toContain('definition.method'); + expect(defTypes).toContain('definition.namespace'); + const names = defs.map(d => d.name); + expect(names).toContain('Calculator'); + expect(names).toContain('Add'); }); }); @@ -234,14 +237,9 @@ describe('Tree-sitter multi-language parsing', () => { for (const [lang, fixture, filePath] of langFixtures) { await loadLanguage(lang, filePath || fixture); const content = readFixture(fixture); - try { - const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[lang]); - const defs = extractDefinitions(matches); - expect(defs.length, `${lang} (${fixture}) should have definitions`).toBeGreaterThan(0); - } catch (e: any) { - // Some grammars may have query compatibility issues - if (!e.message?.includes('TSQueryError')) throw e; - } + const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[lang]); + const defs = extractDefinitions(matches); + expect(defs.length, `${lang} (${fixture}) should have definitions`).toBeGreaterThan(0); } }); });