alepez / vim-gtest

Vim plugin to quickly select and run GoogleTest asyncronously.
64 stars 12 forks source link

Automatically guess the test executable from the source file name & `compile_commands.json` #29

Closed dpelle closed 1 year ago

dpelle commented 1 year ago

It is a tad annoying to have to pass the text executable in the following command, especially when a project has multiple executable names:

:GTestCmd path/to/test/executable

Could the executable name be guessed from the info in the compile_commands.json file, which is typically automatically generated when e.g. using cmake and building with export CMAKE_EXPORT_COMPILE_COMMANDS=ON?

alepez commented 1 year ago

Hi! I see an issue here: what if you have multiple test executables?

In your case, you can just add this to your vimrc something like this:

let g:gtest#gtest_command = "/usr/local/bin/test-from-compile-commands"

and implement /usr/local/bin/test-from-compile-commands to find the executable found in the compile_commands.json and run it.

alepez commented 1 year ago

I'm closing this issue because this can be achieved implementing an external executable, as described above.

If you have a simple working implementation, feel free to add it here as a comment, so I can add an example to the documentation. Or request a PR, as you prefer.