Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

"debug this test" option from editor not parsing flags #2894

Closed
lfourky opened this issue Nov 7, 2019 · 7 comments
Closed

"debug this test" option from editor not parsing flags #2894

lfourky opened this issue Nov 7, 2019 · 7 comments

Comments

@lfourky
Copy link

lfourky commented Nov 7, 2019

Describe the solution you'd like
I would like to be able to pass flags to the debugger when debugging from the editor.

Describe alternatives you've considered
I was able to run dlv and pass flags to it from the terminal, so I guess there must be a way to pass flags when using the "debug this test" from the editor, as well.

Example code that I would like to be able to debug from editor:
https://play.golang.org/p/5eZhpWSmhmp

@BojanKomazec
Copy link

@lfourky Are you passing flag via args property in launch.json? You should have something like:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {},
            "args": ["-f=flag_value_placeholder"]
        }
    ]
}

I am able to pass flag value to tests and debug them from VSCode with this in place.

@BojanKomazec
Copy link

Seems this issue has already been filed: #2115

@lfourky
Copy link
Author

lfourky commented Nov 14, 2019

I have tried to add the flag to "args", yes. Since @BojanKomazec and I had a conversation outside of this, we've come to the conclusion that debugging the tests by using the F5 command or selecting Debug -> Start Debugging (F5) from the menu bar in VSCode works - the flags get parsed!

However, the issue still remains, when pressing the "debug test" option just above a specific test, the flags don't get parsed.

EDIT: Sorry, haven't seen the duplicate issue before. However, it's still ongoing, and I'm happy to provide any feedback if needed.

@ramya-rao-a
Copy link
Contributor

The flags provided in the debug configuration in the launch.json file do not get used by the debug test code lens that appears above individual tests.

But the ones that get passed to go.testFlags should definitely get used. Have you tried that?

@ramya-rao-a
Copy link
Contributor

If you are specifically looking for args that should get passed, then #2115 is indeed tracking this case and we can close this issue

@BojanKomazec
Copy link

BojanKomazec commented Nov 15, 2019

Thanks @ramya-rao-a for the go.testFlags hint. I can confirm that particular test is able to pick passed flags ONLY if run via run test code lens BUT NOT if run via debug test if settings.json contains the above mentioned property and looks like:

{
   ...
   "go.testFlags": ["-f=flag_value_placeholder"],
   ...
}

@lfourky
Copy link
Author

lfourky commented Nov 15, 2019

Thanks everyone. @ramya-rao-a I was not looking for args specifically, I just need a way to pass flags when debugging specific test functions. Will continue the discussion there, though!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants