tests: unify tests under one target
to ease sharing code. vis/light tests are going to need the testqbsp infrastructure.
This commit is contained in:
parent
a9b9892761
commit
050886f32c
|
|
@ -109,6 +109,7 @@ endif ()
|
|||
add_subdirectory(qbsp)
|
||||
add_subdirectory(vis)
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(tests)
|
||||
|
||||
install(FILES README.md DESTINATION bin)
|
||||
install(FILES changelog.md DESTINATION bin)
|
||||
|
|
|
|||
|
|
@ -28,33 +28,15 @@ if ( $? -eq $false ) {
|
|||
throw "package failed"
|
||||
}
|
||||
|
||||
.\common\Release\testcommon.exe
|
||||
.\tests\Release\tests.exe
|
||||
|
||||
if ( $? -eq $false ) {
|
||||
throw "testcommon failed"
|
||||
}
|
||||
|
||||
.\light\Release\testlight.exe
|
||||
|
||||
if ( $? -eq $false ) {
|
||||
throw "testlight failed"
|
||||
}
|
||||
|
||||
.\qbsp\Release\testqbsp.exe
|
||||
|
||||
if ( $? -eq $false ) {
|
||||
throw "testqbsp failed"
|
||||
throw "tests failed"
|
||||
}
|
||||
|
||||
# run hidden tests (releaseonly)
|
||||
.\qbsp\Release\testqbsp.exe [.]
|
||||
.\tests\Release\tests.exe [.]
|
||||
|
||||
if ( $? -eq $false ) {
|
||||
throw "testqbsp [.] failed"
|
||||
}
|
||||
|
||||
.\vis\Release\testvis.exe --allow-running-no-tests
|
||||
|
||||
if ( $? -eq $false ) {
|
||||
throw "testvis failed"
|
||||
throw "tests [.] failed"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,8 @@ make -j8 VERBOSE=1 || exit 1
|
|||
cpack || exit 1
|
||||
|
||||
# run tests
|
||||
./common/testcommon || exit 1
|
||||
./light/testlight || exit 1
|
||||
./qbsp/testqbsp || exit 1
|
||||
./qbsp/testqbsp [.] || exit 1 # run hidden tests (releaseonly)
|
||||
./vis/testvis --allow-running-no-tests || exit 1
|
||||
./tests/tests || exit 1
|
||||
./tests/tests [.] || exit 1 # run hidden tests (releaseonly)
|
||||
|
||||
# check rpath
|
||||
readelf -d ./light/light
|
||||
|
|
|
|||
|
|
@ -51,8 +51,5 @@ otool -L ./bspinfo/bspinfo
|
|||
otool -L ./bsputil/bsputil
|
||||
|
||||
# run tests
|
||||
./common/testcommon || exit 1
|
||||
./light/testlight || exit 1
|
||||
./qbsp/testqbsp || exit 1
|
||||
./qbsp/testqbsp [.] || exit 1 # run hidden tests (releaseonly)
|
||||
./vis/testvis --allow-running-no-tests || exit 1
|
||||
./tests/tests || exit 1
|
||||
./tests/tests [.] || exit 1 # run hidden tests (releaseonly)
|
||||
|
|
|
|||
|
|
@ -36,18 +36,3 @@ add_library(common STATIC
|
|||
${CMAKE_SOURCE_DIR}/include/common/vectorutils.hh)
|
||||
|
||||
target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb fmt::fmt nlohmann_json::nlohmann_json)
|
||||
|
||||
# test target
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(COMMON_TEST_SOURCE
|
||||
test.cc)
|
||||
add_executable(testcommon ${COMMON_TEST_SOURCE})
|
||||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET testcommon POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testcommon>")
|
||||
target_link_libraries (testcommon common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2WithMain fmt::fmt)
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(testcommon)
|
||||
|
|
@ -115,33 +115,3 @@ endif(embree_FOUND)
|
|||
|
||||
install(TARGETS light RUNTIME DESTINATION bin)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/gpl_v3.txt DESTINATION bin)
|
||||
|
||||
# test (see: https://google.github.io/googletest/quickstart-cmake.html)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(LIGHT_TEST_SOURCE
|
||||
test_entities.cc
|
||||
test_ltface.cc
|
||||
test_light.cc
|
||||
test_common.cc)
|
||||
add_executable(testlight ${LIGHT_TEST_SOURCE})
|
||||
target_link_libraries (testlight PRIVATE liblight common ${CMAKE_THREAD_LIBS_INIT} Catch2::Catch2WithMain fmt::fmt)
|
||||
if (embree_FOUND)
|
||||
target_link_libraries (testlight PRIVATE embree)
|
||||
|
||||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET testlight POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testlight>"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:testlight>")
|
||||
|
||||
if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
|
||||
add_custom_command(TARGET testlight POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:testlight>")
|
||||
endif()
|
||||
|
||||
add_definitions(-DHAVE_EMBREE)
|
||||
endif (embree_FOUND)
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(testlight)
|
||||
|
|
@ -41,20 +41,3 @@ install(TARGETS qbsp RUNTIME DESTINATION bin)
|
|||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET qbsp POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:qbsp>")
|
||||
|
||||
# test (see: https://google.github.io/googletest/quickstart-cmake.html)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(QBSP_TEST_SOURCE
|
||||
test_qbsp.cc
|
||||
${CMAKE_BINARY_DIR}/testmaps.hh)
|
||||
add_executable(testqbsp ${QBSP_TEST_SOURCE})
|
||||
target_link_libraries (testqbsp libqbsp common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2WithMain fmt::fmt nanobench::nanobench)
|
||||
|
||||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET testqbsp POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testqbsp>")
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(testqbsp)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
enable_testing()
|
||||
|
||||
add_executable(tests
|
||||
test.cc
|
||||
test_common.cc
|
||||
test_entities.cc
|
||||
test_light.cc
|
||||
test_ltface.cc
|
||||
test_qbsp.cc
|
||||
test_vis.cc
|
||||
${CMAKE_BINARY_DIR}/testmaps.hh
|
||||
)
|
||||
|
||||
find_package(embree 3.0 REQUIRED)
|
||||
# HACK: Windows embree .dll's from https://github.com/embree/embree/releases ship with a tbb12.dll
|
||||
# and we need to copy it from the embree/bin directory to our light.exe/testlight.exe dir in order for them to run
|
||||
find_file(EMBREE_TBB_DLL tbb12.dll
|
||||
"${EMBREE_ROOT_DIR}/bin"
|
||||
NO_DEFAULT_PATH)
|
||||
if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
|
||||
message(STATUS "Found embree EMBREE_TBB_DLL: ${EMBREE_TBB_DLL}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(tests libqbsp liblight libvis common TBB::tbb Catch2::Catch2WithMain fmt::fmt nanobench::nanobench)
|
||||
|
||||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:tests>"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:tests>")
|
||||
if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
|
||||
add_custom_command(TARGET tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:tests>")
|
||||
endif()
|
||||
|
||||
add_definitions(-DHAVE_EMBREE)
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(tests)
|
||||
|
|
@ -26,18 +26,3 @@ add_custom_command(TARGET vis POST_BUILD
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:vis>")
|
||||
|
||||
install(TARGETS vis RUNTIME DESTINATION bin)
|
||||
|
||||
# test
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_executable(testvis
|
||||
test_vis.cc)
|
||||
target_link_libraries(testvis PRIVATE libvis common Catch2::Catch2WithMain fmt::fmt)
|
||||
|
||||
# HACK: copy .dll dependencies
|
||||
add_custom_command(TARGET testvis POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testvis>")
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(testvis)
|
||||
|
|
|
|||
Loading…
Reference in New Issue