Skip to content

Commit e14fe08

Browse files
committed
test: integrate handlebars and boost.url test suite
This change integrates the test suite library developed for handlebars with the test suite library from boost.url that is being used for other tests. With this integration, Handlebars tests are listed among any other tests in the library. The features used for handlebars, such as the expression decomposer and the diff algorithm for golden master tests, have been integrated into the test library from Boost.URL. fix #390, #384
1 parent e4947d8 commit e14fe08

15 files changed

+766
-662
lines changed

CMakeLists.txt

+33-46
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include(GNUInstallDirs)
2828

2929
option(MRDOX_BUILD_TESTS "Build tests" ${BUILD_TESTING})
3030
option(MRDOX_BUILD_SHARED "Link shared" OFF)
31-
option(MRDOX_BUILD_DOCS "Configure install target" OFF)
31+
option(MRDOX_BUILD_DOCS "Build documentation" OFF)
3232
option(MRDOX_INSTALL "Configure install target" ON)
3333
option(MRDOX_PACKAGE "Build install package" ON)
3434
option(MRDOX_GENERATE_REFERENCE "Generate reference.xml/reference.adoc" ON)
@@ -204,6 +204,7 @@ endif ()
204204

205205
file(GLOB_RECURSE TOOL_SOURCES CONFIGURE_DEPENDS tool/*.cpp tool/*.hpp)
206206
add_executable(mrdox ${TOOL_SOURCES})
207+
target_compile_definitions(mrdox PRIVATE -DMRDOX_TOOL)
207208

208209
target_include_directories(mrdox
209210
PUBLIC
@@ -225,39 +226,6 @@ if (MRDOX_CLANG)
225226
)
226227
endif ()
227228

228-
229-
#-------------------------------------------------
230-
#
231-
# Tests
232-
#
233-
#-------------------------------------------------
234-
235-
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS
236-
test/*.cpp
237-
test/*.hpp)
238-
add_executable(mrdox-test ${TEST_SOURCES})
239-
240-
target_include_directories(mrdox-test
241-
PRIVATE
242-
"${PROJECT_SOURCE_DIR}/include"
243-
"${PROJECT_SOURCE_DIR}/lib"
244-
"${PROJECT_SOURCE_DIR}/test"
245-
"${PROJECT_SOURCE_DIR}/tool"
246-
)
247-
248-
target_compile_definitions(mrdox PRIVATE -DMRDOX_TOOL)
249-
target_link_libraries(mrdox-test PUBLIC mrdox-core)
250-
251-
if (MRDOX_CLANG)
252-
target_compile_options(
253-
mrdox-test
254-
PRIVATE
255-
-Wno-covered-switch-default
256-
)
257-
endif ()
258-
259-
#-------------------------------------------------------------------------------
260-
261229
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
262230
#source_group(TREE ${PROJECT_SOURCE_DIR} PREFIX "" FILES CMakeLists.txt)
263231
source_group(TREE ${PROJECT_SOURCE_DIR}/include/mrdox PREFIX "include" FILES ${INCLUDES})
@@ -270,8 +238,27 @@ source_group(TREE ${PROJECT_SOURCE_DIR}/source PREFIX "source" FILES ${SOURCES})
270238
#-------------------------------------------------
271239

272240
if (MRDOX_BUILD_TESTS)
273-
# if we run tests, we need the addons in the right place.
241+
#-------------------------------------------------
242+
# Unit tests
243+
#-------------------------------------------------
244+
include(CTest)
245+
file(GLOB_RECURSE TEST_SUITE_FILES CONFIGURE_DEPENDS test/test_suite/*.cpp test/test_suite/*.hpp)
246+
file(GLOB_RECURSE UNIT_TEST_SOURCES CONFIGURE_DEPENDS test/unit/*.cpp test/unit/*.hpp)
247+
add_executable(mrdox-test ${TEST_SUITE_FILES} ${UNIT_TEST_SOURCES})
248+
target_include_directories(mrdox-test
249+
PRIVATE
250+
"${PROJECT_SOURCE_DIR}/include"
251+
"${PROJECT_SOURCE_DIR}/lib"
252+
"${PROJECT_SOURCE_DIR}/tool"
253+
"${PROJECT_SOURCE_DIR}/test/test_suite"
254+
)
255+
target_link_libraries(mrdox-test PUBLIC mrdox-core)
256+
if (MRDOX_CLANG)
257+
target_compile_options(mrdox-test PRIVATE -Wno-covered-switch-default)
258+
endif ()
259+
target_compile_definitions(mrdox-test PRIVATE -DMRDOX_UNIT_TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/unit")
274260
add_custom_command(
261+
# if we run tests, we need the addons in the right place.
275262
TARGET mrdox-test
276263
POST_BUILD
277264
COMMAND ${CMAKE_COMMAND} -E copy
@@ -280,25 +267,28 @@ if (MRDOX_BUILD_TESTS)
280267
BYPRODUCTS ${CMAKE_BINARY_DIR}/addons
281268
DEPENDS ${CMAKE_SOURCE_DIR}/addons
282269
)
270+
add_test(NAME mrdox-test COMMAND mrdox-test --action test "${PROJECT_SOURCE_DIR}/test-files/old-tests")
283271

284-
file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS source/*.cpp source/*.hpp)
285-
enable_testing()
286-
add_test(NAME mrdox-test COMMAND mrdox-test --action test
287-
"${PROJECT_SOURCE_DIR}/test-files/old-tests"
288-
)
289-
272+
#-------------------------------------------------
273+
# Reference documentation
274+
#-------------------------------------------------
290275
if (MRDOX_GENERATE_REFERENCE)
291276
# test run
277+
file(GLOB_RECURSE REFERENCE_SOURCES CONFIGURE_DEPENDS source/*.cpp source/*.hpp)
278+
292279
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
293280
include(mrdox.cmake)
294281

295-
mrdox(FORMAT adoc CONFIG docs/mrdox.yml SOURCES ${TEST_SOURCES})
296-
mrdox(FORMAT xml CONFIG docs/mrdox.yml SOURCES ${TEST_SOURCES})
282+
mrdox(FORMAT adoc CONFIG docs/mrdox.yml SOURCES ${REFERENCE_SOURCES})
283+
mrdox(FORMAT xml CONFIG docs/mrdox.yml SOURCES ${REFERENCE_SOURCES})
297284

298285
add_custom_target(reference_adoc ALL DEPENDS reference.adoc)
299286
add_custom_target(reference_xml ALL DEPENDS reference.xml)
300287
endif()
301288

289+
#-------------------------------------------------
290+
# XML lint
291+
#-------------------------------------------------
302292
find_package(LibXml2)
303293
if (LibXml2_FOUND)
304294
find_package(Java REQUIRED Runtime)
@@ -321,9 +311,6 @@ if (MRDOX_BUILD_TESTS)
321311
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
322312
endif()
323313

324-
add_executable(handlebars-test test/unit/handlebars.cpp)
325-
target_link_libraries(handlebars-test PUBLIC mrdox-core)
326-
target_compile_definitions(handlebars-test PRIVATE -DMRDOX_UNIT_TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/unit")
327314
endif()
328315

329316

include/mrdox/Platform.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ namespace mrdox {
7878
# endif
7979
#endif
8080

81-
#if ! defined(__GNUC__) && defined(_MSC_VER)
82-
#define FMT_CONSTEVAL
81+
#ifndef FMT_CONSTEVAL
82+
# if !defined(__GNUC__) && defined(_MSC_VER)
83+
# define FMT_CONSTEVAL
84+
# endif
8385
#endif
8486

8587
} // mrdox
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/test_suite/detail/decomposer.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) 2023 Alan de Freitas ([email protected])
3+
//
4+
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
// Official repository: https://github.com/boostorg/url
8+
//
9+
10+
#include "decomposer.hpp"
11+
12+
#if __has_include(<cxxabi.h>)
13+
#include <cxxabi.h>
14+
#endif
15+
16+
namespace test_suite {
17+
namespace detail {
18+
std::string demangle(const char *mangled)
19+
{
20+
#if __has_include(<cxxabi.h>)
21+
int status;
22+
char *demangled = abi::__cxa_demangle(mangled, nullptr, nullptr, &status);
23+
std::string result;
24+
if (status == 0) {
25+
result = demangled;
26+
} else {
27+
result = mangled;
28+
}
29+
std::free(demangled);
30+
return result;
31+
#else
32+
return mangled;
33+
#endif
34+
}
35+
} // detail
36+
} // test_suite

0 commit comments

Comments
 (0)