Connect unit tests with CTest
This commit is contained in:
parent
fe2fc45014
commit
e77a227cbf
3 changed files with 28 additions and 3 deletions
|
|
@ -61,6 +61,7 @@ if (SFIZZ_BENCHMARKS)
|
|||
endif()
|
||||
|
||||
if (SFIZZ_TESTS)
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
###############################
|
||||
# Test application
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/catch2")
|
||||
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
|
||||
set(SFIZZ_TEST_SOURCES
|
||||
DirectRegionT.cpp
|
||||
RegionValuesT.cpp
|
||||
|
|
@ -47,8 +52,7 @@ set(SFIZZ_TEST_SOURCES
|
|||
)
|
||||
|
||||
add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES})
|
||||
target_link_libraries(sfizz_tests PRIVATE sfizz::internal sfizz::spin_mutex sfizz::jsl)
|
||||
target_link_libraries(sfizz_tests PRIVATE sfizz::internal sfizz::spin_mutex sfizz::jsl sfizz::filesystem)
|
||||
sfizz_enable_lto_if_needed(sfizz_tests)
|
||||
sfizz_enable_fast_math(sfizz_tests)
|
||||
|
||||
file(COPY "." DESTINATION ${CMAKE_BINARY_DIR}/tests)
|
||||
catch_discover_tests(sfizz_tests)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,28 @@
|
|||
#define CATCH_CONFIG_RUNNER
|
||||
#include "catch2/catch.hpp"
|
||||
|
||||
#include <ghc/fs_std.hpp>
|
||||
|
||||
static bool moveToTestsDirectory(const fs::path& searchedPath);
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (!moveToTestsDirectory(fs::u8path("tests/TestFiles"))) {
|
||||
std::cerr << "Failed to locate test files\n";
|
||||
return 1;
|
||||
}
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool moveToTestsDirectory(const fs::path& searchedPath)
|
||||
{
|
||||
while (!fs::exists(searchedPath)) {
|
||||
fs::path cwdPath = fs::current_path();
|
||||
fs::path newPath = cwdPath.parent_path();
|
||||
if (cwdPath == newPath)
|
||||
return false;
|
||||
fs::current_path(newPath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue