Skip to content

Commit 4d258c5

Browse files
authored
Merge pull request #216 from carstene1ns/doctest
Use `doctest` for unit tests
2 parents 69bd43d + 68b5b42 commit 4d258c5

6 files changed

Lines changed: 5696 additions & 63 deletions

File tree

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
/builds/autoconf/
55
!/builds/autoconf/m4/m4_ax_pkg_check_modules.m4
66
/liblcf-*/
7-
/tests/*.log
8-
/tests/*.trs
9-
/time_stamp*
7+
/test_runner*
108
.deps/
119
.libs/
1210
.dirstamp
@@ -20,7 +18,6 @@ configure
2018
liblcf-*.tar.gz
2119
libtool
2220
stamp-h1
23-
test-suite.log
2421
*.la
2522
*.lo
2623

@@ -57,5 +54,4 @@ Makefile
5754
*.pc
5855

5956
# tests
60-
/tests/time_stamp*
61-
!/tests/time_stamp.cpp
57+
/tests/test_runner*

Makefile.am

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,22 @@ pkginclude_HEADERS = \
193193
src/generated/rpg_trooppage.h \
194194
src/generated/rpg_variable.h
195195

196-
check_PROGRAMS = time_stamp
197-
TESTS = time_stamp
198-
time_stamp_SOURCES = tests/time_stamp.cpp
199-
time_stamp_CPPFLAGS = \
196+
check_PROGRAMS = test_runner
197+
test_runner_SOURCES = \
198+
tests/time_stamp.cpp \
199+
tests/test_main.cpp
200+
test_runner_CPPFLAGS = \
200201
-I$(srcdir)/src \
201202
-I$(srcdir)/src/generated
202-
time_stamp_CXXFLAGS = \
203+
test_runner_CXXFLAGS = \
203204
-std=c++11 \
204205
$(EXPAT_CXXFLAGS) \
205206
$(ICU_CXXFLAGS)
206-
time_stamp_LDADD = \
207+
test_runner_LDADD = \
207208
liblcf.la \
208209
$(EXPAT_LIBS) \
209210
$(ICU_LIBS)
210-
time_stamp_LDFLAGS = -no-install
211+
test_runner_LDFLAGS = -no-install
212+
213+
check-local:
214+
$(AM_V_at)./test_runner

builds/cmake/CMakeLists.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,10 @@ install(FILES ${CMAKE_BINARY_DIR}/liblcf.pc
8383
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
8484

8585
# test
86-
enable_testing()
87-
8886
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src)
8987

90-
function(CXX_TEST target libs)
91-
get_filename_component(name ${target} NAME_WE)
92-
add_executable(test_${name} ${target})
93-
target_link_libraries(test_${name} ${PROJECT_NAME} ${libs})
94-
add_test(
95-
NAME test_${name}
96-
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
97-
COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_${name})
98-
add_dependencies(test_${name} ${PROJECT_NAME})
99-
endfunction()
100-
10188
file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/*.cpp)
102-
foreach(i ${TEST_FILES})
103-
cxx_test(${i} ${ICU_LIBRARIES} ${EXPAT_LIBRARY})
104-
endforeach()
89+
add_executable(test_runner EXCLUDE_FROM_ALL ${TEST_FILES})
90+
target_link_libraries(test_runner ${PROJECT_NAME} ${ICU_LIBRARIES} ${EXPAT_LIBRARY})
91+
add_custom_target(check COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_runner)
92+
add_dependencies(check test_runner)

0 commit comments

Comments
 (0)