Skip to content

Commit

Permalink
Update GoogleTest to latest version (#369)
Browse files Browse the repository at this point in the history
* Remove old gtest version
* Add new vendored Googletest version
* CMake updates for new googletest version
* Test updates for new googletest version
* Remove unnecessary gtest_main functions
* Update test/CMakeLists.txt

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
  • Loading branch information
mjcarroll and ahcorde authored Jun 29, 2022
1 parent 265b31b commit fac0793
Show file tree
Hide file tree
Showing 95 changed files with 11,438 additions and 21,004 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ find_package(gz-cmake3 REQUIRED)
#============================================================================
# Configure the project
#============================================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

gz_configure_project(
REPLACE_IGNITION_INCLUDE_PATH gz/physics
VERSION_SUFFIX pre1)
Expand Down
6 changes: 0 additions & 6 deletions bullet/src/EntityManagement_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,3 @@ TEST(EntityManagement_TEST, ConstructEmptyWorld)
auto world = engine->ConstructEmptyWorld("empty world");
ASSERT_NE(nullptr, world);
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions bullet/src/SDFFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,3 @@ TEST(SDFFeatures_TEST, WorldIsParentOrChild)
EXPECT_NE(nullptr, joint);
}
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions dartsim/src/Base_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,3 @@ TEST(BaseClass, AddNestedModel)
ASSERT_EQ(2u, parentModelInfo.nestedModels.size());
EXPECT_EQ(nestedModel2ID, parentModelInfo.nestedModels[1]);
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
10 changes: 2 additions & 8 deletions dartsim/src/Collisions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class Collisions_TEST
public ::testing::WithParamInterface<std::string>
{};

INSTANTIATE_TEST_CASE_P(PhysicsPlugins, Collisions_TEST,
::testing::ValuesIn(gz::physics::test::g_PhysicsPluginLibraries),); // NOLINT
INSTANTIATE_TEST_SUITE_P(PhysicsPlugins, Collisions_TEST,
::testing::ValuesIn(gz::physics::test::g_PhysicsPluginLibraries));

TestWorldPtr ConstructMeshPlaneWorld(
const gz::physics::Engine3dPtr<TestFeatureList> &_engine,
Expand Down Expand Up @@ -155,9 +155,3 @@ TEST_P(Collisions_TEST, MeshAndPlane)
-1.91, link->FrameDataRelativeToWorld().pose.translation()[2], 0.05);
}
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
7 changes: 0 additions & 7 deletions dartsim/src/EntityManagement_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,3 @@ TEST(EntityManagement_TEST, ModelByIndexWithNestedModels)
ASSERT_NE(nullptr, model2Again);
EXPECT_EQ(2ul, model2Again->GetIndex());
}


int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
7 changes: 0 additions & 7 deletions dartsim/src/JointFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1392,10 +1392,3 @@ TEST_F(JointTransmittedWrenchFixture, ContactForces)
EXPECT_TRUE(physics::test::Equal(expectedWrenchAtMotorJointInJoint,
wrenchAtMotorJointInJoint, 1e-4));
}

/////////////////////////////////////////////////
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
8 changes: 0 additions & 8 deletions dartsim/src/KinematicsFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,3 @@ TEST_F(KinematicsFeaturesFixture, JointFrameSemantics)
EXPECT_TRUE(
physics::test::Equal(F_WCexpected, childLinkFrameData, 1e-6));
}

/////////////////////////////////////////////////
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

7 changes: 0 additions & 7 deletions dartsim/src/LinkFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,3 @@ TEST_F(LinkFeaturesFixture, ModelAxisAlignedBoundingBox)
EXPECT_PRED_FORMAT2(
vectorPredicate, physics::Vector3d(2, 2, 1.0), bboxLinkFrame.max());
}

/////////////////////////////////////////////////
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
14 changes: 4 additions & 10 deletions dartsim/src/SDFFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ class SDFFeatures_TEST : public ::testing::TestWithParam<LoaderType>
};

// Run with different load world functions
INSTANTIATE_TEST_CASE_P(LoadWorld, SDFFeatures_TEST,
INSTANTIATE_TEST_SUITE_P(LoadWorld, SDFFeatures_TEST,
::testing::Values(LoaderType::Whole,
LoaderType::Piecemeal), );
LoaderType::Piecemeal));

/////////////////////////////////////////////////
// Test that the dartsim plugin loaded all the relevant information correctly.
Expand Down Expand Up @@ -717,9 +717,9 @@ class SDFFeatures_FrameSemantics: public SDFFeatures_TEST
};

// Run with different load world functions
INSTANTIATE_TEST_CASE_P(LoadWorld, SDFFeatures_FrameSemantics,
INSTANTIATE_TEST_SUITE_P(LoadWorld, SDFFeatures_FrameSemantics,
::testing::Values(LoaderType::Whole,
LoaderType::Piecemeal), );
LoaderType::Piecemeal));

