Skip to content

Commit c5c3485

Browse files
committed
Compute the target name instead of the executable
1 parent 8195cc6 commit c5c3485

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/ctest.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,13 +1920,17 @@ export class CTestDriver implements vscode.Disposable {
19201920
private async buildTestTargets(foundTarget: Map<CMakeProject, Map<string, vscode.TestItem[]>>, run: vscode.TestRun): Promise<boolean> {
19211921
let overallSuccess = true;
19221922
for (const [project, targets] of foundTarget) {
1923-
const binaryDir = (await project.binaryDir).toString();
1923+
const execTargets = await project.executableTargets;
19241924
const accmulatedTestList: vscode.TestItem[] = [];
19251925
const accumulatedTargets: string[] = [];
19261926
let success: boolean = true;
1927-
for (const [targetName, testList] of targets) {
1928-
accumulatedTargets.push(path.relative(binaryDir, targetName));
1929-
accmulatedTestList.concat(testList);
1927+
for (const [targetPath, testList] of targets) {
1928+
// Look up the CMake target name from executable targets by matching
1929+
// the executable path. Using path.relative() uses the executable instead of the target name
1930+
const normalizedTargetPath = util.platformNormalizePath(targetPath);
1931+
const execTarget = execTargets.find(t => util.platformNormalizePath(t.path) === normalizedTargetPath);
1932+
accumulatedTargets.push(execTarget ? execTarget.name : path.parse(targetPath).name);
1933+
accmulatedTestList.push(...testList);
19301934
}
19311935
try {
19321936
if (extensionManager !== undefined && extensionManager !== null) {

0 commit comments

Comments
 (0)