Skip to content

Commit fa6470e

Browse files
OmotolaCopilot
andcommitted
Fix: filter out \ args when no test name is available
When getCTestArgs is called without a specific test name (e.g., during test discovery, batch runs, or initial configuration), args containing \ are now filtered out instead of being passed to ctest with the literal unexpanded placeholder. This prevents creating files with literal \ in their name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c19f34c commit fa6470e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/ctest.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,15 @@ export class CTestDriver implements vscode.Disposable {
459459
const opts: ExpansionOptions = testName !== undefined
460460
? { ...driver.expansionOptions, vars: { ...driver.expansionOptions.vars, testName } }
461461
: driver.expansionOptions;
462-
const initialArgs = await Promise.all(this.ws.config.ctestDefaultArgs.map(async (value) => expandString(value, opts)));
463-
const additionalArgs = await Promise.all(this.ws.config.ctestArgs.map(async (value) => expandString(value, opts)));
462+
463+
// When testName is not provided, filter out args containing ${testName} to avoid
464+
// passing literal "${testName}" to ctest (e.g., during test discovery or batch runs).
465+
const testNamePlaceholder = '${testName}';
466+
const filterTestNameArgs = (args: string[]): string[] =>
467+
testName !== undefined ? args : args.filter(arg => !arg.includes(testNamePlaceholder));
468+
469+
const initialArgs = await Promise.all(filterTestNameArgs(this.ws.config.ctestDefaultArgs).map(async (value) => expandString(value, opts)));
470+
const additionalArgs = await Promise.all(filterTestNameArgs(this.ws.config.ctestArgs).map(async (value) => expandString(value, opts)));
464471

465472
ctestArgs = initialArgs.slice(0);
466473

0 commit comments

Comments
 (0)