/////////////////////////////////////////////////
TEST_P(SDFFeatures_FrameSemantics, LinkRelativeTo)
Expand Down Expand Up @@ -931,9 +931,3 @@ TEST_P(SDFFeatures_TEST, Shapes)
ASSERT_EQ(1u, skeleton->getNumBodyNodes());
}
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
7 changes: 0 additions & 7 deletions dartsim/src/ShapeFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,3 @@ TEST_F(ShapeFeaturesFixture, SecondarySlipCompliance)
}
}
#endif

/////////////////////////////////////////////////
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
10 changes: 2 additions & 8 deletions dartsim/src/SimulationFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,5 @@ TEST_P(SimulationFeatures_TEST, RetrieveContacts)
}
}

INSTANTIATE_TEST_CASE_P(PhysicsPlugins, SimulationFeatures_TEST,
::testing::ValuesIn(gz::physics::test::g_PhysicsPluginLibraries),); // NOLINT

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
INSTANTIATE_TEST_SUITE_P(PhysicsPlugins, SimulationFeatures_TEST,
::testing::ValuesIn(gz::physics::test::g_PhysicsPluginLibraries));
7 changes: 0 additions & 7 deletions dartsim/src/WorldFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,3 @@ TEST_F(WorldFeaturesFixture, Solver)
world->SetSolver("pgs");
EXPECT_EQ("PgsBoxedLcpSolver", world->GetSolver());
}

/////////////////////////////////////////////////
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
gz_get_libsources_and_unittests(sources gtest_sources)
gz_create_core_library(SOURCES ${sources})

gz_create_core_library(SOURCES ${sources} CXX_STANDARD 17)

target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PUBLIC
Expand Down
6 changes: 0 additions & 6 deletions src/Cloneable_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,3 @@ TEST(Cloneable_TEST, Copy)
copyTo->Copy(std::move(*moveFrom));
EXPECT_EQ("movingFrom", copyToCasted->myString);
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
7 changes: 0 additions & 7 deletions src/CompositeData_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,3 @@ TEST(CompositeData_TEST, Queries)
EXPECT_NE(0u, all.count(typeid(IntData).name()));
EXPECT_NE(0u, all.count(typeid(BoolData).name()));
}

/////////////////////////////////////////////////
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions src/FeatureList_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,3 @@ TEST(FeatureList_TEST, Hierarchy)
EXPECT_TRUE((detail::TupleContainsBase<Conflict1, Level3Tuple>::value));
EXPECT_TRUE((detail::TupleContainsBase<Conflict2, Level3Tuple>::value));
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions src/Feature_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,3 @@ TEST(Feature_TEST, SimpleMock)

EXPECT_EQ(3u, missing.size());
}

int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions src/FilterTuple_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,3 @@ TEST(FilterTuple_TEST, CombineListsResult)
EXPECT_EQ(1u, std::tuple_size<SingleCombineListsChildFilter>::value);
EXPECT_EQ(1u, std::tuple_size<SingleCombineLists>::value);
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions src/FindFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,3 @@ TEST(FindFeatures_TEST, Unimplemented)
// No plugins should ever have implemented this spoofed feature list
EXPECT_EQ(0u, foundPlugins.size());
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
7 changes: 0 additions & 7 deletions src/SpecifyData_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,3 @@ TEST(SpecifyData, Move)
EXPECT_EQ("old_string", opEqData.Get<StringData>().myString);
}
}

/////////////////////////////////////////////////
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
26 changes: 1 addition & 25 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
if (NOT BUILD_TESTING)
return()
endif()

include_directories (
${PROJECT_SOURCE_DIR}/test/gtest/include
${PROJECT_SOURCE_DIR}/test/gtest
${PROJECT_SOURCE_DIR}/test
${CMAKE_BINARY_DIR}/include
)

# Build gtest
add_library(gtest STATIC gtest/src/gtest-all.cc)
add_library(gtest_main STATIC gtest/src/gtest_main.cc)
target_link_libraries(gtest_main gtest)
set_property(TARGET gtest_main PROPERTY CXX_STANDARD ${c++standard})
set_property(TARGET gtest PROPERTY CXX_STANDARD ${c++standard})
set(GTEST_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest.a")
set(GTEST_MAIN_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest_main.a")

execute_process(COMMAND cmake -E remove_directory ${CMAKE_BINARY_DIR}/test_results)
execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results)
# This gives us access to src/utils headers
include_directories(${PROJECT_SOURCE_DIR}/src ${GTEST_INCLUDE_DIRS})

#============================================================================
# Do a fake install of ign-physics in order to test the examples.
#============================================================================
Expand All @@ -44,6 +19,7 @@ ExternalProject_Add(
"-DCMAKE_INSTALL_PREFIX=${FAKE_INSTALL_PREFIX}"
)

add_subdirectory(gtest_vendor)
add_subdirectory(benchmark)
add_subdirectory(common_test)
add_subdirectory(plugins)
Expand Down
3 changes: 2 additions & 1 deletion test/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ set(tests
ExpectData.cc
)

gz_add_benchmarks(SOURCES ${tests})
gz_add_benchmarks(SOURCES ${tests}
INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src)
Loading

0 comments on commit fac0793

Please sign in to comment.