summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-12-17 13:44:36 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-12-17 13:44:50 (GMT)
commita1b71112d10b371610ef03b908ce9f2ab8eaeaf9 (patch)
treee1280527bde42f2207a373ddaa0923a90557ee3f /Tests
parent20a77bdf170d22072b4161693b06322559d0b3e9 (diff)
parent6c40e0b25ec8475d73779ffbaa63a4230aa5e28d (diff)
downloadCMake-a1b71112d10b371610ef03b908ce9f2ab8eaeaf9.zip
CMake-a1b71112d10b371610ef03b908ce9f2ab8eaeaf9.tar.gz
CMake-a1b71112d10b371610ef03b908ce9f2ab8eaeaf9.tar.bz2
Merge topic 'configure-log'
6c40e0b25e ConfigureLog: Version individual events instead of the whole log 048a02d5bb ConfigureLog: Log try_compile and try_run checks 746c776caf ConfigureLog: Add infrastructure for structured configure event logging e8b8d82cbf Tests: Generalize RunCMake expectation component names 8d29a0bda6 cmTryRunCommand: Factor out stdout/stderr capture conditions fdda4095a3 cmCoreTryCompile: Return more semantic information from compile step Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8017
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/RunCMake.cmake66
-rw-r--r--Tests/RunCMake/try_compile/Inspect-config.txt34
-rw-r--r--Tests/RunCMake/try_compile/SourceFromBadName-config.txt1
-rw-r--r--Tests/RunCMake/try_run/ConfigureLog-bad.c1
-rw-r--r--Tests/RunCMake/try_run/ConfigureLog-config.txt96
-rw-r--r--Tests/RunCMake/try_run/ConfigureLog-test.c9
-rw-r--r--Tests/RunCMake/try_run/ConfigureLog.cmake18
-rw-r--r--Tests/RunCMake/try_run/RunCMakeTest.cmake1
8 files changed, 195 insertions, 31 deletions
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index cc754e8..54d7eb5 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -33,18 +33,18 @@ function(run_cmake test)
set(platform_name msys)
endif()
- foreach(o IN ITEMS out err)
- if(RunCMake-std${o}-file AND EXISTS ${top_src}/${RunCMake-std${o}-file})
- file(READ ${top_src}/${RunCMake-std${o}-file} expect_std${o})
- string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
- elseif(EXISTS ${top_src}/${test}-std${o}-${platform_name}.txt)
- file(READ ${top_src}/${test}-std${o}-${platform_name}.txt expect_std${o})
- string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
- elseif(EXISTS ${top_src}/${test}-std${o}.txt)
- file(READ ${top_src}/${test}-std${o}.txt expect_std${o})
- string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
+ foreach(o IN ITEMS stdout stderr config)
+ if(RunCMake-${o}-file AND EXISTS ${top_src}/${RunCMake-${o}-file})
+ file(READ ${top_src}/${RunCMake-${o}-file} expect_${o})
+ string(REGEX REPLACE "\n+$" "" expect_${o} "${expect_${o}}")
+ elseif(EXISTS ${top_src}/${test}-${o}-${platform_name}.txt)
+ file(READ ${top_src}/${test}-${o}-${platform_name}.txt expect_${o})
+ string(REGEX REPLACE "\n+$" "" expect_${o} "${expect_${o}}")
+ elseif(EXISTS ${top_src}/${test}-${o}.txt)
+ file(READ ${top_src}/${test}-${o}.txt expect_${o})
+ string(REGEX REPLACE "\n+$" "" expect_${o} "${expect_${o}}")
else()
- unset(expect_std${o})
+ unset(expect_${o})
endif()
endforeach()
if (NOT expect_stderr)
@@ -144,6 +144,12 @@ function(run_cmake test)
if(NOT "${actual_result}" MATCHES "${expect_result}")
string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n")
endif()
+ set(config_file "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}/CMakeFiles/CMakeConfigureLog.yaml")
+ if(EXISTS "${config_file}")
+ file(READ "${config_file}" actual_config)
+ else()
+ set(actual_config "")
+ endif()
# Special case: remove ninja no-op line from stderr, but not stdout.
# Test cases that look for it should use RunCMake_TEST_OUTPUT_MERGE.
@@ -180,17 +186,13 @@ function(run_cmake test)
"|[^\n]*Bullseye Testing Technology"
")[^\n]*\n)+"
)
- foreach(o IN ITEMS out err)
- string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}")
- string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_std${o} "${actual_std${o}}")
- string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}")
- set(expect_${o} "")
- if(DEFINED expect_std${o})
- if(NOT "${actual_std${o}}" MATCHES "${expect_std${o}}")
- string(REGEX REPLACE "\n" "\n expect-${o}> " expect_${o}
- " expect-${o}> ${expect_std${o}}")
- set(expect_${o} "Expected std${o} to match:\n${expect_${o}}\n")
- string(APPEND msg "std${o} does not match that expected.\n")
+ foreach(o IN ITEMS stdout stderr config)
+ string(REGEX REPLACE "\r\n" "\n" actual_${o} "${actual_${o}}")
+ string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_${o} "${actual_${o}}")
+ string(REGEX REPLACE "\n+$" "" actual_${o} "${actual_${o}}")
+ if(DEFINED expect_${o})
+ if(NOT "${actual_${o}}" MATCHES "${expect_${o}}")
+ string(APPEND msg "${o} does not match that expected.\n")
endif()
endif()
endforeach()
@@ -215,15 +217,17 @@ function(run_cmake test)
string(APPEND msg "Command was:\n command> ${command}\n")
endif()
if(msg)
- string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}")
- string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}")
- message(SEND_ERROR "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - FAILED:\n"
- "${msg}"
- "${expect_out}"
- "Actual stdout:\n${actual_out}\n"
- "${expect_err}"
- "Actual stderr:\n${actual_err}\n"
- )
+ foreach(o IN ITEMS stdout stderr config)
+ if(DEFINED expect_${o})
+ string(REGEX REPLACE "\n" "\n expect-${o}> " expect_${o} " expect-${o}> ${expect_${o}}")
+ string(APPEND msg "Expected ${o} to match:\n${expect_${o}}\n")
+ endif()
+ if(NOT o STREQUAL "config" OR DEFINED expect_${o})
+ string(REGEX REPLACE "\n" "\n actual-${o}> " actual_${o} " actual-${o}> ${actual_${o}}")
+ string(APPEND msg "Actual ${o}:\n${actual_${o}}\n")
+ endif()
+ endforeach()
+ message(SEND_ERROR "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - FAILED:\n${msg}")
else()
message(STATUS "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - PASSED")
endif()
diff --git a/Tests/RunCMake/try_compile/Inspect-config.txt b/Tests/RunCMake/try_compile/Inspect-config.txt
new file mode 100644
index 0000000..47169cf
--- /dev/null
+++ b/Tests/RunCMake/try_compile/Inspect-config.txt
@@ -0,0 +1,34 @@
+^
+---
+events:
+ -
+ kind: "try_compile-v1"
+ backtrace:
+ - "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
+ - "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
+ - "Inspect.cmake:[0-9]+ \(enable_language\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "CMAKE_C_ABI_COMPILED"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+ -
+ kind: "try_compile-v1"
+ backtrace:
+ - "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
+ - "[^"]*/Modules/CMakeTestCXXCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
+ - "Inspect.cmake:[0-9]+ \(enable_language\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "CMAKE_CXX_ABI_COMPILED"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+\.\.\.$
diff --git a/Tests/RunCMake/try_compile/SourceFromBadName-config.txt b/Tests/RunCMake/try_compile/SourceFromBadName-config.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/try_compile/SourceFromBadName-config.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/try_run/ConfigureLog-bad.c b/Tests/RunCMake/try_run/ConfigureLog-bad.c
new file mode 100644
index 0000000..6508ead
--- /dev/null
+++ b/Tests/RunCMake/try_run/ConfigureLog-bad.c
@@ -0,0 +1 @@
+#error "This does not compile!"
diff --git a/Tests/RunCMake/try_run/ConfigureLog-config.txt b/Tests/RunCMake/try_run/ConfigureLog-config.txt
new file mode 100644
index 0000000..602437e
--- /dev/null
+++ b/Tests/RunCMake/try_run/ConfigureLog-config.txt
@@ -0,0 +1,96 @@
+^
+---
+events:
+ -
+ kind: "try_compile-v1"
+ backtrace:
+ - "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
+ - "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
+ - "CMakeLists.txt:[0-9]+ \(project\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "CMAKE_C_ABI_COMPILED"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+ -
+ kind: "try_run-v1"
+ backtrace:
+ - "ConfigureLog.cmake:[0-9]+ \(try_run\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "COMPILE_RESULT"
+ cached: true
+ stdout: \|.*
+ exitCode: [1-9][0-9]*
+ runResult:
+ variable: "RUN_RESULT"
+ cached: true
+ -
+ kind: "try_run-v1"
+ backtrace:
+ - "ConfigureLog.cmake:[0-9]+ \(try_run\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "COMPILE_RESULT"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+ runResult:
+ variable: "RUN_RESULT"
+ cached: true
+ stdout: \|
+ Output on stdout!
+ stderr: \|
+ Output, with backslash '\\\\', on stderr!
+ exitCode: 12
+ -
+ kind: "try_run-v1"
+ backtrace:
+ - "ConfigureLog.cmake:[0-9]+ \(try_run\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "COMPILE_RESULT"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+ runResult:
+ variable: "RUN_RESULT"
+ cached: true
+ stdout: \|
+ Output, with backslash '\\\\', on stderr!
+ Output on stdout!
+ exitCode: 12
+ -
+ kind: "try_run-v1"
+ backtrace:
+ - "ConfigureLog.cmake:[0-9]+ \(try_run\)"
+ - "CMakeLists.txt:[0-9]+ \(include\)"
+ directories:
+ source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
+ buildResult:
+ variable: "COMPILE_RESULT"
+ cached: true
+ stdout: \|.*
+ exitCode: 0
+ runResult:
+ variable: "RUN_RESULT"
+ cached: true
+ stdout: \|
+ Output on stdout!
+ stderr: \|
+ Output, with backslash '\\\\', on stderr!
+ exitCode: 12
+\.\.\.$
diff --git a/Tests/RunCMake/try_run/ConfigureLog-test.c b/Tests/RunCMake/try_run/ConfigureLog-test.c
new file mode 100644
index 0000000..6a8f125
--- /dev/null
+++ b/Tests/RunCMake/try_run/ConfigureLog-test.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int main()
+{
+ fprintf(stderr, "Output, with backslash '\\', on stderr!\n");
+ fflush(stderr); /* make output deterministic even if stderr is buffered */
+ fprintf(stdout, "Output on stdout!\n");
+ return 12;
+}
diff --git a/Tests/RunCMake/try_run/ConfigureLog.cmake b/Tests/RunCMake/try_run/ConfigureLog.cmake
new file mode 100644
index 0000000..4b5c7cb
--- /dev/null
+++ b/Tests/RunCMake/try_run/ConfigureLog.cmake
@@ -0,0 +1,18 @@
+try_run(RUN_RESULT COMPILE_RESULT
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-bad.c
+ )
+
+try_run(RUN_RESULT COMPILE_RESULT
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
+ )
+
+try_run(RUN_RESULT COMPILE_RESULT
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT
+ )
+
+try_run(RUN_RESULT COMPILE_RESULT
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
+ RUN_OUTPUT_STDOUT_VARIABLE RUN_STDOUT
+ RUN_OUTPUT_STDERR_VARIABLE RUN_STDERR
+ )
diff --git a/Tests/RunCMake/try_run/RunCMakeTest.cmake b/Tests/RunCMake/try_run/RunCMakeTest.cmake
index dbea089..62e3caf 100644
--- a/Tests/RunCMake/try_run/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_run/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
run_cmake(BinDirEmpty)
run_cmake(BinDirRelative)
run_cmake(NoOutputVariable)
+run_cmake(ConfigureLog)
set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=old_signature.cmake)
include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake)