File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1923,15 +1923,17 @@ export class CTestDriver implements vscode.Disposable {
19231923 let overallSuccess = true ;
19241924 for ( const [ project , targets ] of foundTarget ) {
19251925 const execTargets = await project . executableTargets ;
1926+ // Precompute a lookup map from normalized executable path to target name
1927+ const execPathToName = new Map < string , string > ( ) ;
1928+ for ( const t of execTargets ) {
1929+ execPathToName . set ( util . platformNormalizePath ( t . path ) , t . name ) ;
1930+ }
19261931 const accumulatedTestList : vscode . TestItem [ ] = [ ] ;
19271932 const accumulatedTargets : string [ ] = [ ] ;
19281933 let success : boolean = true ;
1929- for ( const [ targetPath , testList ] of targets ) {
1930- // Look up the CMake target name from executable targets by matching
1931- // the executable path. Using path.relative() uses the executable instead of the target name
1934+ for ( const [ targetPath , testList ] of targets ) {
19321935 const normalizedTargetPath = util . platformNormalizePath ( targetPath ) ;
1933- const execTarget = execTargets . find ( t => util . platformNormalizePath ( t . path ) === normalizedTargetPath ) ;
1934- accumulatedTargets . push ( execTarget ? execTarget . name : path . parse ( targetPath ) . name ) ;
1936+ accumulatedTargets . push ( execPathToName . get ( normalizedTargetPath ) ?? path . parse ( targetPath ) . name ) ;
19351937 accumulatedTestList . push ( ...testList ) ;
19361938 }
19371939 try {
You can’t perform that action at this time.
0 commit comments