From e1a081a2c49b3ca541fb59c97230f60649bcbbd5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 7 Jun 2021 15:09:42 +0800 Subject: [PATCH] cmake: do not print warning in each cmake run cmake prints the warning of > run-promtool-unittests is skipped due to missing promtool everytime if the test is skipped per the test. but we only need to get this message the first time cmake is executed. more importantly, the value of `PROMTOOL_EXECUTABLE` is cached. so the new error message does not provide updated information, so just stop doing so if the cached variable is found. Signed-off-by: Kefu Chai --- src/test/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 0d64ae7f7621b..28d1f7849de3c 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -606,6 +606,10 @@ add_ceph_test(run-cli-tests ${CMAKE_CURRENT_SOURCE_DIR}/run-cli-tests) add_ceph_test(smoke.sh ${CMAKE_CURRENT_SOURCE_DIR}/smoke.sh) +if(DEFINED PROMTOOL_EXECUTABLE) + set(promtool_executable_checked TRUE) +endif() + find_program(PROMTOOL_EXECUTABLE promtool) if(PROMTOOL_EXECUTABLE) execute_process( @@ -615,11 +619,11 @@ if(PROMTOOL_EXECUTABLE) if(NOT rc) add_ceph_test(run-promtool-unittests ${PROMTOOL_EXECUTABLE} test rules ${CMAKE_SOURCE_DIR}/monitoring/prometheus/alerts/test_alerts.yml) - else() + elseif(NOT promtool_executable_checked) message(WARNING "'${PROMTOOL_EXECUTABLE} test rules' does not work, " "please use a newer prometheus") endif() -else() +elseif(NOT promtool_executable_checked) message(WARNING "run-promtool-unittests is skipped due to missing promtool") endif() -- 2.39.5