Skip to content

Commit a485bfc

Browse files
committed
fix path calc for windows compatibility
1 parent 275fbb6 commit a485bfc

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/client/testing/testController/common/testProjectRegistry.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
import * as path from 'path';
55
import { TestController, Uri } from 'vscode';
6+
import { isParentPath } from '../../../common/platform/fs-paths';
67
import { IConfigurationService } from '../../../common/types';
78
import { IInterpreterService } from '../../../interpreter/contracts';
8-
import { traceError, traceInfo, traceVerbose } from '../../../logging';
9+
import { traceError, traceInfo } from '../../../logging';
910
import { UNITTEST_PROVIDER } from '../../common/constants';
1011
import { TestProvider } from '../../types';
1112
import { IEnvironmentVariablesProvider } from '../../../common/variables/types';
1213
import { PythonProject, PythonEnvironment } from '../../../envExt/types';
1314
import { getEnvExtApi, useEnvExtension } from '../../../envExt/api.internal';
14-
import { isParentPath } from '../../../common/platform/fs-paths';
1515
import { ProjectAdapter } from './projectAdapter';
1616
import { getProjectId, createProjectDisplayName, createTestAdapters } from './projectUtils';
1717
import { 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

Comments
 (0)