From 42b0be7f3a1b56032dc03e471aae90bbd89969db Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 20 Jul 2020 20:59:49 -0400 Subject: [PATCH] Run PoC tests even without doctest #811 Add back the USE_DOCTEST CMake option, but make it conditional upon BUILD_TESTING. If BUILD_TESTING is provided without USE_DOCTEST, we build and run the PoC tests, just not notcurses-tester. If neither is defined, no tests are available (the PoC binaries are still built). If both are defined, build the PoCs plus notcurses-tester, and run them all in make test. --- CMakeLists.txt | 42 ++++++++++++++++++++++++------------------ README.md | 7 ++++--- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7c91e901..d8b0ca140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,12 +9,18 @@ set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_VISIBILITY_PRESET hidden) +include(CTest) include(GNUInstallDirs) +include(CMakeDependentOption) ###################### USER-SELECTABLE OPTIONS ########################### # BUILD_TESTING is defined by CTest option(DFSG_BUILD "DFSG build (no non-free media/code)" OFF) option(USE_COVERAGE "Assess code coverage with llvm-cov/lcov" OFF) +cmake_dependent_option( + USE_DOCTEST "Build notcurses-tester with doctest" ON + "${BUILD_TESTING}" OFF +) option(USE_DOXYGEN "Build HTML cross reference with doxygen" OFF) option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON) option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON) @@ -60,6 +66,7 @@ message(STATUS "Requested build mode: ${CMAKE_BUILD_TYPE}") find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) +find_package(doctest REQUIRED) # some distros (motherfucking alpine subsume terminfo directly # into ncurses. accept either, and may god have mercy on our souls. pkg_search_module(TERMINFO REQUIRED tinfo>=6.1 ncursesw>=6.1) @@ -81,7 +88,7 @@ if(NOT "${HAVE_QRCODEGEN_H}") endif() endif() find_library(LIBRT rt) -if(${BUILD_TESTING}) +if(${USE_DOCTEST}) find_package(doctest 2.3.5 REQUIRED) endif() @@ -522,21 +529,7 @@ target_link_libraries(notcurses-view endif() # Testing -include(CTest) if(${BUILD_TESTING}) -file(GLOB TESTSRCS CONFIGURE_DEPENDS tests/*.cpp) -add_executable(notcurses-tester ${TESTSRCS}) -target_include_directories(notcurses-tester - PRIVATE - include - "${PROJECT_BINARY_DIR}/include" - src/lib -) -target_link_libraries(notcurses-tester - PRIVATE - notcurses++ - "${TERMINFO_LIBRARIES}" -) # sadly, this doesn't take effect until CMake 3.17... set(CMAKE_CTEST_ARGUMENTS "-V") enable_testing() @@ -564,10 +557,26 @@ add_test( NAME rgbbg COMMAND rgbbg ) +if(${USE_DOCTEST}) +file(GLOB TESTSRCS CONFIGURE_DEPENDS tests/*.cpp) +add_executable(notcurses-tester ${TESTSRCS}) +target_include_directories(notcurses-tester + PRIVATE + include + "${PROJECT_BINARY_DIR}/include" + src/lib +) +target_link_libraries(notcurses-tester + PRIVATE + notcurses++ + "${TERMINFO_LIBRARIES}" +) add_test( NAME notcurses-tester COMMAND notcurses-tester -p ${CMAKE_CURRENT_SOURCE_DIR}/data ) +install(TARGETS notcurses-tester DESTINATION bin) +endif() endif() # pkg-config support @@ -627,9 +636,6 @@ install(TARGETS notcurses-demo DESTINATION bin) install(TARGETS notcurses-input DESTINATION bin) install(TARGETS notcurses-ncreel DESTINATION bin) install(TARGETS ncneofetch DESTINATION bin) -if(${BUILD_TESTING}) -install(TARGETS notcurses-tester DESTINATION bin) -endif() install(TARGETS notcurses-tetris DESTINATION bin) if(${USE_FFMPEG} OR ${USE_OIIO}) install(TARGETS notcurses-view DESTINATION bin) diff --git a/README.md b/README.md index 33deae0e6..4399bd3a9 100644 --- a/README.md +++ b/README.md @@ -156,10 +156,11 @@ To set the C compiler, export `CC`. To set the C++ compiler, export `CXX`. The `CMAKE_BUILD_TYPE` CMake variable can be defined to any of its standard values, but must be `Debug` for use of `USE_COVERAGE`. -* `BUILD_TESTING`: build `notcurses-tester` using doctest * `DFSG_BUILD`: leave out all content considered non-free under the Debian Free - Software Guidelines. -* `USE_MULTIMEDIA`: `ffmpeg` for FFmpeg, `oiio` for OpenImageIO, `none` for none. + Software Guidelines +* `BUILD_TESTING`: build test targets +* `USE_DOCTEST`: build `notcurses-tester` with Doctest, requires `BUILD_TESTING` +* `USE_MULTIMEDIA`: `ffmpeg` for FFmpeg, `oiio` for OpenImageIO, `none` for none * `USE_QRCODEGEN`: build qrcode support via libqrcodegen * `USE_PANDOC`: build man pages with pandoc * `USE_DOXYGEN`: build interlinked HTML documentation with Doxygen