From 174356cdb7f27e741f9668883d1c5d558e20bc6b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Apr 2014 16:01:42 -0400 Subject: 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. --- test/CMakeLists.txt | 4 ++-- test/run.cmake | 13 ++++++++----- 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}) -- cgit v0.12