summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/message
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2019-10-12 02:37:15 (GMT)
committerCraig Scott <craig.scott@crascit.com>2019-10-12 07:21:36 (GMT)
commit7cf79f44195a86a907dba770f1f7a361d00e77c2 (patch)
treea8c9b970b55979ec5eecce59aadab91036941235 /Tests/RunCMake/message
parent5bf85e25178f5d9f19d2f30cf66f088c21e1114a (diff)
downloadCMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.zip
CMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.tar.gz
CMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.tar.bz2
message: Support logging a context with each message
Diffstat (limited to 'Tests/RunCMake/message')
-rw-r--r--Tests/RunCMake/message/RunCMakeTest.cmake15
-rw-r--r--Tests/RunCMake/message/message-context-cache-stdout.txt8
-rw-r--r--Tests/RunCMake/message/message-context-cli-stdout.txt8
-rw-r--r--Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt5
-rw-r--r--Tests/RunCMake/message/message-context.cmake27
5 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake
index 50271d4..bf6a47e 100644
--- a/Tests/RunCMake/message/RunCMakeTest.cmake
+++ b/Tests/RunCMake/message/RunCMakeTest.cmake
@@ -68,3 +68,18 @@ run_cmake_command(
message-indent-multiline
${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-indent-multiline.cmake
)
+
+run_cmake_command(
+ message-context-cli
+ ${CMAKE_COMMAND} --log-level=trace --log-context -P ${RunCMake_SOURCE_DIR}/message-context.cmake
+ )
+
+run_cmake_command(
+ message-context-cache
+ ${CMAKE_COMMAND} -DCMAKE_MESSAGE_LOG_LEVEL=TRACE -DCMAKE_MESSAGE_CONTEXT_SHOW=ON -P ${RunCMake_SOURCE_DIR}/message-context.cmake
+ )
+
+run_cmake_command(
+ message-context-cli-wins-cache
+ ${CMAKE_COMMAND} --log-level=verbose --log-context -DCMAKE_MESSAGE_CONTEXT_SHOW=OFF -P ${RunCMake_SOURCE_DIR}/message-context.cmake
+ )
diff --git a/Tests/RunCMake/message/message-context-cache-stdout.txt b/Tests/RunCMake/message/message-context-cache-stdout.txt
new file mode 100644
index 0000000..af18c15
--- /dev/null
+++ b/Tests/RunCMake/message/message-context-cache-stdout.txt
@@ -0,0 +1,8 @@
+-- Begin context output test
+-- \[top\] Top: before
+-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message
+-- \[top\.foo\] foo TRACE message
+-- \[top\.foo\.baz\] This is the multi-line
+\[top\.foo\.baz\] baz DEBUG message
+-- \[top\] Top: after
+-- End of context output test
diff --git a/Tests/RunCMake/message/message-context-cli-stdout.txt b/Tests/RunCMake/message/message-context-cli-stdout.txt
new file mode 100644
index 0000000..af18c15
--- /dev/null
+++ b/Tests/RunCMake/message/message-context-cli-stdout.txt
@@ -0,0 +1,8 @@
+-- Begin context output test
+-- \[top\] Top: before
+-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message
+-- \[top\.foo\] foo TRACE message
+-- \[top\.foo\.baz\] This is the multi-line
+\[top\.foo\.baz\] baz DEBUG message
+-- \[top\] Top: after
+-- End of context output test
diff --git a/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt b/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt
new file mode 100644
index 0000000..157db97
--- /dev/null
+++ b/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt
@@ -0,0 +1,5 @@
+-- Begin context output test
+-- \[top\] Top: before
+-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message
+-- \[top\] Top: after
+-- End of context output test
diff --git a/Tests/RunCMake/message/message-context.cmake b/Tests/RunCMake/message/message-context.cmake
new file mode 100644
index 0000000..93d4cd9
--- /dev/null
+++ b/Tests/RunCMake/message/message-context.cmake
@@ -0,0 +1,27 @@
+function(bar)
+ list(APPEND CMAKE_MESSAGE_CONTEXT "bar")
+ list(APPEND CMAKE_MESSAGE_INDENT "<-- indent -->")
+ message(VERBOSE "bar VERBOSE message")
+endfunction()
+
+function(baz)
+ list(APPEND CMAKE_MESSAGE_CONTEXT "baz")
+ message(DEBUG "This is the multi-line\nbaz DEBUG message")
+endfunction()
+
+function(foo)
+ list(APPEND CMAKE_MESSAGE_CONTEXT "foo")
+ bar()
+ message(TRACE "foo TRACE message")
+ baz()
+endfunction()
+
+message(STATUS "Begin context output test")
+list(APPEND CMAKE_MESSAGE_CONTEXT "top")
+
+message(STATUS "Top: before")
+foo()
+message(STATUS "Top: after")
+
+list(POP_BACK CMAKE_MESSAGE_CONTEXT)
+message(STATUS "End of context output test")