Skip to content

feat: add cmake.ctest.debugLaunchTarget - #4273

Merged
Garrett Campbell (gcampbell-msft) merged 6 commits into
microsoft:mainfrom
Nerixyz:ctest/debugLaunchTarget
Mar 10, 2025
Merged

Garrett Campbell (gcampbell-msft) merged 6 commits into
microsoft:mainfrom
Nerixyz:ctest/debugLaunchTarget

Conversation

@Nerixyz

@Nerixyz Nerixyz (Nerixyz) commented Feb 7, 2025 •

Copy link
Copy Markdown
Contributor

This change addresses item #3940

This changes debugging of tests

The following changes are proposed:

  • The setting cmake.ctest.debugLaunchTarget is added, which specifies a launch configuration to be used when debugging tests.
Code_2025-03-07_22-37-48.mp4

The purpose of this change

When repeatedly debugging tests (something fails → fix → recompile → test → something else fails → ...), one usually uses the same launch configuration. Often, multiple launch configurations are present in a project (e.g. a specific one for tests that has "args": ["${cmake.testArgs}"]). The popup to select a test can get distracting.

Comment thread docs/debug-launch.md Resolved
Comment thread package.nls.json Resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're happy to take these changes, the modifications are simple enough and it would provide value.

However, a couple of comments for somethings need to be changed:

  1. See the other comments on this PR.
  2. Add a Changelog entry. You will need to add a section for 1.21
## 1.21

Features:

- <>
  1. Please add a screenshot and/or gif to the description of the PR so that it's more obvious what this will look like in the settings and in practice.
@Nerixyz Nerixyz (Nerixyz) changed the title feat: add cmake.ctest.testSuiteDelimiter.debugLaunchTarget Mar 7, 2025
@gcampbell-msft

Copy link
Copy Markdown
Collaborator

Just a changelog merge conflict. Merging.

@gcampbell-msft
Garrett Campbell (gcampbell-msft) merged commit 7b36420 into microsoft:main Mar 10, 2025
@Nerixyz
Nerixyz (Nerixyz) deleted the ctest/debugLaunchTarget branch March 10, 2025 17:17
@zwassall-gentuity

zwassall-gentuity commented Mar 13, 2025 •

Copy link
Copy Markdown

This seems to at least partially address #3153 and #3345?

@Amy-Li03

Copy link
Copy Markdown
Collaborator

Verified this on cmake tools v1.21.7(pre-release), we can see the cmake.ctest.debugLaunchTarget setting, and after use it, specifies a launch configuration to be used when debugging tests.
Fixed

hippo91 pushed a commit to hippo91/vscode-cmake-tools that referenced this pull request Mar 29, 2025
* feat: add `cmake.ctest.testSuiteDelimiter.debugLaunchTarget`

* fix: setting name

* fix: description name

* chore: add changelog entry

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>
Mateusz Pfeifer (fajkomix1990) pushed a commit to fajkomix1990/mati---glowny that referenced this pull request Jul 2, 2025
* feat: add `cmake.ctest.testSuiteDelimiter.debugLaunchTarget`

* fix: setting name

* fix: description name

* chore: add changelog entry

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>
Hannia Valera (hanniavalera) pushed a commit that referenced this pull request May 13, 2026
* Adds a new end to end test directory devoted to ctest tests

* Fix non stopping breakpoints

* Adds scripts entry for new end to end ctest

* Adds configurations for new end to end ctest test

* Do not forbid test refreshing even in test mode

* Fix end to end test devoted to ctest

* Test is functionnal when running through debug

* Add "allowParallelJobs" in the config

* Removes useless files

* Replaces TestCleanup target with simpler call in the teardown method

* Add cmake.ctest.allowParallelJobs setting

* Upgrade cmake minimum required version to avoid warnings

* Sets up two tests. One with parallel jobs enabled and the other without

* Remove useless file

* Adds two tests dealing with testSuiteDelimiter

* Remove generated test file between each test

* Do not delete file if it is not present

* Fix test suite delimiter

* Do not add a comma if no text is appended

* Delete test file results before the test

* Create cleanUpTestResultFiles to factorize code

* Adds explicit message to failing assertions

* Fix comment

* Generalize output writing

* Protect empy successor when dealing with last element of the container

* Adds doc and format

* Move suite initialization in the right method

* Await for settings change promise

* Set CMT_TESTING to one

* Restore previous state

* Renames files and targets

* Create a TestUtils lib to factorize code

* Start templating test file

* Move cmake stuff in its own module

* Adds doc

* Set tests definition in CMake presets

* Renames preset

* Remove generated test from git

* Fix generate_test_source_file function and return value

* Introduces use of common directory to store test result

* Defines common tests directory in cmake cache variables

* Add and fix doc. Renames variable.

* First ry to retrieve CMakePresets name in the test

* Remove tmp test dir, its location being read from CMakePresets.

* Reword test labels

* Format

* Turns method into free function to be reused in other test suites

* Removes unused import

* Adds another test suite to check test failure detection

* Typo

* Adds comments

* Factorize code

* Add newline at eof

* Typos

* Adds suite test to check when all tests fail

* Adds doc. Removes comment

* Moves test env initialization into commonSetup method to avoid code duplication

* Adds doc

* Remove dead code

* Adds endToEndTestsSingleRootCTest to the list of tests to run in the CI pipelines for windows, linux, and macos.

* Remove launch configuration modification that was not made on purpose

* Enable test explorer for those test suites

* Keeping integrity of the return code as suggested in the review comments

* Takes into account code review suggestions

