Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions test/header/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ include (../seqan3-test.cmake)
CPMGetPackage (googletest)
CPMGetPackage (benchmark)

option (SEQAN3_FULL_HEADER_TEST "Test seqan3 headers as well as the headers of external libraries" OFF)

# We compile each header twice in separate compilation units, where the second compilation omits the header guard (check
# for cyclic includes). Each alone is sufficient to test that the header is functional, but both are needed to check for
# link errors, which can happen if the header accidentally defines a variable, e.g. a global or class static member.
Expand Down Expand Up @@ -133,15 +131,3 @@ endmacro ()
# note: seqan3/version.hpp is one of the only header that is not required to have a seqan3/core/platform.hpp include
seqan3_header_test (seqan3 "${SEQAN3_CLONE_DIR}/include" "seqan3/version.hpp|seqan3/contrib/std|seqan3/vendor")
seqan3_header_test (seqan3_test "${SEQAN3_CLONE_DIR}/test/include" "")

if (SEQAN3_FULL_HEADER_TEST)

# not self-contained headers; error: extra ‘;’ [-Werror=pedantic]
# seqan3_header_test (lemon "${SEQAN3_CLONE_DIR}/submodules/lemon/include" "")

# not complete self-contained headers
seqan3_header_test (cereal "${SEQAN3_CLONE_DIR}/submodules/cereal/include" "/external/|polymorphic_impl\.hpp")

seqan3_header_test (sdsl-lite "${SEQAN3_CLONE_DIR}/submodules/sdsl-lite/include" "")

endif ()
34 changes: 20 additions & 14 deletions test/header/generate_header_source.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,59 @@ option (HEADER_SUB_TEST "")

file (WRITE "${HEADER_TARGET_SOURCE}" "") # write empty file

# cmake-format: off

if (HEADER_SUB_TEST STREQUAL "no-self-include")
# this test ensures that a header will not be included by itself later
file (READ "${HEADER_FILE_ABSOLUTE}" header_content)

string (REPLACE "#pragma once" "" header_content "${header_content}")

file (APPEND "${HEADER_TARGET_SOURCE}" "${header_content}\n")
file (APPEND "${HEADER_TARGET_SOURCE}"
"// seqan3-header-test-no-self-include-start\n"
"${header_content}\n"
"// seqan3-header-test-no-self-include-end\n\n")
else ()
# this test ensures that a header guard is in place
file (APPEND "${HEADER_TARGET_SOURCE}" #
"// seqan3-header-test-header-guard-start\n"
"#include <${HEADER_FILE_INCLUDE}>\n" #
"#include <${HEADER_FILE_INCLUDE}>\n")
"#include <${HEADER_FILE_INCLUDE}>\n"
"// seqan3-header-test-header-guard-end\n\n")
endif ()

# these includes are required by some headers (note that they follow)
file (APPEND "${HEADER_TARGET_SOURCE}" #
"// seqan3-header-test-dependencies-start\n"
"#include <gtest/gtest.h>\n" #
"#include <benchmark/benchmark.h>\n" #
"TEST(${HEADER_TEST_NAME_SAFE}) {}\n")
"TEST(${HEADER_TEST_NAME_SAFE}) {}\n"
"// seqan3-header-test-dependencies-end\n\n")

# test that seqan3 headers include platform.hpp
if ("${HEADER_COMPONENT}" MATCHES "seqan3")

# exclude seqan3/std/* and seqan3/contrib/* from platform test
if (NOT HEADER_FILE_INCLUDE MATCHES "seqan3/(std|contrib)/")
file (APPEND "${HEADER_TARGET_SOURCE}" #
"// seqan3-header-test-platform-start\n"
"#ifndef SEQAN3_DOXYGEN_ONLY\n" #
"#error \"Your header '${HEADER_FILE_INCLUDE}' file is missing #include <seqan3/core/platform.hpp>\"\n" #
"#endif\n")
"#endif\n"
"// seqan3-header-test-platform-end\n\n")
endif ()

# seqan3/std/* must not include platform.hpp (and therefore any other seqan3 header)
# See https://github.com/seqan/product_backlog/issues/135
if (HEADER_FILE_INCLUDE MATCHES "seqan3/std/")
file (APPEND "${HEADER_TARGET_SOURCE}" #
"// seqan3-header-test-no-platform-start\n"
"#ifdef SEQAN3_DOXYGEN_ONLY" #
"#error \"The standard header '${HEADER_FILE_INCLUDE}' file MUST NOT include any other " #
"seqan3 header (except for seqan3/contrib)\"\n" #
"#endif\n")
"#endif\n"
"// seqan3-header-test-no-platform-end\n\n")
endif ()

# test whether seqan3 has the visibility bug on lower gcc versions
# https://github.com/seqan/seqan3/issues/1317
file (APPEND "${HEADER_TARGET_SOURCE}" #
"#include <seqan3/core/platform.hpp>\n\n" #
"class A{ int i{5}; };\n\n" #
"template <typename t>\n" #
"concept private_bug = requires(t a){a.i;};\n\n" #
"static_assert(!private_bug<A>, \"See https://github.com/seqan/seqan3/issues/1317\");\n")
endif ()

# cmake-format: on
Loading