Add self-parsing integration test

This commit is contained in:
Jonathan Müller 2017-08-13 10:41:29 +02:00
commit bd4db2ce80
4 changed files with 25 additions and 1 deletions

View file

@ -21,6 +21,7 @@ option(BUILD_TESTING "build test" OFF) # The ctest variable for building tests
if(${CPPAST_BUILD_TEST} OR ${BUILD_TESTING} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
set(build_test ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for the self integration test
else()
set(build_test OFF)
endif()

View file

@ -15,7 +15,6 @@ set(header
../include/cppast/cpp_class_template.hpp
../include/cppast/cpp_decltype_type.hpp
../include/cppast/cpp_entity.hpp
../include/cppast/cpp_entity.hpp
../include/cppast/cpp_entity_container.hpp
../include/cppast/cpp_entity_index.hpp
../include/cppast/cpp_entity_kind.hpp

View file

@ -34,10 +34,18 @@ set(tests
preprocessor.cpp
visitor.cpp)
# generate list of source files for the self parsing test
get_target_property(files cppast SOURCES)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cppast_files.hpp "// list of cppast source file includes\n")
foreach(file ${files})
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cppast_files.hpp "\"${CMAKE_CURRENT_SOURCE_DIR}/../src/${file}\",\n")
endforeach()
add_executable(cppast_test test.cpp test_parser.hpp ${tests})
target_include_directories(cppast_test PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(cppast_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src)
target_link_libraries(cppast_test PUBLIC cppast)
target_compile_definitions(cppast_test PUBLIC CPPAST_INTEGRATION_FILE="${CMAKE_CURRENT_SOURCE_DIR}/integration.cpp")
set_target_properties(cppast_test PROPERTIES CXX_STANDARD 11)
enable_testing()

View file

@ -113,3 +113,19 @@ TEST_CASE("stdlib", "[!hide][integration]")
resolve_includes(parser, file.value(), config);
REQUIRE(!parser.error());
}
TEST_CASE("cppast", "[!hide][integration]")
{
const char* files[] = {
#include <cppast_files.hpp>
};
cpp_entity_index idx;
simple_file_parser<libclang_parser> parser(type_safe::ref(idx), default_logger());
libclang_compilation_database database("../");
libclang_compile_config config(database, CPPAST_INTEGRATION_FILE);
parse_files(parser, files, config);
REQUIRE(!parser.error());
}