summarylogtreecommitdiffstats
path: root/0001-Enable-tidy-tests-only-by-default-via-ENABLE_DEVEL_D.patch
blob: 7464a0b49cb1a4f28a7dbce0b26972d38469e96b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From a1bed55eda18b127750c7bff97f97474cd5c3ce9 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Wed, 22 Nov 2023 12:56:30 +0100
Subject: [PATCH 1/2] Enable tidy tests only by default via
 `ENABLE_DEVEL_DEFAULTS`

This test is only relevant for development. Additionally, the behavior of
clang-format differs slightly between versions so this can really cause
needlessly failures.
---
 cmake/modules/BasicConfig.cmake | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/cmake/modules/BasicConfig.cmake b/cmake/modules/BasicConfig.cmake
index 6a9d65a..dc9a696 100644
--- a/cmake/modules/BasicConfig.cmake
+++ b/cmake/modules/BasicConfig.cmake
@@ -403,8 +403,14 @@ if (NOT META_NO_TIDY)
     if (CMAKE_FORMAT_BIN)
         set(CMAKE_FORMAT_ENABLED_DEFAULT ON)
     endif ()
+    set(TIDY_TESTS_ENABLED_DEFAULT OFF)
+    if (ENABLE_DEVEL_DEFAULTS AND CLANG_FORMAT_ENABLED_DEFAULT)
+        set(TIDY_TESTS_ENABLED_DEFAULT ON)
+    endif ()
     option(CLANG_FORMAT_ENABLED "enables creation of tidy target using clang-format" "${CLANG_FORMAT_ENABLED_DEFAULT}")
     option(CMAKE_FORMAT_ENABLED "enables creation of tidy target using cmake-format" "${CMAKE_FORMAT_ENABLED_DEFAULT}")
+    option(TIDY_TESTS_ENABLED "enables tests for checking whether code is well-formatted using clang-format"
+           "${TIDY_TESTS_ENABLED_DEFAULT}")
 endif ()
 
 # add target for tidying with clang-format
@@ -427,14 +433,16 @@ if (NOT META_NO_TIDY
     add_dependencies(tidy "${META_TARGET_NAME}_tidy")
 
     # also add a test to verify whether sources are tidy
-    add_test(
-        NAME "${META_TARGET_NAME}_tidy_test"
-        COMMAND "${CLANG_FORMAT_BIN}" -output-replacements-xml -style=file ${FORMATABLE_FILES}
-        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
-    list(APPEND CHECK_TARGET_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format")
-    set_tests_properties(
-        "${META_TARGET_NAME}_tidy_test" PROPERTIES FAIL_REGULAR_EXPRESSION "<replacement.*>.*</replacement>" REQUIRED_FILES
-                                                   "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format")
+    if (TIDY_TESTS_ENABLED)
+        add_test(
+            NAME "${META_TARGET_NAME}_tidy_test"
+            COMMAND "${CLANG_FORMAT_BIN}" -output-replacements-xml -style=file ${FORMATABLE_FILES}
+            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
+        list(APPEND CHECK_TARGET_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format")
+        set_tests_properties(
+            "${META_TARGET_NAME}_tidy_test" PROPERTIES FAIL_REGULAR_EXPRESSION "<replacement.*>.*</replacement>"
+                                                       REQUIRED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format")
+    endif ()
 endif ()
 
 # add target for tidying with cmake-format
-- 
2.42.1