fix(process): exclude Dart test entry points (#3407)

Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
This commit is contained in:
azizur100389 2026-09-28 19:29:26 +01:00 • committed by GitHub
parent 0ef3f28d0e
commit 4569910c79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 0 deletions

View file

@ -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',
];

View file

@ -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();

View file

@ -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',
];