Skip to content

Add variable support for ctestArgs and ctestDefaultArgs#4925

Open
Omotola wants to merge 1 commit into
mainfrom
dev/oakeredolu/ctest-testname-variable
Open

Add variable support for ctestArgs and ctestDefaultArgs#4925
Omotola wants to merge 1 commit into
mainfrom
dev/oakeredolu/ctest-testname-variable

Conversation

@Omotola
Copy link
Copy Markdown
Contributor

@Omotola Omotola commented May 4, 2026

Overview

Enables test-specific argument expansion in cmake.ctestArgs and cmake.ctestDefaultArgs using the ${testName}
placeholder. This allows users to generate per-test log files (e.g., --output-log /logs/${testName}.log) instead
of having all tests overwrite the same file.

Resolves #4416

Changes

  • src/ctest.ts: Added ${testName} variable to the expansion options in getCTestArgs(). Added
    hasTestNameVariable() helper to detect usage.
  • package.nls.json: Updated setting descriptions for ctestArgs and ctestDefaultArgs to document the new
    variable.

How it works

The ${testName} variable is expanded to the CTest test name when a single test is being executed:

Execution path Behavior
Non-parallel mode Expanded per-test in the sequential loop (each test gets its own ctest invocation)
Parallel mode, single test Expanded when exactly one test is targeted
Parallel mode, multiple tests Warning logged; variable left unexpanded (batch invocation has no single test
name)
Direct ctest path Expanded when testsToRun contains exactly one entry

Example usage

// settings.json
{
    "cmake.ctestArgs": ["--output-log", "/logs/${testName}.log"]
}

Validation
image

Enables test-specific argument expansion in cmake.ctestArgs and
cmake.ctestDefaultArgs using the ${testName} placeholder. This allows
users to generate per-test output (e.g., --output-log ${testName}.log)
instead of having all tests overwrite the same file.

The variable is expanded when a single test is being run:
- Non-parallel mode: expanded per-test in the sequential loop
- Parallel mode: expanded when exactly one test is targeted
- Direct ctest path: expanded when testsToRun has one entry

When multiple tests run in a batch, a warning is logged and the
variable is not expanded. Args containing ${testName} (and their
preceding flags) are filtered out when no test name is available,
preventing literal placeholders from being passed to ctest.

Resolves #4416

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Omotola Omotola force-pushed the dev/oakeredolu/ctest-testname-variable branch from cc5e5fe to c8bb730 Compare May 5, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support for test-specific arguments in cmake.ctestArgs and cmake.ctestDefaultArgs‌

1 participant