summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-09 20:01:42 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-09 20:44:12 (GMT)
commit174356cdb7f27e741f9668883d1c5d558e20bc6b (patch)
treed2f870ba895030d76745ca7e50d69f8cdc33d9db
parent9216e5fb1fdffd5c0040ee4ea50e6b3ea6129964 (diff)
downloadCastXML-174356cdb7f27e741f9668883d1c5d558e20bc6b.zip
CastXML-174356cdb7f27e741f9668883d1c5d558e20bc6b.tar.gz
CastXML-174356cdb7f27e741f9668883d1c5d558e20bc6b.tar.bz2
test: Support zero or many alternative expected result file names
Teach test/run.cmake to loop over a list of possible expected result names. This will allow tests results to be specialized in certain cases without duplicating common results.
-rw-r--r--test/CMakeLists.txt4
-rw-r--r--test/run.cmake13
2 files changed, 10 insertions, 7 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 5248b72..0c6550d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -22,7 +22,7 @@ macro(castxml_test_cmd test)
NAME cmd.${test}
COMMAND ${CMAKE_COMMAND}
"-Dcommand:STRING=${command}"
- "-Dtest=cmd.${test}"
+ "-Dexpect=cmd.${test}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/run.cmake
)
endmacro()
@@ -38,7 +38,7 @@ macro(castxml_test_gccxml_common prefix ext std test)
NAME ${prefix}.${test}
COMMAND ${CMAKE_COMMAND}
"-Dcommand:STRING=${command}"
- "-Dtest=${prefix}.${test}"
+ "-Dexpect=${prefix}.${test}"
"-Dxml=${prefix}.${test}.xml"
"-Dxmllint=${LIBXML2_XMLLINT_EXECUTABLE}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/run.cmake
diff --git a/test/run.cmake b/test/run.cmake
index 3699b6c..560327e 100644
--- a/test/run.cmake
+++ b/test/run.cmake
@@ -45,12 +45,15 @@ foreach(o result stdout stderr ${maybe_xml})
set(actual-${o} "Actual ${o}:\n${actual-${o}}\n")
set(expect-${o} "")
- if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/expect/${test}-${o}.txt)
- file(READ ${CMAKE_CURRENT_LIST_DIR}/expect/${test}-${o}.txt expect_${o})
- elseif(DEFINED default_${o})
+ unset(expect_${o})
+ 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})
+ break()
+ endif()
+ endforeach()
+ if(NOT DEFINED expect_${o} AND DEFINED default_${o})
set(expect_${o} "${default_${o}}")
- else()
- unset(expect_${o})
endif()
if(DEFINED expect_${o})