DavidSchuldenfrei/gtest-adapter

Cannot work with executable that contains a space in the path

Closed this issue · 5 comments

In case it is relevant, I'm doing this on MacOS.

I have a launch.json setup like the following:

{
  "name": "Test",
  "type": "lldb",
  "request": "launch",
  "program": "${workspaceFolder}/build/My Program Tests.app/Contents/MacOS/My Program Tests",
  "args": [],
  "cwd": "${workspaceFolder}"
}

When I set "gtest-adapter.debugConfig": ["Test"] in my settings.json, I get an error that it fails to execute "{pathToMyWorkspace}/build/My". If I add symlinks from My_Program_Tests -> My Program Tests in both locations, and update my launch.json appropriately, then this extensions works.

Usually this occurs when the string is not escaped before being passed into a shell for execution. If this is the root cause, then there are a whole set of other valid characters to have in a path which will cause issues. So escaping would be crucial for general-purpose use of this extension. The better way is to run the executable with an array of arguments (similar to execv instead of through a shell but I'm not sure if you have the ability to do this in your extension.

Aside from the above, this brings nice access to gtests. Keep up the good work.

@gbooker Hi,
I don't have a Mac so I cannot replicate. Does the debugger work with such a string?
Can you try surrounding the path by quotes something like
"program": "'${workspaceFolder}/build/My Program Tests.app/Contents/MacOS/My Program Tests'"?

Glad you like the extension

I don't have a Mac so I cannot replicate

Other platforms support spaces in their binary executables. Does this work on your platform?

Does the debugger work with such a string?

Yes. In fact every single launch I have in this project has a space in it and the debugger has never once had any kind of issue.

Can you try surrounding the path by quotes something

No change; still doesn't work. I have previously tried escaping the spaces with \s, but that doesn't work either.

@gbooker I will look into it over the weekend hopefully, and get back to you.
Thanks for your feedback

@gbooker This should be fixed in version 1.8.2. Can you confirm,and I will close this issue?
Thanks

At first it didn't; I confirmed that my extension version was 1.8.2 and I was getting the same error but after restarting VSC it succeeded. Thanks.