Skip to content

Commit

Permalink
Remove old UnitTest++ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Apr 9, 2021
1 parent 893a7c4 commit 1240aaa
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 4,881 deletions.
69 changes: 26 additions & 43 deletions CMakeLists.txt
Expand Up @@ -76,8 +76,7 @@ option(DISABLE_BUNDLED_JSONCPP "Don't fall back to bundled JsonCpp" OFF)

option(ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF)

option(ENABLE_TESTS "Build unit tests (requires Catch2 or UnitTest++)" ON)
option(USE_CATCH2 "Enable Catch2-based unit tests" ON)
option(ENABLE_TESTS "Build unit tests (requires Catch2)" ON)
option(ENABLE_PARALLEL_CTEST "Run CTest using multiple processors" ON)
option(ENABLE_COVERAGE "Scan test coverage using gcov and report" OFF)

Expand All @@ -93,7 +92,7 @@ if (DISABLE_TESTS)
endif()

if(DEFINED ENABLE_TESTS)
set(ENABLE_TESTS ${ENABLE_TESTS} CACHE BOOL "Build unit tests (requires Catch2 or UnitTest++)" FORCE)
set(ENABLE_TESTS ${ENABLE_TESTS} CACHE BOOL "Build unit tests (requires Catch2)" FORCE)
endif()

#### Work around a GCC < 9 bug with handling of _Pragma() in macros
Expand Down Expand Up @@ -176,58 +175,42 @@ endif()
############# PROCESS tests/ DIRECTORY ##############
if(ENABLE_TESTS)
set(TESTS_ENABLED TRUE) # May be overridden by tests/CMakeLists.txt
if (USE_CATCH2)
find_package(Catch2 REQUIRED)
if(ENABLE_PARALLEL_CTEST)
# Figure out the amount of parallelism for CTest
include(ProcessorCount)
ProcessorCount(CPU_COUNT)
if(NOT CPU_COUNT EQUAL 0)
message(STATUS "Setting up unit tests to use ${CPU_COUNT} processors")
set(CTEST_OPTIONS "-j${CPU_COUNT}")
endif()
find_package(Catch2 REQUIRED)
if(ENABLE_PARALLEL_CTEST)
# Figure out the amount of parallelism for CTest
include(ProcessorCount)
ProcessorCount(CPU_COUNT)
if(NOT CPU_COUNT EQUAL 0)
message(STATUS "Setting up unit tests to use ${CPU_COUNT} processors")
set(CTEST_OPTIONS "-j${CPU_COUNT}")
endif()
include(CTest)
include(Catch)
endif()
include(CTest)
include(Catch)
add_subdirectory(tests)
endif()
add_feature_info("Unit tests" TESTS_ENABLED "Compile unit tests for library functions")

############## COVERAGE REPORTING #################
if (ENABLE_COVERAGE)
if (DEFINED CATCH2_TEST_TARGETS)
setup_target_for_coverage_lcov(
NAME coverage
LCOV_ARGS "--no-external"
EXECUTABLE ctest
EXECUTABLE_ARGS ${CTEST_OPTIONS}
DEPENDENCIES openshot ${CATCH2_TEST_TARGETS}
EXCLUDE
"bindings/*"
"examples/*"
"${CMAKE_CURRENT_BINARY_DIR}/bindings/*"
"${CMAKE_CURRENT_BINARY_DIR}/src/*_autogen/*"
)
else()
setup_target_for_coverage_lcov(
NAME coverage
LCOV_ARGS "--no-external"
EXECUTABLE ${UNIT_TEST_TARGETS}
DEPENDENCIES openshot
EXCLUDE
"bindings/*"
"examples/*"
"${CMAKE_CURRENT_BINARY_DIR}/bindings/*"
"${CMAKE_CURRENT_BINARY_DIR}/src/*_autogen/*"
)
endif()
if (ENABLE_COVERAGE AND DEFINED UNIT_TEST_TARGETS)
setup_target_for_coverage_lcov(
NAME coverage
LCOV_ARGS "--no-external"
EXECUTABLE ctest
EXECUTABLE_ARGS ${CTEST_OPTIONS}
DEPENDENCIES openshot ${UNIT_TEST_TARGETS}
EXCLUDE
"bindings/*"
"examples/*"
"${CMAKE_CURRENT_BINARY_DIR}/bindings/*"
"${CMAKE_CURRENT_BINARY_DIR}/src/*_autogen/*"
)
endif()

