mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-10 22:37:15 +02:00
added a way to find test data wihout copy
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -95,7 +95,8 @@
|
|||||||
"regex": "cpp",
|
"regex": "cpp",
|
||||||
"source_location": "cpp",
|
"source_location": "cpp",
|
||||||
"future": "cpp",
|
"future": "cpp",
|
||||||
"typeindex": "cpp"
|
"typeindex": "cpp",
|
||||||
|
"*.in": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "enabled"
|
"C_Cpp.errorSquiggles": "enabled"
|
||||||
}
|
}
|
@ -17,9 +17,7 @@ set_target_properties(tests PROPERTIES
|
|||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
catch_discover_tests(tests)
|
|
||||||
|
|
||||||
if(AARE_TESTS)
|
|
||||||
set(TestSources
|
set(TestSources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test.cpp
|
||||||
)
|
)
|
||||||
@ -28,4 +26,12 @@ if(AARE_TESTS)
|
|||||||
#Work around to remove, this is not the way to do it =)
|
#Work around to remove, this is not the way to do it =)
|
||||||
# target_include_directories(tests PRIVATE ${CMAKE_SOURCE_DIR}/include/common)
|
# target_include_directories(tests PRIVATE ${CMAKE_SOURCE_DIR}/include/common)
|
||||||
target_link_libraries(tests PRIVATE core aare_compiler_flags)
|
target_link_libraries(tests PRIVATE core aare_compiler_flags)
|
||||||
endif()
|
|
||||||
|
catch_discover_tests(tests
|
||||||
|
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/data
|
||||||
|
)
|
||||||
|
|
||||||
|
#configure a header to pass test file paths
|
||||||
|
get_filename_component(TEST_FILE_PATH ${PROJECT_SOURCE_DIR}/data ABSOLUTE)
|
||||||
|
configure_file(test_config.hpp.in test_config.hpp)
|
||||||
|
target_include_directories(tests PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
@ -1 +1,17 @@
|
|||||||
//Empty file to satisfy CMake when no other tests are added
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "test_config.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("Test suite can find data assets"){
|
||||||
|
auto fpath = test_data_path()/ "test_numpy_file.npy";
|
||||||
|
REQUIRE(std::filesystem::exists(fpath));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Test suite can open data assets"){
|
||||||
|
auto fpath = test_data_path()/ "test_numpy_file.npy";
|
||||||
|
auto f = std::ifstream(fpath, std::ios::binary);
|
||||||
|
REQUIRE(f.is_open());
|
||||||
|
}
|
7
tests/test_config.hpp.in
Normal file
7
tests/test_config.hpp.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
static constexpr auto test_data_path_str = "@TEST_FILE_PATH@";
|
||||||
|
inline auto test_data_path() {
|
||||||
|
return std::filesystem::path(test_data_path_str);
|
||||||
|
}
|
Reference in New Issue
Block a user