RunCMakeTest.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. include(RunCMake)
  2. run_cmake(no-arguments)
  3. run_cmake(bad-option)
  4. function(check_string_syntax name test)
  5. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-${test}-build)
  6. set(RunCMake_TEST_VARIANT_DESCRIPTION " - ${name}")
  7. run_cmake_with_options(${test} ${ARGN})
  8. endfunction()
  9. ## Unexpected arguments
  10. ### sub-commands with one argument
  11. foreach (subcommand IN ITEMS LENGTH TOLOWER TOUPPER HEX MAKE_C_IDENTIFIER)
  12. check_string_syntax (${subcommand} unexpected-arg "-DSTRING_ARGUMENTS=${subcommand},ARG1,ARG2")
  13. endforeach()
  14. ### sub-commands with two arguments
  15. foreach (subcommand IN ITEMS HASH STRIP QUOTE)
  16. check_string_syntax (${subcommand} unexpected-arg "-DSTRING_ARGUMENTS=${subcommand},ARG1,ARG2,ARG3")
  17. endforeach()
  18. ### sub-commands with three arguments
  19. foreach (subcommand IN ITEMS SUBSTRING)
  20. check_string_syntax (${subcommand} unexpected-arg "-DSTRING_ARGUMENTS=${subcommand},ARG1,ARG2,ARG3,ARG4")
  21. endforeach()
  22. foreach (subcommand IN ITEMS FIND MATCH RANDOM)
  23. check_string_syntax (${subcommand} unexpected-arg2 "-DSTRING_ARGUMENTS=${subcommand},ARG1,ARG2,ARG3,ARG4")
  24. endforeach()
  25. ### sub-commands with four arguments
  26. foreach (subcommand IN ITEMS REPLACE)
  27. check_string_syntax (${subcommand} unexpected-arg2 "-DSTRING_ARGUMENTS=${subcommand},ARG1,ARG2,ARG3,ARG4,ARG5")
  28. endforeach()
  29. run_cmake(SUBSTRING-WrongArguments)
  30. run_cmake(FIND-WrongArguments)
  31. run_cmake(MATCH-WrongArguments)
  32. run_cmaKE(ASCII-WrongArguments)
  33. run_cmake(TIMESTAMP-WrongArguments)
  34. run_cmake(RANDOM-WrongArguments)
  35. run_cmake(UUID-WrongArguments)
  36. run_cmake(REPLACE-WrongArguments)
  37. run_cmake(STRIP-WrongArguments)
  38. run_cmake(QUOTE-WrongArguments)
  39. run_cmake(HASH-WrongArguments)
  40. function(check_string_execution name)
  41. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
  42. if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
  43. set(CONFIG_OPTION -DCMAKE_CONFIGURATION_TYPES=Debug)
  44. else()
  45. set(CONFIG_OPTION -DCMAKE_BUILD_TYPE=Debug)
  46. endif()
  47. set(RunCMake_TEST_NO_CLEAN 1)
  48. set(RunCMake_TEST_VARIANT_DESCRIPTION " - ${name}")
  49. run_cmake_with_options(generate -DSTRING_TEST=${name} ${CONFIG_OPTION})
  50. run_cmake_command(check "${CMAKE_COMMAND}" "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}" -P "${RunCMake_TEST_BINARY_DIR}/${name}.cmake")
  51. endfunction()
  52. check_string_execution (LENGTH)
  53. check_string_execution (SUBSTRING)
  54. check_string_execution (FIND)
  55. check_string_execution (MATCH)
  56. check_string_execution (JOIN)
  57. check_string_execution (ASCII)
  58. check_string_execution (TIMESTAMP)
  59. check_string_execution (RANDOM)
  60. check_string_execution (UUID)
  61. check_string_execution (REPLACE)
  62. check_string_execution (APPEND)
  63. check_string_execution (PREPEND)
  64. check_string_execution (TOLOWER)
  65. check_string_execution (TOUPPER)
  66. check_string_execution (STRIP)
  67. check_string_execution (QUOTE)
  68. check_string_execution (HEX)
  69. check_string_execution (HASH)