Skip to content

Commit c1f7fb1

Browse files
committed
based on copilot comments
1 parent 0cfd96d commit c1f7fb1

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

src/client/testing/common/debugLauncher.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,27 @@ export class DebugLauncher implements ITestDebugLauncher {
118118
}),
119119
);
120120

121+
// Clean up event subscriptions when debugging completes (success, failure, or cancellation)
122+
deferred.promise.finally(() => {
123+
disposables.forEach((d) => d.dispose());
124+
});
125+
121126
// Start the debug session
122-
const started = await debugManager.startDebugging(workspaceFolder, launchArgs, sessionOptions);
127+
let started = false;
128+
try {
129+
started = await debugManager.startDebugging(workspaceFolder, launchArgs, sessionOptions);
130+
} catch (error) {
131+
traceError('Error starting debug session', error);
132+
deferred.reject(error);
133+
callCallbackOnce();
134+
return deferred.promise;
135+
}
123136
if (!started) {
124137
traceError('Failed to start debug session');
125138
deferred.resolve();
126139
callCallbackOnce();
127140
}
128141

129-
// Clean up event subscriptions when debugging completes (success, failure, or cancellation)
130-
deferred.promise.finally(() => {
131-
disposables.forEach((d) => d.dispose());
132-
});
133-
134142
return deferred.promise;
135143
}
136144

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class TestProjectRegistry {
293293
const parentPath = parent.projectUri.fsPath;
294294
const childPath = child.projectUri.fsPath;
295295

296-
if (childPath.startsWith(parentPath + path.sep)) {
296+
if (isParentPath(parentPath, childPath)) {
297297
nestedPaths.push(childPath);
298298
traceVerbose(`[test-by-project] Nested: ${child.projectName} under ${parent.projectName}`);
299299
}

src/client/testing/testController/controller.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,10 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
306306
}
307307
}
308308

309-
// Clear registry and re-discover all projects for the workspace
310-
this.projectRegistry.clearWorkspace(workspace.uri);
311-
await this.projectRegistry.discoverAndRegisterProjects(workspace.uri);
312-
313-
// Re-run test discovery for the workspace to populate fresh test items
314-
await this.discoverTestsInWorkspace(workspace.uri);
309+
// Re-discover all projects and tests for the workspace in a single pass.
310+
// discoverAllProjectsInWorkspace is responsible for clearing/re-registering
311+
// projects and performing test discovery for the workspace.
312+
await this.discoverAllProjectsInWorkspace(workspace.uri);
315313
}
316314
}
317315

0 commit comments

Comments
 (0)