summaryrefslogtreecommitdiffstats
path: root/test/run.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-28 14:34:12 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-28 16:21:35 (GMT)
commitbafe43d6438fa5ce0ef778d5d713cd7f594370b9 (patch)
tree00c732375758a3f69de9fbdddd4cfff0838c4bd2 /test/run.cmake
parent2235efe2de1db560083b69c711739533c205eb25 (diff)
downloadCastXML-bafe43d6438fa5ce0ef778d5d713cd7f594370b9.zip
CastXML-bafe43d6438fa5ce0ef778d5d713cd7f594370b9.tar.gz
CastXML-bafe43d6438fa5ce0ef778d5d713cd7f594370b9.tar.bz2
test: Add option to transform actual xml to expected xml
If TEST_UPDATE is set in the environment and a test fails, transform the actual xml output into the expected xml and overwrite the .xml.txt file containing the latter. This will help make sweeping updates to the expected test output when sweeping output format changes are made.
Diffstat (limited to 'test/run.cmake')
-rw-r--r--test/run.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/run.cmake b/test/run.cmake
index 5e1c55b..a123639 100644
--- a/test/run.cmake
+++ b/test/run.cmake
@@ -55,6 +55,7 @@ foreach(o result stdout stderr ${maybe_xml})
foreach(e ${expect})
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/expect/${e}.${o}.txt)
file(READ ${CMAKE_CURRENT_LIST_DIR}/expect/${e}.${o}.txt expect_${o})
+ set(expect_${o}_file ${CMAKE_CURRENT_LIST_DIR}/expect/${e}.${o}.txt)
break()
endif()
endforeach()
@@ -73,6 +74,17 @@ foreach(o result stdout stderr ${maybe_xml})
endforeach()
if(msg)
+ if("$ENV{TEST_UPDATE}" AND expect_xml_file AND EXISTS "${xml}")
+ set(update_xml "${actual_xml}")
+ string(REGEX REPLACE "^<\\?xml version=\"1.0\"\\?>" "^<\\\\?xml version=\"1.0\"\\\\?>" update_xml "${update_xml}")
+ string(REGEX REPLACE "<GCC_XML[^>]*>" "<GCC_XML[^>]*>" update_xml "${update_xml}")
+ string(REGEX REPLACE "artificial=\"1\"( throws=\"\")?" "artificial=\"1\"( throws=\"\")?" update_xml "${update_xml}")
+ string(REGEX REPLACE "size=\"[0-9]+\" align=\"[0-9]+\"" "size=\"[0-9]+\" align=\"[0-9]+\"" update_xml "${update_xml}")
+ string(REGEX REPLACE "<File id=\"(f[0-9]+)\" name=\"[^\"]*/test/input/([^\"]*)\"/>" "<File id=\"\\1\" name=\".*/test/input/\\2\"/>" update_xml "${update_xml}")
+ string(REGEX REPLACE "</GCC_XML>$" "</GCC_XML>$" update_xml "${update_xml}")
+ file(WRITE "${expect_xml_file}" "${update_xml}\n")
+ endif()
+
string(REPLACE ";" "\" \"" command_string "\"${command}\"")
set(msg "${msg}Command was:\n command> ${command_string}\n")
message(SEND_ERROR