* Specify compilers for linux and windows systems.

* Select the preset according to the OS type

* Updated Issue Template Selection (#4335)

* updated templates

* wording updates

* updated changelog

* template updates

* Fix 3232 (#4223)

* Adds the getAllCMakeProjects method

* Loop over all CMake projects of the workspace to provide tasks.

Also pass the workspaceFolder to the provideTask method

* Add workspacefolder property to the CustomBuildTaskTerminal class.

This is necessary to make each task run in the correct project

* Simplify getAllCMakeProjects method.

It is a simple delegation to the eponym method of projectController

* The scope is now always a workspaceFolder

* Adds the getDefaultPresetNameForProject function

* Renames getDefaultPresetName function into getDefaultPresetNameForActiveProject

* Renames getActiveProject method into getProject method

Using workspaceFolder scope allows to retrieve the project using this folder

* Adds doc

* Get the preset for the specified workspace using the new getDefaultPresetNameForProject function

* Fix trailing space

* Adds comment

* Adds the method getProjectForFolder in the extension.

It is mostly a delegation to the eponym method of the projectController

* Update CHANGELOG.md (#3232)

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* feat: add `cmake.ctest.debugLaunchTarget` (#4273)

* feat: add `cmake.ctest.testSuiteDelimiter.debugLaunchTarget`

* fix: setting name

* fix: description name

* chore: add changelog entry

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* fix(ctest): don't require backtrace in presence of DEF_SOURCE_LINE (#4321)

* ctest: Don't require backtrace in presence of DEF_SOURCE_LINE

* docs: add CHANGELOG entry

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* Fix lowercase include paths on Mac (#4325)

* Fix lowercase include paths on Mac

* Update CHANGELOG for version 1.21

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error (#4341)

* Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error

* Move bug fix entry in CHANGELOG to 1.21 section

* Dev/snehara/update readme (#4338)

* graphics

* more images

* readme updates

* whitespace

* html sanitization

* made picture clarity better

* Update README.md

* Update README.md

* rewording suggestion from Garrett

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* rewording suggestion from Garrett

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* rewording suggestion from Garrett

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* rewording suggestion from Garrett

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* reordered features

* rewording and fixing broken contributing link

* removed extra period

* made feature and banner updates

* updated alt text

* reverted wording

* removed cache editor feature image

* updated wording for presets support feature

* removed extra image

---------

Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>

* fix getProjectForFolder (#4348)

* Don't require LCOV to be found in test project (#4351)

* Update README.md (#4350)

* Update README.md

added a brief description of the features we support

* updated readme

* be more explicit in what we check (#4352)

* Localization - Translated Strings (#4344)

Co-authored-by: csigs <csigs@users.noreply.github.com>

* Localization - Translated Strings (#4353)

Co-authored-by: csigs <csigs@users.noreply.github.com>

* Changes the location of temp directory holding the tests (TESTS_DIR).

Using /tmp is not compatible with windows use

* Remove useless CMAKE variable

* Adapt single-root-ctest end-to-end tests to current API and fix Windows portability

 * Adopt CommandResult.exitCode API for cmake.ctest assertions (cmakeProjProject.ctest() now returns Promise<CommandResult>)
 * Set CMT_TESTING_OVERRIDE_TEST_EXPLORER=1 in launch.json so refreshTests in test mode falls through to runCTestImpl
 * Resolve cleanUpTestResultFiles ${workspaceFolder} macro at runtime instead of letting it land literally in y in rimraf
 * Pin Windows generator to "Visual Studio 17 2022" (windows-2022 runner no longer ships VS 16 2019)
 * Set CXX_STANDARD 17 on generated test executables (MSVC default is C++14 and the sources use <filesystem>)
 * Use path::string() in generate_output_file.cpp (path::string_type is std::wstring on Windows)
 * Set WINDOWS_EXPORT_ALL_SYMBOLS on TestUtils so the .lib import library is generated on MSVC

* enhance end-to-end CTest tests: update paths for cross-platform compatibility, improve directory handling, and refactor test configuration management.

* cleanUpTestResultFiles now derives the test result directory from the configure preset's `cacheVariables.TESTS_DIR` (expanding ${sourceDir})
   rather than a hardcoded literal that could silently drift, and guards
   the rmdir with `fs.exists` so the very first setup() — when the
   directory is absent — does not throw.
 * Snapshot the workspace-folder values of `cmake.ctest.allowParallelJobs`
   and `cmake.ctest.testSuiteDelimiter` once before any suite runs and
   restore them once after every suite has finished, so the project's
   checked-in `.vscode/settings.json` is no longer left dirty by a test
   run. Restoration intentionally happens in a global `after` hook (not
   per-suite) because writing the setting fires the extension's
   `refreshTests` cascade; deferring it to the very end avoids the
   cascade racing with the next suite's `BuildDirectoryHelper.clear()`
   on Windows (EBUSY) and isolates the shutdown-time build attempt to a
   scoped try/catch.

* lint errors

---------

Co-authored-by: Guillaume Peillex <guillaume.peillex@cea.fr>
Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Co-authored-by: nerix <nero.9@hotmail.de>
Co-authored-by: Ron <45816308+rjaegers@users.noreply.github.com>
Co-authored-by: tringenbach <tim.ringenbach@gmail.com>
Co-authored-by: 0xemgy <139615394+0xemgy@users.noreply.github.com>
Co-authored-by: Tofik Sonono <tofik.sonono@intel.com>
Co-authored-by: csigs <csigs@users.noreply.github.com>
Co-authored-by: Local Merge <noreply@anthropic.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants