33
44import * as path from 'path' ;
55import { TestController , Uri } from 'vscode' ;
6+ import { isParentPath } from '../../../common/platform/fs-paths' ;
67import { IConfigurationService } from '../../../common/types' ;
78import { IInterpreterService } from '../../../interpreter/contracts' ;
8- import { traceError , traceInfo , traceVerbose } from '../../../logging' ;
9+ import { traceError , traceInfo } from '../../../logging' ;
910import { UNITTEST_PROVIDER } from '../../common/constants' ;
1011import { TestProvider } from '../../types' ;
1112import { IEnvironmentVariablesProvider } from '../../../common/variables/types' ;
1213import { PythonProject , PythonEnvironment } from '../../../envExt/types' ;
1314import { getEnvExtApi , useEnvExtension } from '../../../envExt/api.internal' ;
14- import { isParentPath } from '../../../common/platform/fs-paths' ;
1515import { ProjectAdapter } from './projectAdapter' ;
1616import { getProjectId , createProjectDisplayName , createTestAdapters } from './projectUtils' ;
1717import { PythonResultResolver } from './resultResolver' ;
@@ -276,6 +276,9 @@ export class TestProjectRegistry {
276276 *
277277 * **Time complexity:** O(n²) where n is the number of projects in the workspace.
278278 * For each project, checks all other projects to find nested relationships.
279+ *
280+ * Note: Uses path.normalize() to handle Windows path separator inconsistencies
281+ * (e.g., paths from URI.fsPath may have mixed separators).
279282 */
280283 private computeNestedProjectIgnores ( workspaceUri : Uri ) : Map < string , string [ ] > {
281284 const ignoreMap = new Map < string , string [ ] > ( ) ;
@@ -290,12 +293,22 @@ export class TestProjectRegistry {
290293 // Skip self-comparison using URI
291294 if ( parent . projectUri . toString ( ) === child . projectUri . toString ( ) ) continue ;
292295
293- const parentPath = parent . projectUri . fsPath ;
294- const childPath = child . projectUri . fsPath ;
296+ // Normalize paths to handle Windows path separator inconsistencies
297+ const parentNormalized = path . normalize ( parent . projectUri . fsPath ) ;
298+ const childNormalized = path . normalize ( child . projectUri . fsPath ) ;
299+
300+ // Add trailing separator to ensure we match directory boundaries
301+ const parentWithSep = parentNormalized . endsWith ( path . sep )
302+ ? parentNormalized
303+ : parentNormalized + path . sep ;
304+ const childWithSep = childNormalized . endsWith ( path . sep ) ? childNormalized : childNormalized + path . sep ;
305+
306+ // Check if child is inside parent (case-insensitive for Windows)
307+ const childIsInsideParent = childWithSep . toLowerCase ( ) . startsWith ( parentWithSep . toLowerCase ( ) ) ;
295308
296- if ( isParentPath ( childPath , parentPath ) ) {
297- nestedPaths . push ( childPath ) ;
298- traceVerbose ( `[test-by-project] Nested: ${ child . projectName } under ${ parent . projectName } ` ) ;
309+ if ( childIsInsideParent ) {
310+ nestedPaths . push ( child . projectUri . fsPath ) ;
311+ traceInfo ( `[test-by-project] Nested: ${ child . projectName } is inside ${ parent . projectName } ` ) ;
299312 }
300313 }
301314
0 commit comments