You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add "${testName}" variable support for ctestArgs and ctestDefaultArgs
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>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Features:
7
7
- Add support for `${workspaceFolder}`, `${workspaceFolder:name}` variables and relative paths in `cmake.exclude` setting for multi-root workspaces. [#4689](https://github.com/microsoft/vscode-cmake-tools/pull/4689)
8
8
9
9
Improvements:
10
+
- Add `${testName}` variable support for `cmake.ctestArgs` and `cmake.ctestDefaultArgs`, enabling per-test argument expansion (e.g., unique log file paths per test). [#4416](https://github.com/microsoft/vscode-cmake-tools/issues/4416)
10
11
- Improve responsiveness to CMake path changes made by vendor extensions during configure-on-open retry. [#4908](https://github.com/microsoft/vscode-cmake-tools/pull/4908) Contributed by STMicroelectronics
11
12
- Improve ergonomics of the test explorer UI by removing the project source directory, improving horizontal scrolling experience. [#4562](https://github.com/microsoft/vscode-cmake-tools/issues/4562)[@miss-programgamer](https://github.com/miss-programgamer)
Copy file name to clipboardExpand all lines: docs/cmake-settings.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,8 +41,8 @@ Options that support substitution, in the table below, allow variable references
41
41
|`cmake.ctest.parallelJobs`| Specify the number of jobs to run in parallel for ctest. Using the value `0` will detect and use the number of CPUs. Using the value `1` will disable test parallelism. |`0`| no |
42
42
|`cmake.ctest.testExplorerIntegrationEnabled`| If `true`, configure CMake to generate information needed by the test explorer. |`true`| no |
43
43
|`cmake.ctest.testSuiteDelimiter`| Character(s) that separate test suite name components. |`null`| no |
44
-
|`cmake.ctestArgs`| An array of additional arguments to pass to CTest. |`[]`| yes |
45
-
|`cmake.ctestDefaultArgs`| Default arguments to pass to CTest. |`["-T", "test", "--output-on-failure"]`| no |
44
+
|`cmake.ctestArgs`| An array of additional arguments to pass to CTest. Supports `${testName}` for per-test expansion (see [Variable substitution](#variable-substitution)). |`[]`| yes |
45
+
|`cmake.ctestDefaultArgs`| Default arguments to pass to CTest. Supports `${testName}` for per-test expansion (see [Variable substitution](#variable-substitution)). |`["-T", "test", "--output-on-failure"]`| no |
46
46
|`cmake.ctestPath`| Path to CTest executable. |`null`| no |
47
47
|`cmake.debugConfig`| The debug configuration to use when debugging a target. When `type` is specified, automatic debugger detection is skipped and a custom debug adapter can be used. Additional properties required by the debug adapter can be added freely. See [Debug and launch](debug-launch.md#customize-the-debug-adapter) for examples, including Natvis via `visualizerFile` without a `launch.json`. |`null` (no values) | yes |
48
48
|`cmake.defaultActiveFolder`| The name of active folder, which be used as default (Only works when `cmake.autoSelectActiveFolder` is disabled). |`""`| no |
@@ -141,6 +141,7 @@ The following built-in variables are expanded in supported `cmake.*` settings on
141
141
|`${buildKitVersionMajor}`| The current CMake kit major version. For example: `7`|
142
142
|`${buildKitVersionMinor}`| The current CMake kit minor version. For example: `3`|
143
143
|`${generator}`| The name of the CMake generator. For example: `Ninja`|
144
+
|`${testName}`| The name of the current CTest test. Only expanded in `cmake.ctestArgs` and `cmake.ctestDefaultArgs` when running a single test (non-parallel mode or single-test selection). When multiple tests run in a batch, the variable is not expanded and a warning is logged.|
144
145
|`${projectName}`|**DEPRECATED**. Expands to the constant string `"ProjectName"` CMake does not consider there to be just one project name to use. The concept of a single project does not work in CMake. Use `${workspaceRootFolderName}`, instead.|
145
146
|`${userHome}`| The full path to the current user's home directory. |
Copy file name to clipboardExpand all lines: package.nls.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -257,8 +257,8 @@
257
257
"cmake-tools.configuration.cmake.defaultVariants.buildType.release.long": "Optimize for speed - exclude debug information.",
258
258
"cmake-tools.configuration.cmake.defaultVariants.buildType.minsize.long": "Optimize for smallest binary size - exclude debug information.",
259
259
"cmake-tools.configuration.cmake.defaultVariants.buildType.reldeb.long": "Optimize for speed - include debug information.",
260
-
"cmake-tools.configuration.cmake.ctestArgs.description": "Additional arguments to pass to CTest. When using CMake Presets, these arguments are temporarily added to the arguments provided by the active test preset.",
261
-
"cmake-tools.configuration.cmake.ctestDefaultArgs.description": "Arguments passed by default to CTest.",
260
+
"cmake-tools.configuration.cmake.ctestArgs.description": "Additional arguments to pass to CTest. When using CMake Presets, these arguments are temporarily added to the arguments provided by the active test preset. Use ${testName} to reference the current test name (only expanded when running a single test).",
261
+
"cmake-tools.configuration.cmake.ctestDefaultArgs.description": "Arguments passed by default to CTest. Use ${testName} to reference the current test name (only expanded when running a single test).",
262
262
"cmake-tools.configuration.cmake.environment.description": "Environment variables to set when running CMake commands. When using CMake Presets, these are temporarily added to the environment used for CMake commands.",
263
263
"cmake-tools.configuration.cmake.environment.additionalProperties.description": "Value for the environment variable.",
264
264
"cmake-tools.configuration.cmake.configureEnvironment.description": "Environment variables to pass to CMake during configure. When using CMake Presets, these are temporarily added to the environment provided by the active configure preset.",
log.warning(localize('testName.not.supported.multiple','${testName} variable in ctest args is not supported when running multiple tests. The variable will not be expanded.'));
log.warning(localize('testName.not.supported.parallel','${testName} variable in ctest args is not supported when running multiple tests in parallel. The variable will not be expanded.'));
802
+
uniqueCtestArgs=driver.ctestArgs.slice();
803
+
}else{
804
+
uniqueCtestArgs=driver.ctestArgs.slice();
805
+
}
806
+
807
+
// Check if the user (or us programmatically) have already added a -j flag. If not, add it by default for parallel jobs.
0 commit comments