if(TESTS_ENABLED AND NOT TARGET coverage)
add_custom_target(coverage
COMMAND ctest ${CTEST_OPTIONS}
DEPENDS openshot ${CATCH2_TEST_TARGETS} ${UNIT_TEST_TARGETS}
DEPENDS openshot ${UNIT_TEST_TARGETS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running unit tests (coverage disabled)"
)
Expand Down
59 changes: 5 additions & 54 deletions tests/CMakeLists.txt
Expand Up @@ -42,6 +42,8 @@ endif()
### TEST SOURCE FILES
###
set(OPENSHOT_TESTS
CacheDisk
CacheMemory
Clip
Color
Coordinate
Expand All @@ -60,16 +62,6 @@ set(OPENSHOT_TESTS
Timeline
)

# Handle differences in test sets
if(USE_CATCH2)
list(APPEND OPENSHOT_TESTS
CacheDisk
CacheMemory
)
else()
list(APPEND OPENSHOT_TESTS Cache)
endif()

###
### OPENCV RELATED TEST FILES
###
Expand All @@ -82,9 +74,9 @@ if(ENABLE_OPENCV)
endif()

###
### Catch2 (new) unit tests
### Catch2 unit tests
###
if (TESTS_ENABLED AND USE_CATCH2)
if (TESTS_ENABLED)
message (STATUS "Tests enabled, test executables will be compiled")
include(Catch)

Expand All @@ -108,47 +100,6 @@ if (TESTS_ENABLED AND USE_CATCH2)
list(APPEND CATCH2_TEST_TARGETS openshot-${tname}-test)
endforeach()
# Export target list for coverage use
set(CATCH2_TEST_TARGETS ${CATCH2_TEST_TARGETS} PARENT_SCOPE)
set(UNIT_TEST_TARGETS ${CATCH2_TEST_TARGETS} PARENT_SCOPE)
endif()

###
### UNITTEST++ (old) unit tests
###
if (TESTS_ENABLED AND NOT USE_CATCH2)
# Find UnitTest++ libraries (used for unit testing)
find_package(UnitTest++)

if (NOT UnitTest++_FOUND)
set(TESTS_ENABLED OFF PARENT_SCOPE)
return()
endif()

# Include UnitTest++ headers (needed for compile)
include_directories(${UnitTest++_INCLUDE_DIRS})

set_package_properties(UnitTest++ PROPERTIES
TYPE RECOMMENDED
PURPOSE "Unit testing framework")

################ TESTER EXECUTABLE #################
# Create unit test executable (openshot-test)
message (STATUS "Tests enabled, test executable will be built as tests/openshot-test")

foreach(tname ${OPENSHOT_TESTS})
list(APPEND TEST_SOURCES cppunittest/${tname}_Tests.cpp)
endforeach()

add_executable(openshot-test
cppunittest/tests.cpp
${TEST_SOURCES}
)
target_compile_definitions(openshot-test PRIVATE
TEST_MEDIA_PATH="${TEST_MEDIA_PATH}"
)
# Link libraries to the new executable
target_link_libraries(openshot-test
openshot
${UnitTest++_LIBRARIES}
)
set(UNIT_TEST_TARGETS openshot-test PARENT_SCOPE)
endif()
140 changes: 0 additions & 140 deletions tests/cppunittest/CVObjectDetection_Tests.cpp

This file was deleted.

0 comments on commit 1240aaa

Please sign in to comment.