diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-11-09 20:07:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-12-14 16:42:29 (GMT) |
commit | e8b8d82cbf60e517ad4b9026ba24de1c59165af4 (patch) | |
tree | f5cc41bdbde54033b86f623f53feea5e0c295ec0 /Tests | |
parent | 8d29a0bda616c4c344def2b1db7aaa94b7f27dbb (diff) | |
download | CMake-e8b8d82cbf60e517ad4b9026ba24de1c59165af4.zip CMake-e8b8d82cbf60e517ad4b9026ba24de1c59165af4.tar.gz CMake-e8b8d82cbf60e517ad4b9026ba24de1c59165af4.tar.bz2 |
Tests: Generalize RunCMake expectation component names
Do not assume all the component names start in "std".
Co-authored-by: Brad King <brad.king@kitware.com>
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index cc754e8..670beb9 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) + 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) @@ -180,17 +180,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) + 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 +211,15 @@ 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) + 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() + string(REGEX REPLACE "\n" "\n actual-${o}> " actual_${o} " actual-${o}> ${actual_${o}}") + string(APPEND msg "Actual ${o}:\n${actual_${o}}\n") + endforeach() + message(SEND_ERROR "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - FAILED:\n${msg}") else() message(STATUS "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - PASSED") endif() |