| 1 |
# @HEADER |
| 2 |
# ***************************************************************************** |
| 3 |
# TriBITS: Tribal Build, Integrate, and Test System |
| 4 |
# |
| 5 |
# Copyright 2013-2016 NTESS and the TriBITS contributors. |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# ***************************************************************************** |
| 8 |
# @HEADER |
| 9 |
|
| 10 |
# This script is a cmake -P script that should be called with the following |
| 11 |
# variables defined: |
| 12 |
# |
| 13 |
# -D binary_dir=${CMAKE_CURRENT_BINARY_DIR} |
| 14 |
# -D source_dir=${CMAKE_CURRENT_SOURCE_DIR} |
| 15 |
# -D ctest_type=${ctest_type} |
| 16 |
# -D scriptname=${scriptname} |
| 17 |
# -D TD_BASE_DIR=${TD_BASE_DIR} |
| 18 |
# -D testname=${testname} |
| 19 |
# |
| 20 |
# It looks recursively under ${TD_BASE_DIR}/tools/cmake-${ctest_type} |
| 21 |
# for a ctest executable and uses it to drive a ctest -S script to run |
| 22 |
# a dashboard for the project. It has to be run this way indirectly |
| 23 |
# through a cmake -P script because the desired ctest executable |
| 24 |
# location is unknown at CMake configure time of the driver project. |
| 25 |
|
| 26 |
if(WIN32) |
| 27 |
set(ctest_filename "ctest.exe") |
| 28 |
else() |
| 29 |
set(ctest_filename "ctest") |
| 30 |
endif() |
| 31 |
|
| 32 |
set(TRIBITS_TDD_USE_SYSTEM_CTEST $ENV{TRIBITS_TDD_USE_SYSTEM_CTEST}) |
| 33 |
message("TRIBITS_TDD_USE_SYSTEM_CTEST='${TRIBITS_TDD_USE_SYSTEM_CTEST}'") |
| 34 |
|
| 35 |
if (TRIBITS_TDD_USE_SYSTEM_CTEST STREQUAL "1") |
| 36 |
|
| 37 |
find_program(CTEST_EXE ${ctest_filename}) |
| 38 |
|
| 39 |
elseif(NOT CTEST_EXE) |
| 40 |
|
| 41 |
message("Selecting '${ctest_filename}' of type '${ctest_type}'...") |
| 42 |
|
| 43 |
set(CTEST_EXE |
| 44 |
"${TD_BASE_DIR}/tools/cmake-${ctest_type}/bin/${ctest_filename}") |
| 45 |
|
| 46 |
if(NOT CTEST_EXE) |
| 47 |
message(FATAL_ERROR "error: '${ctest_type}' ctest could not be found...") |
| 48 |
endif() |
| 49 |
|
| 50 |
endif() |
| 51 |
|
| 52 |
if(NOT EXISTS "${CTEST_EXE}") |
| 53 |
message(FATAL_ERROR "error: CTEST_EXE='${CTEST_EXE}' does not exist...") |
| 54 |
endif() |
| 55 |
|
| 56 |
message("CTEST_EXE='${CTEST_EXE}'") |
| 57 |
execute_process(COMMAND ${CTEST_EXE} --version) |
| 58 |
|
| 59 |
message("=========== variables ===========") |
| 60 |
message("binary_dir='${binary_dir}'") |
| 61 |
message("source_dir='${source_dir}'") |
| 62 |
message("ctest_type='${ctest_type}'") |
| 63 |
message("scriptname='${scriptname}'") |
| 64 |
message("TD_BASE_DIR='${TD_BASE_DIR}'") |
| 65 |
message("testname='${testname}'") |
| 66 |
message("=================================") |
| 67 |
|
| 68 |
message("========== environment ==========") |
| 69 |
execute_process(COMMAND ${CMAKE_COMMAND} -E environment) |
| 70 |
message("=================================") |
| 71 |
|
| 72 |
message("============ script =============") |
| 73 |
message("executing ctest -S '${scriptname}' for test '${testname}'...") |
| 74 |
|
| 75 |
execute_process(COMMAND ${CTEST_EXE} |
| 76 |
-S |
| 77 |
"${source_dir}/${scriptname}" |
| 78 |
-V |
| 79 |
--output-log |
| 80 |
"${binary_dir}/${testname}.log" |
| 81 |
RESULT_VARIABLE rv |
| 82 |
) |
| 83 |
|
| 84 |
if(NOT "${rv}" STREQUAL "0") |
| 85 |
message("warning: calling ctest -S script failed with '${rv}'") |
| 86 |
endif() |
| 87 |
|
| 88 |
message("=================================") |