aboutsummaryrefslogtreecommitdiff
path: root/tests/ECMQtDeclareLoggingCategoryTest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ECMQtDeclareLoggingCategoryTest')
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt50
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/log.categories6
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories6
3 files changed, 62 insertions, 0 deletions
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
index 74f24317..a921fd3b 100644
--- a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
+++ b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
@@ -5,12 +5,35 @@ set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules")
set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
include(ECMQtDeclareLoggingCategory)
+include(CMakeParseArguments)
+
+function (check_file)
+ set(options)
+ set(oneValueArgs GENERATED EXPECTED)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if (NOT EXISTS "${ARGS_GENERATED}")
+ message(FATAL_ERROR "${ARGS_GENERATED} was not generated")
+ endif()
+ file(READ "${ARGS_GENERATED}" generated_contents)
+ if (NOT EXISTS "${ARGS_EXPECTED}")
+ message(FATAL_ERROR "Original ${ARGS_EXPECTED} was not found")
+ endif()
+ file(READ "${ARGS_EXPECTED}" original_contents)
+ if (NOT "${generated_contents}" STREQUAL "${original_contents}")
+ message(FATAL_ERROR "${generated_file} contains '${generated_contents}' instead of '${original_contents}'")
+ endif()
+endfunction()
ecm_qt_declare_logging_category(
sources
HEADER "log1.h"
IDENTIFIER "log1"
CATEGORY_NAME "log.one"
+ OLD_CATEGORY_NAMES "log1old"
+ DESCRIPTION "log 1"
+ EXPORT LOG
)
ecm_qt_declare_logging_category(
@@ -18,6 +41,9 @@ ecm_qt_declare_logging_category(
HEADER "log2.h"
IDENTIFIER "foo::bar::log2"
CATEGORY_NAME "log.two"
+ DEFAULT_SEVERITY Info
+ DESCRIPTION "log 2"
+ EXPORT LOG
)
ecm_qt_declare_logging_category(
@@ -28,6 +54,15 @@ ecm_qt_declare_logging_category(
DEFAULT_SEVERITY Critical
)
+ecm_qt_export_logging_category(
+ IDENTIFIER "log4"
+ CATEGORY_NAME "log.four"
+ OLD_CATEGORY_NAMES "logfouroldest" "log4old"
+ DEFAULT_SEVERITY Warning
+ EXPORT LOG
+ DESCRIPTION "log 4"
+)
+
find_package(Qt5Core REQUIRED)
add_executable(testmain testmain.cpp ${sources})
@@ -40,3 +75,18 @@ target_link_libraries(testmain
Qt5::Core
)
+ecm_qt_install_logging_categories(
+ EXPORT LOG
+ FILE log.categories
+ DESTINATION "${CMAKE_BINARY_DIR}/dummyinstall"
+)
+
+check_file(
+ GENERATED "${CMAKE_CURRENT_BINARY_DIR}/log.categories"
+ EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/log.categories"
+)
+check_file(
+ GENERATED "${CMAKE_CURRENT_BINARY_DIR}/log.renamecategories"
+ EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/log.renamecategories"
+)
+
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/log.categories b/tests/ECMQtDeclareLoggingCategoryTest/log.categories
new file mode 100644
index 00000000..267c5064
--- /dev/null
+++ b/tests/ECMQtDeclareLoggingCategoryTest/log.categories
@@ -0,0 +1,6 @@
+# KDebugSettings data file
+# This file was generated by ecm_qt_install_logging_categories(). DO NOT EDIT!
+
+log.one log 1 IDENTIFIER [log1]
+log.two log 2 DEFAULT_SEVERITY [INFO] IDENTIFIER [foo::bar::log2]
+log.four log 4 DEFAULT_SEVERITY [WARNING] IDENTIFIER [log4]
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories b/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories
new file mode 100644
index 00000000..7bcac2fb
--- /dev/null
+++ b/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories
@@ -0,0 +1,6 @@
+# KDebugSettings data file
+# This file was generated by ecm_qt_install_logging_categories(). DO NOT EDIT!
+
+log1old log.one
+logfouroldest log4old
+log4old log.four