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

Test updates for common::testing module. #315

Merged
merged 12 commits into from
May 5, 2022
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
# Initialize the project
#============================================================================
project(ignition-common5 VERSION 5.0.0)
set(IGN_COMMON_VER ${PROJECT_VERSION_MAJOR})

#============================================================================
# Find ignition-cmake
Expand Down
3 changes: 1 addition & 2 deletions av/src/AudioDecoder_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include <ignition/common/AudioDecoder.hh>
#include <ignition/utils/ExtraTestMacros.hh>

#include "test_config.h"
#include <ignition/common/testing/TestPaths.hh>

using namespace ignition;

Expand Down
5 changes: 4 additions & 1 deletion av/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ if(IGN_COMMON_BUILD_HW_VIDEO)
target_compile_definitions(${av_target} PRIVATE IGN_COMMON_BUILD_HW_VIDEO)
endif()

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
${av_target}
ignition-common${IGN_COMMON_VER}-testing
)

8 changes: 7 additions & 1 deletion av/src/VideoEncoder_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#include "ignition/common/Console.hh"
#include "ignition/common/VideoEncoder.hh"
#include "test_config.h"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;
using namespace common;
Expand All @@ -28,7 +30,11 @@ class VideoEncoderTest : public common::testing::AutoLogFixture
protected: void SetUp() override
{
Console::SetVerbosity(4);
tempDir = common::testing::MakeTestTempDirectory();
ASSERT_TRUE(tempDir->Valid()) << tempDir->Path();
}

public: std::shared_ptr<ignition::common::TempDirectory> tempDir;
};

/////////////////////////////////////////////////
Expand Down
9 changes: 7 additions & 2 deletions events/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ target_link_libraries(${events_target}
PUBLIC
ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER})

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS ${events_target})
ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
${events_target}
ignition-common${IGN_COMMON_VER}-testing
)
2 changes: 1 addition & 1 deletion events/src/Event_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/testing/AutoLogFixture.hh"

#include <functional>
#include <ignition/common/Event.hh>
Expand Down
2 changes: 1 addition & 1 deletion events/src/MouseEvent_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/MouseEvent.hh"
#include "ignition/common/config.hh"

Expand Down
5 changes: 4 additions & 1 deletion geospatial/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ target_include_directories(${geospatial_target}
${GDAL_INCLUDE_DIR})

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS ${geospatial_target})
LIB_DEPS
${geospatial_target}
ignition-common${IGN_COMMON_VER}-testing
)
4 changes: 3 additions & 1 deletion geospatial/src/Dem_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <ignition/math/Vector3.hh>

#include "ignition/common/geospatial/Dem.hh"
#include "test_config.h"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;

Expand Down
4 changes: 3 additions & 1 deletion geospatial/src/ImageHeightmap_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <gtest/gtest.h>

#include "ignition/common/geospatial/ImageHeightmap.hh"
#include "test_config.h"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

#define ELEVATION_TOL 1e-8

Expand Down
4 changes: 2 additions & 2 deletions graphics/src/Animation_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

#include <gtest/gtest.h>

#include "test_config.h"

#include <ignition/math/Vector3.hh>
#include <ignition/math/Quaternion.hh>
#include <ignition/common/KeyFrame.hh>
#include <ignition/common/Animation.hh>

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

class AnimationTest : public common::testing::AutoLogFixture { };
Expand Down
9 changes: 7 additions & 2 deletions graphics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ target_link_libraries(${graphics_target}
GTS::GTS
FreeImage::FreeImage)

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS ${graphics_target})
ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
${graphics_target}
ignition-common${IGN_COMMON_VER}-testing
)

if(USE_EXTERNAL_TINYXML2)

Expand Down
6 changes: 4 additions & 2 deletions graphics/src/ColladaExporter_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
#include <gtest/gtest.h>
#include "tinyxml2.h"

#include "test_config.h"
#include "ignition/common/ColladaLoader.hh"
#include "ignition/common/ColladaExporter.hh"
#include "ignition/common/Filesystem.hh"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

