Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Tests using ROS not discovered until roscore is started #393

Closed
4 of 5 tasks
stepeos opened this issue Jul 26, 2023 · 1 comment
Closed
4 of 5 tasks

Google Tests using ROS not discovered until roscore is started #393

stepeos opened this issue Jul 26, 2023 · 1 comment

Comments

@stepeos
Copy link

stepeos commented Jul 26, 2023

Hi!, really love the extension, thanks for your effort.

I have found a bug writing Google Tests suites. My tests require roscore to be started as they communicate with the master. I have noticed, that these tests are not discovered/shown in the panel unless roscore is started.
There is (by default) not debugging info that tells the (new and unexperienced user) why tests executables exists, but are not shown in the test explorer.

Checklist

  • The issue is about this extension and NOT about a fork.
  • Check the known issues list.
  • The latest version of the extension was used.
  • It is not related to remote-vscode or I checked the following issue
  • Imagine yourself into my position and think how hard to debug the issue without insufficient information.
    I understand that you have privacy concerns and I expect you to understand that this extension is developed for free.
    Thanks.

Describe the bug

Roscore invocation hinders the extension from discovering tests without notifying the user why tests aren't found.
For me as new cpp testing user, there is no output window for testmate which tells me what is going on, why tests are not discovered!

To Reproduce
Here is a minimal example:
test_roscore.cpp:

// test imports
#include <gtest/gtest.h>

// standard imports
#include <thread>
#include <string>

// third party imports
#include "ros/ros.h"

int main(int argc, char** argv) {
  // echo argc and argv!
  ros::init(argc, argv, "test_roscore");
  std::this_thread::sleep_for(std::chrono::milliseconds(500));
  ros::NodeHandle nh;
  testing::InitGoogleTest(&argc, argv);
  bool success = RUN_ALL_TESTS();
  ros::shutdown();
  return success;
}

Notice that ros::init is called before testing::InitGoogleTests. This implies that that roscore must be started before any of the test suite functions can be used. I have not looked at this repo's source code (sorry no time, master thesis) but I imagine that google tests suite functions are used to discover the tests.

In the CMakeLists.txt:

...
catkin_add_gtest(roscore_tests test/test_roscore.cpp)
target_link_libraries(frontend_test ${catkin_LIBRARIES})

Desktop

not important

  • Extension Version:
  • VS Code Version:
  • Catch2 / Google Test / DOCTest Version:
  • OS Type and Version:
  • Using remote-ssh/docker/wsl?:n

Log (optional but recommended)

Log file but names changed. Sorry but I'm very limited in what i can publish and also short on time. Basically what happen is the discovery times out because it keeps waiting for roscore

[2023-07-26 09:00:24.654] [INFO] Activating extension
[2023-07-26 09:00:24.660] [INFO] Activation finished
[2023-07-26 09:00:26.058] [INFO] `test.advancedExecutables` is not defined. trying to use `test.executables`
[2023-07-26 09:00:26.062] [DEBUG] ExecutableConfig.resolveVariable:  {
  value: 'devel/**/*{test,Test,TEST}*',
  resolved: Promise { <pending> },
  strictAllowed: false
}
[2023-07-26 09:00:26.066] [INFO] pattern devel/**/*{test,Test,TEST}* /home/steve/someproject {
  isAbsolute: false,
  absPath: '/home/steve/blablabla/**/*{test,Test,TEST}*',
  isPartOfWs: true,
  relativeToWsPosix: 'devel/**/*{test,Test,TEST}*'
}
[2023-07-26 09:00:26.802] [DEBUG] Checking file for tests: /home/steve/theproblemexecutable
[2023-07-26 09:00:26.803] [DEBUG] Checking file for tests: /home/steve/C
[2023-07-26 09:00:26.803] [DEBUG] Checking file for tests: /home/steve/B
[2023-07-26 09:00:26.804] [DEBUG] Checking file for tests: /home/steve/A
[2023-07-26 09:00:26.807] [DEBUG] ExecutableConfig.resolveVariable:  {
  value: '${absDirpath}',
  resolved: Promise { <pending> },
  strictAllowed: false
}
[2023-07-26 09:00:26.809] [DEBUG] ExecutableConfig.resolveVariable:  { value: {}, resolved: Promise { <pending> }, strictAllowed: true }
[2023-07-26 09:00:26.848] [DEBUG] ExecutableConfig.resolveVariable:  {
  value: '${absDirpath}',
  resolved: Promise { <pending> },
  strictAllowed: false
}
[2023-07-26 09:00:26.849] [DEBUG] ExecutableConfig.resolveVariable:  { value: {}, resolved: Promise { <pending> }, strictAllowed: true }
[2023-07-26 09:00:26.851] [DEBUG] ExecutableConfig.resolveVariable:  {
  value: '${absDirpath}',
  resolved: Promise { <pending> },
  strictAllowed: false
}
[2023-07-26 09:00:26.852] [DEBUG] ExecutableConfig.resolveVariable:  { value: {}, resolved: Promise { <pending> }, strictAllowed: true }
[2023-07-26 09:00:26.854] [DEBUG] ExecutableConfig.resolveVariable:  {
  value: '${absDirpath}',
  resolved: Promise { <pending> },
  strictAllowed: false
}
[2023-07-26 09:00:26.867] [DEBUG] ExecutableConfig.resolveVariable:  { value: {}, resolved: Promise { <pending> }, strictAllowed: true }
[2023-07-26 09:00:31.891] [DEBUG] Not a test executable: /home/steve/theproblemexecutable reason: Error: FsWrapper.spawnAsync signal: SIGTERM
    at ChildProcess.<anonymous> (/home/steve/.vscode/extensions/matepek.vscode-catch2-test-adapter-4.5.1/out/dist/main.js:2:295754)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1121:16)
    at Socket.<anonymous> (node:internal/child_process:479:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:757:14)
[2023-07-26 09:00:32.022] [INFO] reloadTests GoogleTest undefined /home/steve/C
...

Cheers!
Steve

@matepek
Copy link
Owner

matepek commented Jul 27, 2023

Thanks for the kind word ^^

I think I have a solution for you: advancedExecutables: strictPattern

Also you might can specify runTask to set up your roscore.

@matepek matepek closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants