diff options
author | Brad King <brad.king@kitware.com> | 2014-02-25 19:23:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-21 20:32:55 (GMT) |
commit | 3b40cc53502afa476384b2c62ec6fee9f521b1fd (patch) | |
tree | 0517fc5c3d86d86608fc1b417c211d3ff15fe30b | |
parent | 5aa9127574095f317a368d09c5a6bfb996ae792f (diff) | |
download | CastXML-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.
-rw-r--r-- | test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | test/run.cmake | 23 |
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() |