microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.43k stars 430 forks source link

The test process will remain loaded after clicking “Debug Tests” #3757

Open v-frankwang opened 1 month ago

v-frankwang commented 1 month ago

Brief Issue Summary

Repro steps:

  1. Create a new folder named 'CMakeProject1' and open it with vscode.
  2. Create a file named CMakeLists.txt with the following content:
    cmake_minimum_required(VERSION 3.8)
    project(CMakeProject1)
    add_executable(CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h")
    enable_testing()
    add_executable(UnitTest "test.cpp")
    add_test(UnitTest0 UnitTest 0)
    add_test(UnitTest1 UnitTest 1)
  3. Create a file named test.cpp with the following content:
    #include
    auto main() -> int { std::cout << "hello world" << std::endl; }
  4. Create a file named CMakeProject1.cpp with the following content:
    #include "CMakeProject1.h"
    using namespace std;
    int main()
    {
    cout << "Hello CMake." << endl;
    return 0;
    }
  5. Create a file named “CMakeProject1.h” with the following content:
    #pragma once
    #include
  6. Run command: “CMake:configure”
  7. Run command: "C/C++:Add Debug Configuration"
  8. Select :"(lldb) launch“
  9. Click on Testing in the left navigation bar
  10. Click'Debug Tests'.

Actual results: After clicking Debug tests it will keep running and no results will appear, after clicking Cancel Test Run an error popup will appear in the bottom right corner.

https://github.com/microsoft/vscode-cmake-tools/assets/160998958/271226e9-49ac-457b-a891-54e6925f07cd

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

gcampbell-msft commented 1 month ago

@v-frankwang The launch configuration that you have in the launch.json isn't one that is going to work for debugging ctest. Could you change it to something more like the ones mentioned here: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/debug-launch.md. There are some directions on how to get started on creating a launch.json that would work for ctest.

Please let me know what findings you get and whether this helps you.

gcampbell-msft commented 1 month ago

When I try to get a repro following your steps with the launch.json from the video, I get a popup that the launch program "enter program name, for example .... does not exist". I would've expected a popup like that for you, is it possible it happened in the background? Either way, fixing the launch.json should fix it. Let me know if there are any other questions or if this feedback helps.

v-frankwang commented 1 month ago

@gcampbell-msft When I first afirst adddd the Launch.json file lldb(Launch), the situation described in the issue occurs, when I replace the code in the Launch.json file with the Ctest in the documentation you provided, it seems that the problem does not occur, but in the debug console there is a new problem. After I delete the added Launch.json file and add a new Launch.json file lldb(Launch) I get the popup box you mentioned “enter program name, for example .... does not exist”. This popup box should be that the field “program” of the added Launch.json file needs to be filled with “program name”, I think this should be normal.

Adding a Launch.json file for the first time:

https://github.com/microsoft/vscode-cmake-tools/assets/160998958/74d80fe9-2429-4e7f-aa78-9d258d5c13b1

Re-add after deletion:

https://github.com/microsoft/vscode-cmake-tools/assets/160998958/14e93245-0afd-4bc0-b81c-44284e2f249b