|
| 1 | +################################################################################ |
| 2 | +# Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # |
| 3 | +# # |
| 4 | +# This software is distributed under the terms of the # |
| 5 | +# GNU Lesser General Public Licence (LGPL) version 3, # |
| 6 | +# copied verbatim in the file "LICENSE" # |
| 7 | +################################################################################ |
| 8 | + |
| 9 | +list(PREPEND CMAKE_MODULE_PATH "cmake/private") |
| 10 | +include(Testlib) |
| 11 | + |
| 12 | +fairroot_ctest_setup() |
| 13 | + |
| 14 | +set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 102400) |
| 15 | +set(CTEST_CONFIGURATION_TYPE "RelWithDebInfo") |
| 16 | + |
| 17 | +get_NCPUS() |
| 18 | +get_os_name_release() |
| 19 | + |
| 20 | +if ("$ENV{LABEL}" STREQUAL "") |
| 21 | + set(CTEST_BUILD_NAME "build") |
| 22 | +else() |
| 23 | + set(CTEST_BUILD_NAME $ENV{LABEL}) |
| 24 | +endif() |
| 25 | + |
| 26 | +find_program(GCOV_COMMAND gcov) |
| 27 | +if(GCOV_COMMAND) |
| 28 | + message("Found GCOV: ${GCOV_COMMAND}") |
| 29 | + set(CTEST_COVERAGE_COMMAND ${GCOV_COMMAND}) |
| 30 | +endif(GCOV_COMMAND) |
| 31 | + |
| 32 | +show_jenkins_info() |
| 33 | + |
| 34 | +ctest_read_custom_files(${CTEST_SOURCE_DIRECTORY}) |
| 35 | + |
| 36 | +ctest_start(Continuous) |
| 37 | + |
| 38 | +get_filename_component(test_install_prefix "${CTEST_BINARY_DIRECTORY}/install" |
| 39 | + ABSOLUTE) |
| 40 | +list(APPEND options |
| 41 | + "-Werror=dev" |
| 42 | + "-DDISABLE_COLOR=ON" |
| 43 | + "-DCMAKE_BUILD_TYPE=PROFILE" |
| 44 | + "-DBUILD_EXAMPLES=OFF" |
| 45 | + "-DCMAKE_INSTALL_PREFIX:PATH=${test_install_prefix}" |
| 46 | +) |
| 47 | +if ((NOT DEFINED BUILD_MBS) OR BUILD_MBS) |
| 48 | + list(APPEND options "-DBUILD_MBS=ON") |
| 49 | +endif() |
| 50 | +if ((NOT DEFINED BUILD_PROOF_SUPPORT) OR BUILD_PROOF_SUPPORT) |
| 51 | + list(APPEND options "-DBUILD_PROOF_SUPPORT=ON") |
| 52 | +endif() |
| 53 | +if ((NOT DEFINED BUILD_EVENT_BUILDER) OR BUILD_EVENT_BUILDER) |
| 54 | + list(APPEND options "-DBUILD_EVENT_BUILDER=ON") |
| 55 | +endif() |
| 56 | +if (USE_CLANG_TIDY) |
| 57 | + list(APPEND options "-DCMAKE_CXX_CLANG_TIDY=clang-tidy") |
| 58 | +endif() |
| 59 | +if (ENABLE_GEANT3_TESTING) |
| 60 | + list(APPEND options "-DENABLE_GEANT3_TESTING=ON") |
| 61 | +endif() |
| 62 | +ctest_configure(OPTIONS "${options}") |
| 63 | + |
| 64 | +ctest_build(FLAGS "-j${NCPUS}" TARGET install |
| 65 | + NUMBER_ERRORS _ctest_build_num_errs |
| 66 | + RETURN_VALUE _ctest_build_ret_val) |
| 67 | + |
| 68 | +unset(repeat) |
| 69 | +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) |
| 70 | + if ("$ENV{CHANGE_ID}" STREQUAL "") |
| 71 | + # Branch build |
| 72 | + set(repeat REPEAT UNTIL_PASS:7) |
| 73 | + endif() |
| 74 | +endif() |
| 75 | +if(_ctest_build_ret_val OR _ctest_build_num_errs) |
| 76 | + message(STATUS "Skipping tests, because build failed" |
| 77 | + " (return value: ${_ctest_build_ret_val}," |
| 78 | + " number of errors: ${_ctest_build_num_errs})") |
| 79 | + set(_ctest_test_ret_val -1) |
| 80 | +else() |
| 81 | + ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" |
| 82 | + PARALLEL_LEVEL 4 |
| 83 | + SCHEDULE_RANDOM ON |
| 84 | + ${repeat} |
| 85 | + RETURN_VALUE _ctest_test_ret_val) |
| 86 | +endif() |
| 87 | + |
| 88 | + If(GCOV_COMMAND) |
| 89 | + ctest_coverage(BUILD "${CTEST_BINARY_DIRECTORY}") |
| 90 | + EndIf() |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +fairroot_ctest_submit(FINAL) |
| 95 | +fairroot_summary_cdash() |
| 96 | + |
| 97 | +if(_ctest_test_ret_val) |
| 98 | + Message(FATAL_ERROR "Some tests failed.") |
| 99 | +endif() |
0 commit comments