matepek / vscode-catch2-test-adapter

Catch2, Google Test and doctest Adapter for the VSCode
https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter
MIT License
210 stars 52 forks source link

Using ${label} and ${parentLabel} on preLaunchTask to start gdbserver of the selected Gtest binary #450

Closed andreucv closed 1 week ago

andreucv commented 1 week ago

Checklist

Describe the bug

Situation: To run a GTest binary I create a docker container with the sdk and the toolchain needed to execute it. I created a wrapper to execute them using your extension, and it works good. I build multiple GTest binaries from different components in my repository. In order to improve performance, how I do it is to maintain the docker container started, and use the executionWrapper setting to execute the GTest binary using a docker exec container_id sh -c ./gtest_component_name_binary.

Problem: Then, as a next step, I want to apply the debug configuration. I'm blocked, as to be able to debug, when I am clicking on the test's debug button I need to start a gdbserver session for the GTest binary selected (I thought on using the ${parentLabel} which I set to be the GTest binary name). I thought on doing that on the preLaunchTask.

However, I have not found any way to pass parameters to the preLaunchTask, as it can only be set as a name of a task inside tasks.json, and I cannot pass the binary name or the testname to do it automatically. I would like to avoid any other user interaction. Do you know how I could do that?

To Reproduce

  1. Go to Testing Section
  2. Click on Debug Test button

Desktop

How I use debug.configTemplate: image

How I thought it could be used (and doesn't work, this task is not recognized as a task): image

matepek commented 1 week ago

(corrected)

These variables are available: https://github.com/matepek/vscode-catch2-test-adapter/blob/3dc483b012d34d6f80ff76a19b70144caec6c34b/src/WorkspaceManager.ts/#L351-L359

And I can make these available relatively easy: - https://github.com/matepek/vscode-catch2-test-adapter/blob/3dc483b012d34d6f80ff76a19b70144caec6c34b/src/WorkspaceManager.ts/#L450-L476

IF the preLaunchTask is inside the debugConfig then both set should be available already. But as you tried it does not work but thats on the debugger not on the extension.

matepek commented 1 week ago

Ah, got confused. That works for the

"runTask" {
  "before": ["task"],
}

only.

matepek commented 1 week ago

What you can use from any tasks are ${testMate.cmd.get-debug-exec} and ${testMate.cmd.get-debug-args}.

(forgot about this functionality, hehhe)