Skip to content

Commit 2168269

Browse files
authored
Merge pull request #12 from open-eid/test
Compile test data directory path to binary to easy execute test in IDE
2 parents 48f665a + 3e99923 commit 2168269

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ endif()
77
project(libcdoc VERSION 0.1.5)
88

99
macro(SET_ENV NAME DEF)
10-
if(DEFINED ENV{${NAME}})
11-
set(${NAME} $ENV{${NAME}} ${ARGN})
12-
else()
13-
set(${NAME} ${DEF} ${ARGN})
14-
endif()
10+
if(DEFINED ENV{${NAME}})
11+
set(${NAME} $ENV{${NAME}} ${ARGN})
12+
else()
13+
set(${NAME} ${DEF} ${ARGN})
14+
endif()
1515
endmacro()
1616

1717
SET_ENV(BUILD_NUMBER 0)

test/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ set(CMAKE_CXX_STANDARD 20)
22
set(CMAKE_CXX_STANDARD_REQUIRED YES)
33

44
add_executable(unittests libcdoc_boost.cpp)
5+
target_compile_definitions(unittests PRIVATE DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
56
target_link_libraries(unittests cdoc cdoc_priv Boost::unit_test_framework)
67

78
add_test(NAME runtest
8-
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittests --build_info=YES --logger=HRF,all,stdout -- ${CMAKE_CURRENT_SOURCE_DIR}/data
9-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
9+
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittests --build_info=YES --logger=HRF,all,stdout
10+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
11+
)
1012

1113
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS unittests)

test/libcdoc_boost.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <Recipient.h>
99
#include <Utils.h>
1010

11+
#ifndef DATA_DIR
12+
#define DATA_DIR "."
13+
#endif
14+
1115
namespace btools = boost::test_tools;
1216
namespace utf = boost::unit_test;
1317
namespace fs = std::filesystem;
@@ -50,7 +54,7 @@ class FixtureBase
5054
// Get path to test data, provided via argument to the unit tests application
5155
if (utf::framework::master_test_suite().argc <= 1)
5256
{
53-
testDataPath = ".";
57+
testDataPath = DATA_DIR;
5458
}
5559
else
5660
{

0 commit comments

Comments
 (0)