summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GenEx-PATH/RunCMakeTest.cmake
blob: a93777a29c539850f6d0161e55f8148712cab21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

include(RunCMake)

run_cmake(no-arguments)
run_cmake(bad-option)

function(check_path_syntax name test)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-${test}-build)
  set(RunCMake_TEST_VARIANT_DESCRIPTION " - ${name}")
  run_cmake_with_options(${test} ${ARGN})
endfunction()

## Unexpected arguments
### sub-commands with one argument
foreach (subcommand IN ITEMS GET_ROOT_NAME GET_ROOT_DIRECTORY GET_ROOT_PATH GET_FILENAME
                             GET_EXTENSION GET_STEM GET_RELATIVE_PART GET_PARENT_PATH
                             HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH HAS_FILENAME
                             HAS_EXTENSION HAS_STEM HAS_RELATIVE_PART HAS_PARENT_PATH
                             IS_ABSOLUTE IS_RELATIVE CMAKE_PATH REMOVE_FILENAME REMOVE_EXTENSION
                             NORMAL_PATH)
  check_path_syntax (${subcommand} unexpected-arg "-DPATH_ARGUMENTS=${subcommand},ARG1,ARG2")
endforeach()
foreach (subcommand IN ITEMS GET_EXTENSION GET_STEM REMOVE_EXTENSION)
  if (subcommand STREQUAL "REMOVE_EXTENSION")
    set(RunCMake-stderr-file "unexpected-arg2-stderr.txt")
  endif()
  check_path_syntax ("${subcommand}[LAST_ONLY]" unexpected-arg "-DPATH_ARGUMENTS=${subcommand},LAST_ONLY,ARG1,ARG2")
  unset(RunCMake-stderr-file)
endforeach()
foreach (subcommand IN ITEMS CMAKE_PATH)
  check_path_syntax ("${subcommand}[NORMALIZE]" unexpected-arg "-DPATH_ARGUMENTS=${subcommand},NORMALIZE,ARG1,ARG2")
endforeach()

### sub-commands with two arguments
foreach (subcommand IN ITEMS IS_PREFIX REPLACE_FILENAME REPLACE_EXTENSION RELATIVE_PATH ABSOLUTE_PATH)
  check_path_syntax (${subcommand} unexpected-arg "-DPATH_ARGUMENTS=${subcommand},ARG1,ARG2,ARG3")
endforeach()
foreach (subcommand IN ITEMS IS_PREFIX ABSOLUTE_PATH)
  check_path_syntax ("${subcommand}[NORMALIZE]" unexpected-arg "-DPATH_ARGUMENTS=${subcommand},NORMALIZE,ARG1,ARG2,ARG3")
endforeach()
foreach (subcommand IN ITEMS REPLACE_EXTENSION)
  set(RunCMake-stderr-file "unexpected-arg2-stderr.txt")
  check_path_syntax ("${subcommand}[LAST_ONLY]" unexpected-arg "-DPATH_ARGUMENTS=${subcommand},LAST_ONLY,ARG1,ARG2,ARG3")
  unset(RunCMake-stderr-file)
endforeach()
unset (RunCMake-stderr-file)


function(check_path_execution name)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  set(RunCMake_TEST_VARIANT_DESCRIPTION " - ${name}")
  run_cmake_with_options(generate -DPATH_TEST=${name})
  run_cmake_command(check "${CMAKE_COMMAND}" "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}" -P "${RunCMake_TEST_BINARY_DIR}/${name}.cmake")
endfunction()

check_path_execution (GET_ITEM)
check_path_execution (HAS_ITEM)
check_path_execution (CMAKE_PATH)
check_path_execution (APPEND)
check_path_execution (REMOVE_ITEM)
check_path_execution (REPLACE_ITEM)
check_path_execution (NORMAL_PATH)
check_path_execution (RELATIVE_PATH)
check_path_execution (ABSOLUTE_PATH)
check_path_execution (IS_RELATIVE)
check_path_execution (IS_ABSOLUTE)
check_path_execution (IS_PREFIX)