Skip to content

test: integrate handlebars and boost.url test suite #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 37 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ include(GNUInstallDirs)

option(MRDOX_BUILD_TESTS "Build tests" ${BUILD_TESTING})
option(MRDOX_BUILD_SHARED "Link shared" OFF)
option(MRDOX_BUILD_DOCS "Configure install target" OFF)
option(MRDOX_BUILD_DOCS "Build documentation" OFF)
option(MRDOX_INSTALL "Configure install target" ON)
option(MRDOX_PACKAGE "Build install package" ON)
option(MRDOX_GENERATE_REFERENCE "Generate reference.xml/reference.adoc" ON)
@@ -115,9 +115,9 @@ find_package(fmt REQUIRED CONFIG)

file(
GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS
lib/*.cpp
lib/*.hpp
lib/*.natvis
src/lib/*.cpp
src/lib/*.hpp
src/lib/*.natvis
include/*.hpp
include/*.natvis
SourceFileNames.cpp)
@@ -128,7 +128,7 @@ target_include_directories(mrdox-core
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${PROJECT_SOURCE_DIR}/lib"
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include")
target_compile_definitions(
mrdox-core
@@ -202,17 +202,17 @@ endif ()
#
#-------------------------------------------------

file(GLOB_RECURSE TOOL_SOURCES CONFIGURE_DEPENDS tool/*.cpp tool/*.hpp)
file(GLOB_RECURSE TOOL_SOURCES CONFIGURE_DEPENDS src/tool/*.cpp src/tool/*.hpp)
add_executable(mrdox ${TOOL_SOURCES})
target_compile_definitions(mrdox PRIVATE -DMRDOX_TOOL)

target_include_directories(mrdox
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/lib"
"${PROJECT_SOURCE_DIR}/tool"
"${PROJECT_SOURCE_DIR}/src"
)

target_compile_definitions(mrdox PRIVATE -DMRDOX_TOOL)
@@ -225,39 +225,6 @@ if (MRDOX_CLANG)
)
endif ()


#-------------------------------------------------
#
# Tests
#
#-------------------------------------------------

file(GLOB TEST_SOURCES CONFIGURE_DEPENDS
test/*.cpp
test/*.hpp)
add_executable(mrdox-test ${TEST_SOURCES})

target_include_directories(mrdox-test
PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/lib"
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/tool"
)

target_compile_definitions(mrdox PRIVATE -DMRDOX_TOOL)
target_link_libraries(mrdox-test PUBLIC mrdox-core)

if (MRDOX_CLANG)
target_compile_options(
mrdox-test
PRIVATE
-Wno-covered-switch-default
)
endif ()

#-------------------------------------------------------------------------------

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#source_group(TREE ${PROJECT_SOURCE_DIR} PREFIX "" FILES CMakeLists.txt)
source_group(TREE ${PROJECT_SOURCE_DIR}/include/mrdox PREFIX "include" FILES ${INCLUDES})
@@ -270,8 +237,25 @@ source_group(TREE ${PROJECT_SOURCE_DIR}/source PREFIX "source" FILES ${SOURCES})
#-------------------------------------------------

if (MRDOX_BUILD_TESTS)
# if we run tests, we need the addons in the right place.
#-------------------------------------------------
# Unit tests
#-------------------------------------------------
include(CTest)
file(GLOB_RECURSE TEST_SUITE_FILES CONFIGURE_DEPENDS src/test/test_suite/*.cpp src/test/test_suite/*.hpp)
file(GLOB_RECURSE UNIT_TEST_SOURCES CONFIGURE_DEPENDS src/test/unit/*.cpp src/test/unit/*.hpp)
add_executable(mrdox-test ${TEST_SUITE_FILES} ${UNIT_TEST_SOURCES})
target_include_directories(mrdox-test
PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/src"
)
target_link_libraries(mrdox-test PUBLIC mrdox-core)
if (MRDOX_CLANG)
target_compile_options(mrdox-test PRIVATE -Wno-covered-switch-default)
endif ()
target_compile_definitions(mrdox-test PRIVATE -DMRDOX_TEST_FILES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test-files")
add_custom_command(
# if we run tests, we need the addons in the right place.
TARGET mrdox-test
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
@@ -280,25 +264,28 @@ if (MRDOX_BUILD_TESTS)
BYPRODUCTS ${CMAKE_BINARY_DIR}/addons
DEPENDS ${CMAKE_SOURCE_DIR}/addons
)
add_test(NAME mrdox-test COMMAND mrdox-test --action test "${PROJECT_SOURCE_DIR}/test-files/old-tests")

file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS source/*.cpp source/*.hpp)
enable_testing()
add_test(NAME mrdox-test COMMAND mrdox-test --action test
"${PROJECT_SOURCE_DIR}/test-files/old-tests"
)

#-------------------------------------------------
# Reference documentation
#-------------------------------------------------
if (MRDOX_GENERATE_REFERENCE)
# test run
file(GLOB_RECURSE REFERENCE_SOURCES CONFIGURE_DEPENDS source/*.cpp source/*.hpp)

set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
include(mrdox.cmake)

mrdox(FORMAT adoc CONFIG docs/mrdox.yml SOURCES ${TEST_SOURCES})
mrdox(FORMAT xml CONFIG docs/mrdox.yml SOURCES ${TEST_SOURCES})
mrdox(FORMAT adoc CONFIG docs/mrdox.yml SOURCES ${REFERENCE_SOURCES})
mrdox(FORMAT xml CONFIG docs/mrdox.yml SOURCES ${REFERENCE_SOURCES})

add_custom_target(reference_adoc ALL DEPENDS reference.adoc)
add_custom_target(reference_xml ALL DEPENDS reference.xml)
endif()

#-------------------------------------------------
# XML lint
#-------------------------------------------------
find_package(LibXml2)
if (LibXml2_FOUND)
find_package(Java REQUIRED Runtime)
@@ -321,9 +308,6 @@ if (MRDOX_BUILD_TESTS)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()

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


6 changes: 4 additions & 2 deletions include/mrdox/Platform.hpp
Original file line number Diff line number Diff line change
@@ -78,8 +78,10 @@ namespace mrdox {
# endif
#endif

#if ! defined(__GNUC__) && defined(_MSC_VER)
#define FMT_CONSTEVAL
#ifndef FMT_CONSTEVAL
# if !defined(__GNUC__) && defined(_MSC_VER)
# define FMT_CONSTEVAL
# endif
#endif

} // mrdox
33 changes: 15 additions & 18 deletions include/mrdox/Support/Handlebars.hpp
Original file line number Diff line number Diff line change
@@ -1191,36 +1191,33 @@ isEmpty(dom::Value const& arg);
execution. For example, the each iterator creates a single
frame which is reused for all child execution.

@param arg The value to test
@return True if the value is empty, false otherwise
@param parent The underlying frame object
@return The overlay object

@see https://mustache.github.io/mustache.5.html#Sections
*/
MRDOX_DECL
dom::Object
createFrame(dom::Object const& parent);

/** Create child data objects.
/** Create a wrapper for a safe string.

This function can be used by block helpers to create child
data objects.

The child data object is an overlay frame object implementation
that will first look for a value in the child object and if
not found will look in the parent object.
This string wrapper prevents the string from being escaped
when the template is rendered.

Helpers that modify the data state should create a new frame
object when doing so, to isolate themselves and avoid corrupting
the state of any parents.
When a helper returns a safe string, it will be marked
as safe and will not be escaped when rendered. The
string will be rendered as if converted to a `dom::Value`
and rendered as-is.

Generally, only one frame needs to be created per helper
execution. For example, the each iterator creates a single
frame which is reused for all child execution.
When constructing the string that will be marked as safe, any
external content should be properly escaped using the
`escapeExpression` function to avoid potential security concerns.

@param arg The value to test
@return True if the value is empty, false otherwise
@param str The string to mark as safe
@return The safe string wrapper

@see https://mustache.github.io/mustache.5.html#Sections
@see https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string
*/
MRDOX_DECL
detail::safeStringWrapper
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/-XML/CXXTags.hpp → src/lib/-XML/CXXTags.hpp
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_XML_CXXTAGS_HPP
#define MRDOX_TOOL_XML_CXXTAGS_HPP
#ifndef MRDOX_LIB_XML_CXXTAGS_HPP
#define MRDOX_LIB_XML_CXXTAGS_HPP

#include "XMLTags.hpp"
#include <mrdox/Metadata/Function.hpp>
4 changes: 2 additions & 2 deletions lib/-XML/XMLGenerator.cpp → src/lib/-XML/XMLGenerator.cpp
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@

#include "XMLGenerator.hpp"
#include "XMLWriter.hpp"
#include "Support/Radix.hpp"
#include "Support/RawOstream.hpp"
#include "lib/Support/Radix.hpp"
#include "lib/Support/RawOstream.hpp"
#include <mrdox/Support/Error.hpp>
#include <mrdox/Metadata.hpp>

4 changes: 2 additions & 2 deletions lib/-XML/XMLGenerator.hpp → src/lib/-XML/XMLGenerator.hpp
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_XML_XMLGENERATOR_HPP
#define MRDOX_TOOL_XML_XMLGENERATOR_HPP
#ifndef MRDOX_LIB_XML_XMLGENERATOR_HPP
#define MRDOX_LIB_XML_XMLGENERATOR_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Generator.hpp>
2 changes: 1 addition & 1 deletion lib/-XML/XMLTags.cpp → src/lib/-XML/XMLTags.cpp
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
//

#include "XMLTags.hpp"
#include "Support/Radix.hpp"
#include "lib/Support/Radix.hpp"
#include <mrdox/Platform.hpp>

namespace clang {
4 changes: 2 additions & 2 deletions lib/-XML/XMLTags.hpp → src/lib/-XML/XMLTags.hpp
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_XML_XMLTAGS_HPP
#define MRDOX_TOOL_XML_XMLTAGS_HPP
#ifndef MRDOX_LIB_XML_XMLTAGS_HPP
#define MRDOX_LIB_XML_XMLTAGS_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/Javadoc.hpp>
8 changes: 4 additions & 4 deletions lib/-XML/XMLWriter.cpp → src/lib/-XML/XMLWriter.cpp
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@

#include "CXXTags.hpp"
#include "XMLWriter.hpp"
#include "Lib/ConfigImpl.hpp"
#include "Support/Yaml.hpp"
#include "Support/Radix.hpp"
#include "Support/SafeNames.hpp"
#include "lib/Lib/ConfigImpl.hpp"
#include "lib/Support/Yaml.hpp"
#include "lib/Support/Radix.hpp"
#include "lib/Support/SafeNames.hpp"
#include <mrdox/Platform.hpp>
#include <llvm/Support/YAMLParser.h>
#include <llvm/Support/YAMLTraits.h>
6 changes: 3 additions & 3 deletions lib/-XML/XMLWriter.hpp → src/lib/-XML/XMLWriter.hpp
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_XML_XMLWRITER_HPP
#define MRDOX_TOOL_XML_XMLWRITER_HPP
#ifndef MRDOX_LIB_XML_XMLWRITER_HPP
#define MRDOX_LIB_XML_XMLWRITER_HPP

#include "XMLTags.hpp"
#include "Support/YamlFwd.hpp"
#include "lib/Support/YamlFwd.hpp"
#include <mrdox/Corpus.hpp>
#include <mrdox/Metadata.hpp>
#include <mrdox/Support/Error.hpp>
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/-adoc/AdocCorpus.hpp → src/lib/-adoc/AdocCorpus.hpp
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_ADOC_ADOCCORPUS_HPP
#define MRDOX_TOOL_ADOC_ADOCCORPUS_HPP
#ifndef MRDOX_LIB_ADOC_ADOCCORPUS_HPP
#define MRDOX_LIB_ADOC_ADOCCORPUS_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/DomMetadata.hpp>
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
#include "Builder.hpp"
#include "MultiPageVisitor.hpp"
#include "SinglePageVisitor.hpp"
#include "Support/SafeNames.hpp"
#include "lib/Support/SafeNames.hpp"
#include <mrdox/Metadata/DomMetadata.hpp>
#include <mrdox/Support/Error.hpp>
#include <mrdox/Support/Path.hpp>
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_ADOC_ADOCGENERATOR_HPP
#define MRDOX_TOOL_ADOC_ADOCGENERATOR_HPP
#ifndef MRDOX_LIB_ADOC_ADOCGENERATOR_HPP
#define MRDOX_LIB_ADOC_ADOCGENERATOR_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Generator.hpp>
2 changes: 1 addition & 1 deletion lib/-adoc/Builder.cpp → src/lib/-adoc/Builder.cpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
//

#include "Builder.hpp"
#include "Support/Radix.hpp"
#include "lib/Support/Radix.hpp"
#include <mrdox/Metadata/DomMetadata.hpp>
#include <mrdox/Support/Path.hpp>
#include <llvm/Support/FileSystem.h>
2 changes: 1 addition & 1 deletion lib/-adoc/Builder.hpp → src/lib/-adoc/Builder.hpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
#define MRDOX_LIB_ADOC_BUILDER_HPP

#include "Options.hpp"
#include "Support/Radix.hpp"
#include "lib/Support/Radix.hpp"
#include <mrdox/Metadata/DomMetadata.hpp>
#include <mrdox/Support/Error.hpp>
#include <mrdox/Support/JavaScript.hpp>
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/-adoc/Options.cpp → src/lib/-adoc/Options.cpp
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@
//

#include "Options.hpp"
#include "Support/Yaml.hpp"
#include "Lib/ConfigImpl.hpp" // VFALCO This is a problem
#include "lib/Support/Yaml.hpp"
#include "lib/Lib/ConfigImpl.hpp" // VFALCO This is a problem
#include <mrdox/Corpus.hpp>
#include <mrdox/Support/Path.hpp>
#include <llvm/Support/YAMLParser.h>
4 changes: 2 additions & 2 deletions lib/-adoc/Options.hpp → src/lib/-adoc/Options.hpp
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
// Official repository: https://github.com/cppalliance/mrdox
//

#ifndef MRDOX_TOOL_ADOC_OPTIONS_HPP
#define MRDOX_TOOL_ADOC_OPTIONS_HPP
#ifndef MRDOX_LIB_ADOC_OPTIONS_HPP
#define MRDOX_LIB_ADOC_OPTIONS_HPP

#include <mrdox/Support/Error.hpp>
#include <string>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@
//

#include "BitcodeGenerator.hpp"
#include "Support/Error.hpp"
#include "Support/SafeNames.hpp"
#include "AST/Bitcode.hpp"
#include "lib/Support/Error.hpp"
#include "lib/Support/SafeNames.hpp"
#include "lib/AST/Bitcode.hpp"
#include <mrdox/Support/ThreadPool.hpp>
#include <mrdox/Metadata.hpp>

Loading