summaryrefslogtreecommitdiffstats
path: root/Tests/StringFileTest
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2012-08-13 17:50:14 (GMT)
committerBrad King <brad.king@kitware.com>2012-08-13 18:19:16 (GMT)
commit9db3116226cb99fcf54e936c833953abcde9b729 (patch)
treebd755ed9e616bbf1482a894bc7946980d81b7703 /Tests/StringFileTest
parent77543bde41b0e52c3959016698b529835945d62d (diff)
downloadCMake-9db3116226cb99fcf54e936c833953abcde9b729.zip
CMake-9db3116226cb99fcf54e936c833953abcde9b729.tar.gz
CMake-9db3116226cb99fcf54e936c833953abcde9b729.tar.bz2
Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block termination commands to have arguments matching the command starting the block. This is no longer the preferred style. Run the following shell code: for c in else endif endforeach endfunction endmacro endwhile; do echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | egrep -z -v 'Tests/CMakeTests/While-Endwhile-' | xargs -0 sed -i -f convert.sed && rm convert.sed
Diffstat (limited to 'Tests/StringFileTest')
-rw-r--r--Tests/StringFileTest/CMakeLists.txt70
1 files changed, 35 insertions, 35 deletions
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 0af11f7..6d798b0 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -10,9 +10,9 @@ file(READ "${CMAKE_CURRENT_SOURCE_DIR}/test.bin" hexContents HEX)
if("${hexContents}" STREQUAL "0001027700")
message("file(READ HEX) correctly read [${hexContents}]")
-else("${hexContents}" STREQUAL "0001027700")
+else()
message(SEND_ERROR "file(READ HEX) incorrectly read [${hexContents}], but expected was [0001027700]")
-endif("${hexContents}" STREQUAL "0001027700")
+endif()
# file(STRINGS) test
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in" infile_strings
@@ -21,17 +21,17 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in" infile_strings
set(infile_strings_goal "#include \"includefile\"\n")
if("${infile_strings}" STREQUAL "${infile_strings_goal}")
message("file(STRINGS) correctly read [${infile_strings}]")
-else("${infile_strings}" STREQUAL "${infile_strings_goal}")
+else()
message(SEND_ERROR
"file(STRINGS) incorrectly read [${infile_strings}]")
-endif("${infile_strings}" STREQUAL "${infile_strings_goal}")
+endif()
# test reading a file and getting its binary data as hex string
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/main.srec" infilehex LIMIT 4 HEX)
if(NOT "${infilehex}" STREQUAL "53313036")
message(SEND_ERROR
"file(READ ... HEX) error, read: \"${infilehex}\", expected \"53313036\"")
-endif(NOT "${infilehex}" STREQUAL "53313036")
+endif()
# test that file(STRINGS) also work with Intel hex and Motorola S-record files
@@ -40,20 +40,20 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/main.ihx" infile_strings REGEX INFO)
set(infile_strings_goal "INFO:compiler\\[SDCC-HEX\\]")
if("${infile_strings}" MATCHES "${infile_strings_goal}")
message("file(STRINGS) correctly read from hex file [${infile_strings}]")
-else("${infile_strings}" MATCHES "${infile_strings_goal}")
+else()
message(SEND_ERROR
"file(STRINGS) incorrectly read from hex file [${infile_strings}]")
-endif("${infile_strings}" MATCHES "${infile_strings_goal}")
+endif()
# this file has been created with "sdcc main.c --out-fmt-s19"
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/main.srec" infile_strings REGEX INFO)
set(infile_strings_goal "INFO:compiler\\[SDCC-SREC\\]")
if("${infile_strings}" MATCHES "${infile_strings_goal}")
message("file(STRINGS) correctly read from srec file [${infile_strings}]")
-else("${infile_strings}" MATCHES "${infile_strings_goal}")
+else()
message(SEND_ERROR
"file(STRINGS) incorrectly read from srec file [${infile_strings}]")
-endif("${infile_strings}" MATCHES "${infile_strings_goal}")
+endif()
# String test
string(REGEX MATCH "[cC][mM][aA][kK][eE]" rmvar "CMake is great")
@@ -75,35 +75,35 @@ string(REPLACE "Autoconf" "CMake" repvar "People should use Autoconf")
if("abc" STREQUAL "xyz")
message(SEND_ERROR "Problem with the if(STREQUAL), \"abc\" and \"xyz\" considered equal")
-endif("abc" STREQUAL "xyz")
+endif()
if("CMake is cool" MATCHES "(CMake) (is).+")
if(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool")
message(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"CMake is cool\"")
- endif(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool")
+ endif()
if(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake")
message(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"CMake\"")
- endif(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake")
+ endif()
if(NOT "${CMAKE_MATCH_2}" STREQUAL "is")
message(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected \"is\"")
- endif(NOT "${CMAKE_MATCH_2}" STREQUAL "is")
-else("CMake is cool" MATCHES "(CMake) (is).+")
+ endif()
+else()
message(SEND_ERROR "Problem with the if(MATCHES), no match found")
-endif("CMake is cool" MATCHES "(CMake) (is).+")
+endif()
string(REGEX MATCH "(People).+CMake" matchResultVar "People should use CMake")
if(NOT "${matchResultVar}" STREQUAL "People should use CMake")
message(SEND_ERROR "string(REGEX MATCH) problem: \"${matchResultVar}\", expected \"People should use CMake\"")
-endif(NOT "${matchResultVar}" STREQUAL "People should use CMake")
+endif()
if(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake")
message(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"People should use CMake\"")
-endif(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake")
+endif()
if(NOT "${CMAKE_MATCH_1}" STREQUAL "People")
message(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"People\"")
-endif(NOT "${CMAKE_MATCH_1}" STREQUAL "People")
+endif()
if(NOT "${CMAKE_MATCH_2}" STREQUAL "")
message(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected empty string")
-endif(NOT "${CMAKE_MATCH_2}" STREQUAL "")
+endif()
string(STRIP "
@@ -115,10 +115,10 @@ string(STRIP " ST3" ST3)
foreach(var ST1 ST2 ST3)
if("${var}" STREQUAL "${${var}}")
message("[${var}] == [${${var}}]")
- else("${var}" STREQUAL "${${var}}")
+ else()
message(SEND_ERROR "Problem with the STRIP command for ${var}: [${${var}}]")
- endif("${var}" STREQUAL "${${var}}")
-endforeach(var)
+ endif()
+endforeach()
string(SUBSTRING "People should use Autoconf" 7 10 substringres)
set(substringres "Everybody ${substringres} CMake")
@@ -139,7 +139,7 @@ message("Output: [${var}]")
string(COMPARE EQUAL "${var}" "$(VAR1)$(VAR2)/$(VAR3)" result)
if(NOT result)
message(SEND_ERROR "Unquoted $(VAR) syntax is broken.")
-endif(NOT result)
+endif()
# Obscure environment variable name
set("ENV{x+(y)}" "Obscure environment variable value")
@@ -178,12 +178,12 @@ foreach(var
tuvar
tlvar)
file(APPEND "${file}" "#define ${var} \"${${var}}\"\n")
-endforeach(var)
+endforeach()
# Verify that the file was created recently.
if(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
message(FATAL_ERROR "if(FILE_IS_NEWER) does not seem to work.")
-endif(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
+endif()
# Test configuration of the string
set(TEST_DEFINED 123)
@@ -225,13 +225,13 @@ macro(TEST_RANGE ARGS CHECK)
set(r)
foreach(a RANGE ${ARGS})
set(r ${r} ${a})
- endforeach(a)
+ endforeach()
message("FOREACH with RANGE ${ARGS} produces ${r}")
if("x${r}x" MATCHES "^x${CHECK}x$")
- else("x${r}x" MATCHES "^x${CHECK}x$")
+ else()
message(SEND_ERROR "The range resulted in: ${r} should be ${CHECK}")
- endif("x${r}x" MATCHES "^x${CHECK}x$")
-endmacro(TEST_RANGE)
+ endif()
+endmacro()
TEST_RANGE("5" "0;1;2;3;4;5")
TEST_RANGE("3;5" "3;4;5")
TEST_RANGE("5;3" "5;4;3")
@@ -246,7 +246,7 @@ set(var_a)
set(var_b)
foreach(item IN LISTS list1 list2 ITEMS "" a "")
set(var_${item} "${var_${item}}x")
-endforeach(item)
+endforeach()
if(NOT "${var_}" STREQUAL "xxxxx")
message(FATAL_ERROR "count incorrect for \"\": [${var_}]")
endif()
@@ -267,16 +267,16 @@ string(SUBSTRING ${ST_INPUTSTRING} 9 -1 ST_NINE)
if(ST_EMPTY)
message(SEND_ERROR "SUBSTRING with length 0 does not return an empty string")
-endif(ST_EMPTY)
+endif()
if(NOT ST_ONE STREQUAL "1")
message(SEND_ERROR "SUBSTING command does not cut the correct selected character, was \"" ${ST_ONE} "\", should be \"1\"")
-endif(NOT ST_ONE STREQUAL "1")
+endif()
if(NOT ST_INPUTSTRING STREQUAL ST_ALL)
message(SEND_ERROR "SUBSTRING does not return the whole string when selected with length")
-endif(NOT ST_INPUTSTRING STREQUAL ST_ALL)
+endif()
if(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS)
message(SEND_ERROR "SUBSTRING does not return the whole string when selected with -1")
-endif(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS)
+endif()
if(NOT ST_NINE STREQUAL "9")
message(SEND_ERROR "SUBSTRING does not return the tail when selected with -1")
-endif(NOT ST_NINE STREQUAL "9")
+endif()