Skip to content

Commit

Permalink
Test updates
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Feb 23, 2022
1 parent 052f550 commit 766a773
Show file tree
Hide file tree
Showing 43 changed files with 165 additions and 248 deletions.
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -125,7 +126,7 @@ configure_file("${PROJECT_SOURCE_DIR}/cppcheck.suppress.in"
${PROJECT_BINARY_DIR}/cppcheck.suppress)

ign_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS av events graphics profiler)
COMPONENTS av events graphics profiler testing)

#============================================================================
# Create package information
Expand Down
2 changes: 1 addition & 1 deletion av/src/AudioDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)
#endif

// Open codec
if (avcodec_open2(this->dataPtr->codecCtx,
if (avcodec_open2(this->dataPtr->codecCtx,
this->dataPtr->codec, nullptr) < 0)
{
ignerr << "Couldn't open audio codec.\n";
Expand Down
5 changes: 2 additions & 3 deletions av/src/AudioDecoder_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#include <gtest/gtest.h>

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

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

using namespace ignition;

Expand Down
6 changes: 4 additions & 2 deletions av/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +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-cmake${IGN_CMAKE_VER}::utilities
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
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/Dem_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <ignition/math/Vector3.hh>

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

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

using namespace ignition;

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/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/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: 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
15 changes: 15 additions & 0 deletions include/ignition/common/TempDirectory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ namespace ignition
const std::string &_subDir = "ignition",
bool _cleanup = true);

/// \brief Create a directory in the tempDirectoryPath by expanding
/// a name template. This directory can also be automatically cleaned
/// up when the object goes out of scope.
///
/// The TempDirectory will have the form _root/_subdir/_prefixXXXXX/
///
/// \param[in] _prefix String to be expanded for the template
/// \param[in] _subDir Subdirectory in OS _root, if desired
/// \param[in] _cleanup True to indicate that the filesystem should
/// be cleaned as part of the destructor
public: TempDirectory(const std::string &_root,
const std::string &_prefix = "temp_dir",
const std::string &_subDir = "ignition",
bool _cleanup = true);

/// \brief Destroy the temporary directory, removing from filesystem
/// if cleanup is true.
public: ~TempDirectory();
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
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
ignition-cmake${IGN_CMAKE_VER}::utilities
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}
Expand Down
Loading

0 comments on commit 766a773

Please sign in to comment.