-
Notifications
You must be signed in to change notification settings - Fork 41
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
Added basic architecture for common tests #357
Conversation
Signed-off-by: ahcorde <[email protected]>
I like this, it's very much in line with what we discussed. @scpeters what do you think? |
Signed-off-by: ahcorde <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #357 +/- ##
==========================================
- Coverage 75.46% 74.55% -0.92%
==========================================
Files 128 128
Lines 5552 5628 +76
==========================================
+ Hits 4190 4196 +6
- Misses 1362 1432 +70
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach reminds me of the approach in gazebo11, which has a hard-coded list of physics engines to use. I've been envisioning an executable like the hello_world_loader that takes the path to a physics plugin as an input and uses FindFeatures::From to identify the plugin names within that file that implement the specified FeatureList
. The main difference from hello_world_loader
is that it would be a gtest executable (if possible) and run test expectations against the APIs implemented by the plugin.
Eventually, I had imagined that this test executable could be installed somewhere not on the PATH
(like libexec
) and exposed as part of an ign physics test
command for use by 3rd-party physics plugin developers, but that we would also have cmake
logic to add tests that run this test executable directly with paths to the dartsim
, bullet
, and tpe-plugin
binaries in the build folder.
test/test_common_config.h.in
Outdated
gz::physics::TestValues()) | ||
|
||
static const std::vector<const char *> kPhysicsEngineTestValues | ||
{"bullet", "dartsim", "tpe"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this reminds me of gazebo11's approach
test/common_test/basic_test.cc
Outdated
} | ||
|
||
INSTANTIATE_TEST_CASE_P(EntityManagementFeatures, EntityManagementFeaturesTest, | ||
PHYSICS_ENGINE_VALUES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this reminds me of gazebo11's approach
Signed-off-by: ahcorde <[email protected]>
…om/ignitionrobotics/ign-physics into ahcorde/common_test_initial_commit
@scpeters what do you think about this logic ? |
Signed-off-by: ahcorde <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment variables are a little easier to set from cmake, but if possible I think it would be nice to use CLI arguments to specify the library name and optional plugin name. We can save that for a later refactoring though
test/common_test/basic_test.cc
Outdated
{ | ||
gz::common::Console::SetVerbosity(4); | ||
|
||
if (!gz::common::env("PHYSICS_ENGINE_NAME", physicsEngineName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't need to specify PHYSICS_ENGINE_NAME
. If it's not specified, we should use FindFeatures3d
to identify the plugin names contained within the LIB_TO_TEST
and then test each of those plugins. To support this, we should get the list of pluginNames in SetUp
and move the gz::plugin::Loader
instantiation and LoadLib
call to a loop in the test case
gz-physics/examples/hello_world_loader/hello_world_loader.cc
Lines 51 to 63 in e91c58a
// Look for 3d plugins auto pluginNames = ignition::physics::FindFeatures3d<Features>::From(pl); if (pluginNames.empty()) { std::cerr << "No plugins with required features found in " << pluginPath << std::endl; } for (const std::string &name : pluginNames) { std::cout << "Testing plugin: " << name << std::endl; ignition::plugin::PluginPtr plugin = pl.Instantiate(name);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: ahcorde <[email protected]>
@scpeters I'm not really sure about adding command line arguments to gtest. I will take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, and I also like the changes in #357
test/common_test/basic_test.cc
Outdated
|
||
class EntityManagementFeaturesTest: | ||
public testing::Test, | ||
public testing::WithParamInterface<const char *> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we aren't currently using parameterized tests (TEST_P
) so this WithParamInterface
line can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <gtest/gtest.h> | ||
|
||
#include <gz/common/Filesystem.hh> | ||
#include <gz/common/Console.hh> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alphabetize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
auto plugins = loader.LoadLib(libToTest); | ||
|
||
pluginNames = gz::physics::FindFeatures3d<Features>::From(loader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future todo: we should also run the 3f
, 2d
, and 2f
variants of FindFeatures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: ahcorde <[email protected]>
…nts (#359) * Added basic architecture for common tests with cmd arguments Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde [email protected]
🎉 New feature
Summary
This PR is a simplifycation of this other PR #354
This draft PR try to set up a common arquitecture to test all physics engine under the same tests avoiding duplication and improving coverage.
Test it
colcon test --merge-install --event-handlers console_direct+ --packages-select ignition-physics6 --ctest-args -R COMMON
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.