From 4569910c79f5b31b332f88698dfc11fd9fe8b6fb Mon Sep 17 00:00:00 2001 From: azizur100389 Date: Mon, 28 Sep 2026 19:29:26 +0100 Subject: [PATCH] fix(process): exclude Dart test entry points (#3407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gergő Magyar --- .../core/ingestion/utils/test-file-path.ts | 1 + gitnexus/test/unit/process-processor.test.ts | 37 +++++++++++++++++++ gitnexus/test/unit/test-file-path.test.ts | 6 +++ 3 files changed, 44 insertions(+) diff --git a/gitnexus/src/core/ingestion/utils/test-file-path.ts b/gitnexus/src/core/ingestion/utils/test-file-path.ts index ceee59c56..deafb8114 100644 --- a/gitnexus/src/core/ingestion/utils/test-file-path.ts +++ b/gitnexus/src/core/ingestion/utils/test-file-path.ts @@ -54,6 +54,7 @@ const TEST_PATH_SUBSTRINGS: readonly string[] = [ const TEST_PATH_DELIMITED_SUFFIXES: readonly string[] = [ '_test.py', '_test.go', + '_test.dart', '_spec.rb', '_test.rb', ]; diff --git a/gitnexus/test/unit/process-processor.test.ts b/gitnexus/test/unit/process-processor.test.ts index 2891704fc..4e8c56dad 100644 --- a/gitnexus/test/unit/process-processor.test.ts +++ b/gitnexus/test/unit/process-processor.test.ts @@ -304,6 +304,43 @@ describe('processProcesses', () => { expect(testProcess).toBeUndefined(); }); + it('excludes Dart *_test.dart entry points outside the test directory', async () => { + const graph = createKnowledgeGraph(); + graph.addNode({ + id: 'func:dartTestMain', + label: 'Function', + properties: { + name: 'main', + filePath: 'lib/pages/dashboard_test.dart', + startLine: 1, + endLine: 10, + isExported: true, + }, + }); + graph.addNode({ + id: 'func:dartHelper', + label: 'Function', + properties: { + name: 'loadDashboard', + filePath: 'lib/pages/dashboard.dart', + startLine: 1, + endLine: 5, + isExported: true, + }, + }); + graph.addRelationship({ + id: 'call:dartTest', + sourceId: 'func:dartTestMain', + targetId: 'func:dartHelper', + type: 'CALLS', + confidence: 0.9, + reason: '', + }); + + const result = await processProcesses(graph, []); + expect(result.processes.some((p) => p.entryPointId === 'func:dartTestMain')).toBe(false); + }); + it('filters out low-confidence calls (below 0.5)', async () => { const graph = createKnowledgeGraph(); diff --git a/gitnexus/test/unit/test-file-path.test.ts b/gitnexus/test/unit/test-file-path.test.ts index a4ffc71bd..191ea71b4 100644 --- a/gitnexus/test/unit/test-file-path.test.ts +++ b/gitnexus/test/unit/test-file-path.test.ts @@ -14,6 +14,7 @@ describe('isTestFilePath — shared predicate', () => { it('normalizes Windows separators and casing', () => { expect(isTestFilePath('SRC\\Test\\FooTests.cs')).toBe(true); expect(isTestFilePath('pkg\\thing_test.go')).toBe(true); + expect(isTestFilePath('PKG\\thing_test.dart')).toBe(true); expect(isTestFilePath('src\\Widgets.Tests\\WidgetTests.cs')).toBe(true); }); @@ -31,6 +32,8 @@ describe('isTestFilePath — shared predicate', () => { 'tests/Feature/LoginTest.php', 'tests/Unit/ThingSpec.php', 'tests/Feature/Support/FakeGateway.php', + 'test/pages/dashboard_page_test.dart', + 'lib/widgets/dashboard_test.dart', ]) { it(`detects a test path the MCP copy used to miss: ${p}`, () => { expect(isTestFilePath(p)).toBe(true); @@ -56,6 +59,8 @@ describe('isTestFilePath — shared predicate', () => { 'Latest.php', 'src/fixtures/schema.ts', 'src/fruitests/helpers.swift', + 'lib/widgets/dashboard.dart', + 'lib/widgets/dashboard_test.dart.backup', ]) { it(`does not classify production code as test: ${p}`, () => { expect(isTestFilePath(p)).toBe(false); @@ -77,6 +82,7 @@ describe('test-file classification has exactly one implementation', () => { 'Contest.swift', 'spec/models/user_spec.rb', 'pkg/thing_test.go', + 'lib/widgets/dashboard_test.dart', 'tests/Feature/LoginTest.php', ];