NEW: add unit-test facilities (incl. running them on AppVeyor)

This commit is contained in:
jkriege2 2024-01-21 21:58:56 +01:00
parent ff08ffe27b
commit 31759543da
5 changed files with 56 additions and 2 deletions

View File

@ -71,5 +71,9 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
add_subdirectory(doc)
if (JKQtPlotter_BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()

View File

@ -163,6 +163,15 @@ for:
- cmd: if %USE_CMAKE%==true cmake --build . --config "%CONFIGURATION%" -j%NUMBER_OF_PROCESSORS% -- %CMAKE_BUILDFLAGS%
- cmd: cd ..
test_script:
- cmd: if %USE_CMAKE%==true echo == RUNNING UNIT TESTS FOR JKQtPlotter CMAKE BUILD ===============================================
- cmd: cd %APPVEYOR_BUILD_FOLDER%
- cmd: cd build
- cmd: if %USE_CMAKE%==true ctest -C --config "%CONFIGURATION%" --output-on-failure --output-junit test-results.xml
after_test:
- find "$APPVEYOR_BUILD_FOLDER" -type f -name 'test-results.xml' -print0 | xargs -0 -I '{}' curl -F 'file=@{}' "https://ci.appveyor.com/api/testresults/junit/$APPVEYOR_JOB_ID"
# Linux (Ubuntu2004)
-
@ -265,11 +274,22 @@ for:
cd examples/cmake_link_example
mkdir build
cd build
cmake -G "%CMAKE_GENERATOR%" "-DCMAKE_PREFIX_PATH=%QTDIR%;%CIMG_INCLUDE_DIR%;$APPVEYOR_BUILD_FOLDER\install" ..
cmake --build . --config "%CONFIGURATION%" -j%NUMBER_OF_PROCESSORS% -- %CMAKE_BUILDFLAGS%
cmake -G "$CONFIGURATION" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR;$APPVEYOR_BUILD_FOLDER\install" ..
cmake --build . --config "$CONFIGURATION" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
cd ..
fi
test_script:
- sh: |
if [ "$USE_CMAKE" = true ] && [ "$TEST_FETCHCONTENT" = false ]; then
echo == RUNNING UNIT TESTS FOR JKQtPlotter CMAKE BUILD ===============================================
cd $APPVEYOR_BUILD_FOLDER
cd build
ctest -C --config "$CONFIGURATION" --output-on-failure --output-junit test-results.xml
fi
after_test:
- find "$APPVEYOR_BUILD_FOLDER" -type f -name 'test-results.xml' -print0 | xargs -0 -I '{}' curl -F 'file=@{}' "https://ci.appveyor.com/api/testresults/junit/$APPVEYOR_JOB_ID"
# MacOS (Monterey)
@ -306,3 +326,10 @@ for:
- sh: cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR" ..
- sh: echo --- Build using CMake -------------------------------------------------------------------------------
- sh: cmake --build . --config "$CONFIGURATION" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
artifacts:
- path: 'build/CMakeFiles/*.log'
name: logs
- path: 'build/Testing/**/*.xml'
name: test_results

View File

@ -28,6 +28,9 @@ endif()
if(NOT DEFINED JKQtPlotter_BUILD_TOOLS)
option(JKQtPlotter_BUILD_TOOLS "Build the tools" ON)
endif()
if(NOT DEFINED JKQtPlotter_BUILD_TESTS)
option(JKQtPlotter_BUILD_TESTS "Build the unit tests" ON)
endif()
if(NOT DEFINED JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT)
option(JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT "Build the library with printer support switched off, even if it is available" OFF)
endif()

View File

@ -62,6 +62,7 @@ The CMake build system offers several configuration variables that you may set/c
- \c JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT : If enabled (\c ON ), additional tiing code is activated (and built into the library), which outputs timming information for several functions of the library into \c qDebug() . This is intended for development putposes only, NOT for productive builds! (default: \c OFF )
- \c JKQtPlotter_BUILD_EXAMPLES : Build examples (default: \c ON )
- \c JKQtPlotter_BUILD_TOOLS : Build tools (default: \c ON )
- \c JKQtPlotter_BUILD_TESTS : Build unit-tests (default: \c ON )
- \c JKQtPlotter_BUILD_LIB_JKQTMATH : Build sub-library JKQTMath (default: \c ON )
- \c JKQtPlotter_BUILD_LIB_JKQTMATHTEXT : Build sub-library JKQTMathText (default: \c ON )
- DEPRECATED: \c JKQtPlotter_BUILD_LIB_JKQTFASTPLOTTER : Build sub-library JKQTFastPlotter (default: \c ON ) ... Note: This option may change to default=OFF in future ... and may be removed thereafter!

19
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.23)
message( STATUS )
message( STATUS "............................................................................." )
message( STATUS ".. BUILDING UNIT TESTS" )
message( STATUS "............................................................................." )
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
message( STATUS ".. - Precompiled Header: ON" )
else()
message( STATUS ".. - Precompiled Header: OFF")
endif()
message( STATUS "............................................................................." )
enable_testing()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Test REQUIRED)
message( STATUS ".. BUILDING UNIT TESTS FOR JKQTCommon:" )
add_subdirectory(jkqtcommmon)