summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-02-25 19:23:58 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-21 20:32:55 (GMT)
commit3b40cc53502afa476384b2c62ec6fee9f521b1fd (patch)
tree0517fc5c3d86d86608fc1b417c211d3ff15fe30b /test
parent5aa9127574095f317a368d09c5a6bfb996ae792f (diff)
downloadCastXML-3b40cc53502afa476384b2c62ec6fee9f521b1fd.zip
CastXML-3b40cc53502afa476384b2c62ec6fee9f521b1fd.tar.gz
CastXML-3b40cc53502afa476384b2c62ec6fee9f521b1fd.tar.bz2
Extend xml test cases to validate with xmllint if available
Look for xmllint and use it to validate the xml format in test results.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/run.cmake23
2 files changed, 26 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8e65bea..623e040 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -14,6 +14,8 @@
# limitations under the License.
#=============================================================================
+find_package(LibXml2 QUIET)
+
macro(castxml_test_cmd test)
set(command $<TARGET_FILE:castxml> ${ARGN})
add_test(
@@ -37,6 +39,7 @@ macro(castxml_test_gccxml test)
"-Dcommand:STRING=${command}"
"-Dtest=gccxml.${test}"
"-Dxml=${test}.xml"
+ "-Dxmllint=${LIBXML2_XMLLINT_EXECUTABLE}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/run.cmake
)
endmacro()
diff --git a/test/run.cmake b/test/run.cmake
index c66405f..9cf4ad6 100644
--- a/test/run.cmake
+++ b/test/run.cmake
@@ -72,3 +72,26 @@ if(msg)
"${actual-xml}"
)
endif()
+
+if(xmllint AND xml AND EXISTS "${xml}")
+ execute_process(
+ COMMAND ${xmllint} --noout --nonet "${xml}"
+ OUTPUT_VARIABLE xmllint_stdout
+ ERROR_VARIABLE xmllint_stderr
+ RESULT_VARIABLE xmllint_result
+ )
+ if(xmllint_result)
+ foreach(o result stdout stderr)
+ string(REGEX REPLACE "\n+$" "" xmllint_${o} "${xmllint_${o}}")
+ string(REGEX REPLACE "\n" "\n xmllint-${o}> " xmllint-${o} " xmllint-${o}> ${xmllint_${o}}")
+ set(xmllint-${o} "xmllint ${o}:\n${xmllint-${o}}\n")
+ endforeach()
+ message(SEND_ERROR
+ "xmllint check failed:\n"
+ "${msg}"
+ "${xmllint-result}"
+ "${xmllint-stdout}"
+ "${xmllint-stderr}"
+ )
+ endif()
+endif()