From 31194fd2188eebca9265889f240a8683cb982347 Mon Sep 17 00:00:00 2001 From: Shameek Ganguly Date: Mon, 11 Nov 2024 10:20:55 -0800 Subject: [PATCH] Add all unit test targets and enable layering check Signed-off-by: Shameek Ganguly --- BUILD.bazel | 780 +++++++++++++++++++++++++++++++++++++++- src/SDF_TEST.cc | 8 +- src/Sensor_TEST.cc | 10 +- src/parser_urdf_TEST.cc | 1 - test/BUILD.bazel | 5 + test/test_config.hh.in | 7 +- 6 files changed, 796 insertions(+), 15 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 5d6d2e646..69a429052 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,6 +4,7 @@ load("@rules_license//rules:license.bzl", "license") package( default_applicable_licenses = [":license"], + features = ["layering_check"], ) license( @@ -135,16 +136,118 @@ cc_test( srcs = [ "src/Actor_TEST.cc", ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "sdformat", - }, deps = [ ":sdformat", "@googletest//:gtest_main", ], ) +cc_test( + name = "AirPressure_TEST", + srcs = [ + "src/AirPressure_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Airspeed_TEST", + srcs = [ + "src/Airspeed_TEST.cc", + ], + deps = [ + ":sdformat", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Altimeter_TEST", + srcs = [ + "src/Altimeter_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Atmosphere_TEST", + srcs = [ + "src/Atmosphere_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Box_TEST", + srcs = [ + "src/Box_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Camera_TEST", + srcs = [ + "src/Camera_TEST.cc", + ], + deps = [ + ":sdformat", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Capsule_TEST", + srcs = [ + "src/Capsule_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Collision_TEST", + srcs = [ + "src/Collision_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Cone_TEST", + srcs = [ + "src/Cone_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + cc_test( name = "Console_TEST", srcs = [ @@ -156,6 +259,48 @@ cc_test( ], ) +cc_test( + name = "Converter_TEST", + srcs = [ + "src/Converter_TEST.cc", + ], + data = [ + "sdf/1.10/1_9.convert", + "sdf/1.6/1_5.convert", + "sdf/1.7/1_6.convert", + "sdf/1.8/1_7.convert", + "sdf/1.9/1_8.convert", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "CustomInertiaCalcProperties_TEST", + srcs = [ + "src/CustomInertiaCalcProperties_TEST.cc", + ], + deps = [ + ":sdformat", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Cylinder_TEST", + srcs = [ + "src/Cylinder_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + cc_test( name = "Element_TEST", srcs = [ @@ -168,6 +313,633 @@ cc_test( ], ) +cc_test( + name = "Ellipsoid_TEST", + srcs = [ + "src/Ellipsoid_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Error_TEST", + srcs = [ + "src/Error_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Exception_TEST", + srcs = [ + "src/Exception_TEST.cc", + ], + deps = [ + ":sdformat", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Filesystem_TEST", + srcs = [ + "src/Filesystem_TEST.cc", + ], + deps = [ + ":sdformat", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "ForceTorque_TEST", + srcs = [ + "src/ForceTorque_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Frame_TEST", + srcs = [ + "src/Frame_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "FrameSemantics_TEST", + srcs = [ + "src/FrameSemantics_TEST.cc", + ], + data = [ + "//test:sdf", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Geometry_TEST", + srcs = [ + "src/Geometry_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Gui_TEST", + srcs = [ + "src/Gui_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +# TODO: Enable once gz-utils exposes ExtraTestMacros.hh in bazel build. +# cc_test( +# name = "gz_TEST", +# srcs = [ +# "src/gz_TEST.cc", +# ], +# deps = [ +# ":sdformat", +# "//test:test_utils", +# "@googletest//:gtest_main", +# ], +#) + +cc_test( + name = "Heightmap_TEST", + srcs = [ + "src/Heightmap_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Imu_TEST", + srcs = [ + "src/Imu_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "InterfaceElements_TEST", + srcs = [ + "src/InterfaceElements_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Joint_TEST", + srcs = [ + "src/Joint_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "JointAxis_TEST", + srcs = [ + "src/JointAxis_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Lidar_TEST", + srcs = [ + "src/Lidar_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Light_TEST", + srcs = [ + "src/Light_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Link_TEST", + srcs = [ + "src/Link_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Magnetometer_TEST", + srcs = [ + "src/Magnetometer_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Material_TEST", + srcs = [ + "src/Material_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Mesh_TEST", + srcs = [ + "src/Mesh_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Model_TEST", + srcs = [ + "src/Model_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "NavSat_TEST", + srcs = [ + "src/NavSat_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Noise_TEST", + srcs = [ + "src/Noise_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "OutputConfig_TEST", + srcs = [ + "src/OutputConfig_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Param_TEST", + srcs = [ + "src/Param_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "ParamPassing_TEST", + srcs = [ + "src/ParamPassing_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "parser_TEST", + srcs = [ + "src/parser_TEST.cc", + ], + data = [ + "//test:integration/model", + "//test:sdf", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "parser_urdf_TEST", + srcs = [ + "src/parser_urdf_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "ParserConfig_TEST", + srcs = [ + "src/ParserConfig_TEST.cc", + ], + data = [ + "//test:sdf", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "ParticleEmitter_TEST", + srcs = [ + "src/ParticleEmitter_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Pbr_TEST", + srcs = [ + "src/Pbr_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Physics_TEST", + srcs = [ + "src/Physics_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Plane_TEST", + srcs = [ + "src/Plane_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Plugin_TEST", + srcs = [ + "src/Plugin_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Polyline_TEST", + srcs = [ + "src/Polyline_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "PrintConfig_TEST", + srcs = [ + "src/PrintConfig_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Projector_TEST", + srcs = [ + "src/Projector_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Root_TEST", + srcs = [ + "src/Root_TEST.cc", + ], + data = [ + "//test:sdf", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Scene_TEST", + srcs = [ + "src/Scene_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "SDF_TEST", + srcs = [ + "src/SDF_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + "@gz-math//:Color", + "@gz-math//:Pose3", + "@gz-math//:Vector2", + ], +) + +cc_test( + name = "SemanticPose_TEST", + srcs = [ + "src/SemanticPose_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Sensor_TEST", + srcs = [ + "src/Sensor_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Sky_TEST", + srcs = [ + "src/Sky_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Sphere_TEST", + srcs = [ + "src/Sphere_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Surface_TEST", + srcs = [ + "src/Surface_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Types_TEST", + srcs = [ + "src/Types_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Utils_TEST", + srcs = [ + "src/Utils_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "Visual_TEST", + srcs = [ + "src/Visual_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "World_TEST", + srcs = [ + "src/World_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "XmlUtils_TEST", + srcs = [ + "src/XmlUtils_TEST.cc", + ], + deps = [ + ":sdformat", + "//test:test_utils", + "@googletest//:gtest_main", + ], +) + # Bazel linting buildifier( name = "buildifier.fix", diff --git a/src/SDF_TEST.cc b/src/SDF_TEST.cc index 6b81db9f9..4936e8f98 100644 --- a/src/SDF_TEST.cc +++ b/src/SDF_TEST.cc @@ -20,15 +20,17 @@ #include #include -#include +#include +#include +#include +#include #include #include +#include "sdf/parser.hh" #include "test_config.hh" #include "test_utils.hh" -#include "sdf/sdf.hh" - class SDFUpdateFixture { public: std::string GetName() const {return this->name;} diff --git a/src/Sensor_TEST.cc b/src/Sensor_TEST.cc index 482c6f1f9..df192bede 100644 --- a/src/Sensor_TEST.cc +++ b/src/Sensor_TEST.cc @@ -16,9 +16,15 @@ */ #include -#include "sdf/Noise.hh" +#include "sdf/AirPressure.hh" +#include "sdf/Altimeter.hh" +#include "sdf/Camera.hh" +#include "sdf/ForceTorque.hh" +#include "sdf/Imu.hh" +#include "sdf/Lidar.hh" #include "sdf/Magnetometer.hh" -#include "sdf/sdf.hh" +#include "sdf/NavSat.hh" +#include "sdf/Noise.hh" #include "sdf/Sensor.hh" ///////////////////////////////////////////////// diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index 96b940d99..ece561937 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -19,7 +19,6 @@ #include -#include "sdf/sdf.hh" #include "parser_urdf.hh" #include "test_utils.hh" diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 59b071333..6325d8764 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -25,3 +25,8 @@ cc_library( includes = ["."], visibility = ["//:__subpackages__"], ) + +exports_files([ + "sdf", + "integration/model", +]) diff --git a/test/test_config.hh.in b/test/test_config.hh.in index 303eab375..095189d07 100644 --- a/test/test_config.hh.in +++ b/test/test_config.hh.in @@ -48,13 +48,10 @@ namespace sdf /// \return True if directory is set correctly, false otherwise bool ProjectSourcePath(std::string &_sourceDir) { - std::string bazel_path; // Bazel builds set TEST_SRCDIR - if(gz::utils::env("TEST_SRCDIR", _sourceDir) && - gz::utils::env("GZ_BAZEL_PATH", bazel_path)) + if(gz::utils::env("TEST_SRCDIR", _sourceDir)) { - _sourceDir = sdf::filesystem::append( - _sourceDir, "gz", bazel_path); + _sourceDir = sdf::filesystem::append(_sourceDir, "_main"); return true; } else