summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
authorBraulio Valdivielso Martinez <bvaldivielso@bloomberg.net>2022-03-25 15:17:05 (GMT)
committerBraulio Valdivielso Martinez <bvaldivielso@bloomberg.net>2022-03-25 16:24:38 (GMT)
commitfd46db174533ee20917ae1b328c43b1e70f07c43 (patch)
tree5cbe3de6941a7f54e6bed7d5213e01d6d8151bca /Tests/RunCMake/CommandLine
parent89f2d779f245f2fe4c9921931699e3996af066a0 (diff)
downloadCMake-fd46db174533ee20917ae1b328c43b1e70f07c43.zip
CMake-fd46db174533ee20917ae1b328c43b1e70f07c43.tar.gz
CMake-fd46db174533ee20917ae1b328c43b1e70f07c43.tar.bz2
Trace: process else and elseif commands correctly
There have been two bugs reported about the `else` and `elseif` commands in the context of the tracing functionality and the json-v1 format (#23191 #22315). In essence, the reported traces referred to the layer of the stacktrace immediately on top of the expected ones. This MR fixes both issues. My solution adds a new parameter to the `PrintCommandTrace` function, `commandMissingFromStack`, that callers can specify if the command they want to report a trace for is not a regular part of the stack maintained in `cmMakefile`. This is only the case for `else` and `elseif`. The other bug is fixed by having the caller pass a `cmListFileBacktrace`, which helps in getting the right lines, file names... for the reported command. Fixes: #23191 #22315
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rwxr-xr-xTests/RunCMake/CommandLine/trace-json-v1-check.py10
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1.cmake1
3 files changed, 15 insertions, 1 deletions
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
index 2ef1495..c4b95dc 100755
--- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
@@ -56,6 +56,11 @@ required_traces = [
'cmd': 'message',
'frame': 3,
'global_frame': 6 if expand else 5
+ },
+ {
+ 'cmd': 'else',
+ 'global_frame': 4 if expand else 3,
+ 'line': 3
}
]
@@ -98,4 +103,7 @@ with open(trace_file, 'r') as fp:
if subset == j:
required_traces.remove(j)
-assert not required_traces
+assert not required_traces, (
+ "The following traces were expected to be part of the "
+ "output but weren't", required_traces
+)
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt
index 089a960..743f6de 100644
--- a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt
@@ -1,3 +1,8 @@
+function(function_that_uses_else)
+ if(FALSE)
+ else()
+ endif()
+endfunction()
function(f)
message(STATUS "nested global_frame")
endfunction()
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
index 4ed6160..464eb1f 100644
--- a/Tests/RunCMake/CommandLine/trace-json-v1.cmake
+++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
@@ -8,3 +8,4 @@ set(FOO 42)
set(BAR " space in string!")
message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ")
add_subdirectory(trace-json-v1-nested)
+function_that_uses_else()