alfaix / neotest-gtest

Google Test adapter for nvim-neotest
MIT License
42 stars 11 forks source link

Setting executable path to parent directory #20

Closed ErikLahm closed 3 months ago

ErikLahm commented 3 months ago

If I understand the usage section in the readme file correctly, then the intended usage is that

  1. I mark all the tests I want to run in the summary pane of neotest and
  2. then run :ConfigureGtest in the same window to
  3. pass the path to the test executables?

At this point it is noted that the following is mentioned in the readme.md files: "You can set the executable path only for parent directory, no need to set it for each test separately."

I understand that I have the possibility to enter here the path to a folder where all different test executables are, instead of just pointing to one specific test executable. However, if I want to just add the path to the parent directory so that I can run tests from different test executables I get the error that no Gtest executables has been found. Am I misunderstanding something?

lets say my project structure is the following: my_project/ ├── build/ │ ├── main │ ├── test_foo │ └── test_bar ├── include/ │ ├── foo.h │ └── bar.h ├── src/ │ ├── main.cpp │ ├── foo.cpp │ └── bar.cpp └── test/ ├── test_foo.cpp └── test_bar.cpp

So under build/ all my executables lie, including the test executables. What I would like to do is the following:

  1. mark _testfoo.cpp and _testbar.cpp
  2. pass the path to the executables as _./myproject/build/

But whenever I do this, I am getting the mentioned error of no Gtest files found.

Just for completeness: when I only run only one test based on one test executable and point the path right to that specific executable, everything works like a charm.

If you need me to provide any other info, please let me know. But since this was rather a question about my understanding of the features, I did not provide much more info.

Thanks a lot!

alfaix commented 3 months ago

Hey @ErikLahm

I understand that I have the possibility to enter here the path to a folder where all different test executables are

This is incorrect - perhaps the documentation can be phrased better. It just means that you don't need to set executables for each test file, but you still need to configure each executable separately. Usually (always?) multiple files in a given folder compile to a single executable, so you would select that parent folder, then type the path to the executable.

What I would like to do is the following:

  1. mark test_foo.cpp and test_bar.cpp
  2. pass the path to the executables as ./my_project/build/

This won't work, unfortunately. You have to mark test_foo.cpp, then set the executable for it, and then do the same for test_bar.cpp. What the documentation is trying to say is if you had test_foo/a.cpp, test_foo/b.cpp, then you can only configure the executable for test_foo/. Hope this makes sense.

That said, I'm working now on executable discovery with CMake, which hopefully should remove the need to do this annoying manual configuration and recompilation.

ErikLahm commented 3 months ago

Hi @alfaix,

Thank you so much for the quick and thorough answer. This definitely helps clarifying it for me.

Looking forward to any updates and thank you for working on this piece.