#ifdef _WIN32
#define snprintf _snprintf
#endif
Expand All @@ -36,7 +38,7 @@ class ColladaExporter : public common::testing::AutoLogFixture {
{
// Call superclass to make sure that logging is initialized
this->common::testing::AutoLogFixture::SetUp();
ASSERT_TRUE(common::testing::TestTmpPath(this->pathOut));
this->pathOut = common::testing::TempPath();
common::createDirectories(this->pathOut);
}

Expand Down
4 changes: 3 additions & 1 deletion graphics/src/ColladaLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
*/
#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"
#include "ignition/common/Material.hh"
#include "ignition/common/ColladaLoader.hh"
#include "ignition/common/Skeleton.hh"
#include "ignition/common/SkeletonAnimation.hh"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;
class ColladaLoader : public common::testing::AutoLogFixture { };

Expand Down
3 changes: 2 additions & 1 deletion graphics/src/GTSMeshUtils_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
#include <gtest/gtest.h>
#include <memory>

#include "test_config.h"
#include "ignition/common/GTSMeshUtils.hh"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

class GTSMeshUtils : public common::testing::AutoLogFixture { };
Expand Down
4 changes: 3 additions & 1 deletion graphics/src/Image_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <gtest/gtest.h>

#include <ignition/common/Image.hh>
#include "test_config.h"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;

Expand Down
4 changes: 3 additions & 1 deletion graphics/src/Material_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/Material.hh"
#include "ignition/common/Pbr.hh"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;

class MaterialTest : public common::testing::AutoLogFixture { };
Expand Down
3 changes: 2 additions & 1 deletion graphics/src/MeshManager_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"
#include "ignition/common/MeshManager.hh"
#include "ignition/common/config.hh"

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

#ifndef _WIN32
Expand Down
3 changes: 2 additions & 1 deletion graphics/src/Mesh_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/Material.hh"
#include "ignition/common/Mesh.hh"
#include "ignition/common/Skeleton.hh"
#include "ignition/common/SubMesh.hh"
#include "ignition/math/Vector3.hh"

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

class MeshTest : public common::testing::AutoLogFixture { };
Expand Down
4 changes: 3 additions & 1 deletion graphics/src/OBJLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
*/
#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"
#include "ignition/common/Material.hh"
#include "ignition/common/OBJLoader.hh"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;

class OBJLoaderTest : public common::testing::AutoLogFixture { };
Expand Down
9 changes: 6 additions & 3 deletions graphics/src/SVGLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

#include <gtest/gtest.h>

#include "test_config.h"

#include "ignition/common/SVGLoader.hh"

#include "ignition/common/testing/AutoLogFixture.hh"
#include "ignition/common/testing/TestPaths.hh"

using namespace ignition;
using namespace common;

Expand All @@ -36,7 +37,9 @@ double tol = 0.05;
/// \brief return path to svg file in test/data/svg
std::string testSvg(const std::string &_filename)
{
return common::testing::TestFile("data", "svg", _filename);
std::string file = common::testing::TestFile("data", "svg", _filename);
EXPECT_TRUE(exists(file));
return file;
}

/////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion graphics/src/SubMesh_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

#include <gtest/gtest.h>

#include "test_config.h"
#include "ignition/math/Vector3.hh"
#include "ignition/common/Mesh.hh"
#include "ignition/common/SubMesh.hh"
#include "ignition/common/MeshManager.hh"

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

class SubMeshTest : public common::testing::AutoLogFixture { };
Expand Down
8 changes: 6 additions & 2 deletions profiler/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ if(IGN_PROFILER_REMOTERY)
endif()
endif()

ign_build_tests(TYPE UNIT SOURCES ${PROFILER_TESTS}
LIB_DEPS ${profiler_target}
ign_build_tests(
TYPE UNIT
SOURCES ${PROFILER_TESTS}
LIB_DEPS
${profiler_target}
ignition-common${IGN_COMMON_VER}-testing
TEST_LIST profiler_tests)

if(TARGET UNIT_Profiler_Remotery_TEST)
Expand Down
2 changes: 1 addition & 1 deletion src/Base64_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <string>
#include <ignition/common/Base64.hh>

#include "test_config.h"
#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

Expand Down
5 changes: 4 additions & 1 deletion src/Battery_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*
*/
#include <gtest/gtest.h>

#include <memory>

#include "ignition/common/Battery.hh"
#include "test_config.h"
#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

Expand Down
9 changes: 4 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ endif()
ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER}
ignition-common${IGN_COMMON_VER}-testing
INCLUDE_DIRS
# Used to make internal source file headers visible to the unit tests
${CMAKE_CURRENT_SOURCE_DIR}
# Used to make test-directory headers visible to the unit tests
${PROJECT_SOURCE_DIR}
# Used to make test_config.h visible to the unit tests
${PROJECT_BINARY_DIR})
${CMAKE_CURRENT_SOURCE_DIR})

if(TARGET UNIT_MovingWindowFilter_TEST)
target_include_directories(UNIT_MovingWindowFilter_TEST PRIVATE
Expand Down
3 changes: 1 addition & 2 deletions src/Console_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

#include "ignition/common/Console.hh"
#include "ignition/common/Filesystem.hh"
#include "ignition/common/TempDirectory.hh"
#include "ignition/common/Util.hh"

#include "test_config.h"

using namespace ignition;
using namespace ignition::common;

Expand Down
3 changes: 2 additions & 1 deletion src/EnumIface_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include <gtest/gtest.h>

#include "ignition/common/EnumIface.hh"
#include "test_config.h"

#include "ignition/common/testing/AutoLogFixture.hh"

using namespace ignition;

Expand Down
Loading