diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-07-23 14:54:12 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-06 08:52:25 (GMT) |
commit | eb583b0a660ba68e8e3b5f820301fde333619283 (patch) | |
tree | d88a52fdc1af9843ee4adceb1a37c66148d48c2e /Tests/RunCMake/cmake_path | |
parent | 212e953d352c2ca20cf6280492633d21fbacdbc9 (diff) | |
download | CMake-eb583b0a660ba68e8e3b5f820301fde333619283.zip CMake-eb583b0a660ba68e8e3b5f820301fde333619283.tar.gz CMake-eb583b0a660ba68e8e3b5f820301fde333619283.tar.bz2 |
cmake_path command: path management
Fixes: #19568, #20922
Diffstat (limited to 'Tests/RunCMake/cmake_path')
178 files changed, 1689 insertions, 0 deletions
diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake new file mode 100644 index 0000000..4fd3c7d --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake @@ -0,0 +1,39 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f") +if (NOT path STREQUAL "/x/y/a/f/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/a/f/../../a/d'") +endif() + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE) +if (NOT path STREQUAL "/x/y/a/d") + list (APPEND errors "'${path}' instead of '/x/y/a/d'") +endif() + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE OUTPUT_VARIABLE output) +if (NOT path STREQUAL "../../a/d") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/x/y/a/d") + list (APPEND errors "'${output}' instead of '/x/y/a/d'") +endif() + +set (path "/a/d/../e") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f") +if (NOT path STREQUAL "/a/d/../e") + list (APPEND errors "'${path}' instead of '/a/d/../e'") +endif() + +set (path "/a/d/../e") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE) +if (NOT path STREQUAL "/a/e") + list (APPEND errors "'${path}' instead of '/a/e'") +endif() + + +check_errors (ABSOLUTE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt b/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND.cmake b/Tests/RunCMake/cmake_path/APPEND.cmake new file mode 100644 index 0000000..565b26d --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND.cmake @@ -0,0 +1,77 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path (APPEND path "/a/b" "c") +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "'${path}' instead of '/a/b/c'") +endif() + +set (path "/a/b") +cmake_path (APPEND path "c") +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "'${path}' instead of '/a/b/c'") +endif() + +cmake_path (APPEND path "x/y" "z" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/b/c/x/y/z") + list (APPEND errors "'${output}' instead of '/a/b/c/x/y/z'") +endif() + +set (path "a") +cmake_path (APPEND path "") +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +cmake_path (APPEND path "/b") +if (NOT path STREQUAL "/b") + list (APPEND errors "'${path}' instead of '/b'") +endif() + +if (WIN32) + set (path "a") + cmake_path (APPEND path "c:/b") + if (NOT path STREQUAL "c:/b") + list (APPEND errors "'${path}' instead of 'c:/b'") + endif() + + set (path "a") + cmake_path (APPEND path "c:") + if (NOT path STREQUAL "c:") + list (APPEND errors "'${path}' instead of 'c:'") + endif() + cmake_path (APPEND path "") + if (NOT path STREQUAL "c:") + list (APPEND errors "'${path}' instead of 'c:'") + endif() + + set (path "c:a") + cmake_path (APPEND path "/b") + if (NOT path STREQUAL "c:/b") + list (APPEND errors "'${path}' instead of 'c:/b'") + endif() + + set (path "c:a") + cmake_path (APPEND path "c:b") + if (NOT path STREQUAL "c:a/b") + list (APPEND errors "'${path}' instead of 'c:a/b'") + endif() + + set (path "//host") + cmake_path (APPEND path "b") + if (NOT path STREQUAL "//host/b") + list (APPEND errors "'${path}' instead of '//host/b'") + endif() + + set (path "//host/") + cmake_path (APPEND path "b") + if (NOT path STREQUAL "//host/b") + list (APPEND errors "'${path}' instead of '//host/b'") + endif() +endif() + +check_errors (APPEND ${errors}) diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake b/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake new file mode 100644 index 0000000..b9320f3 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake @@ -0,0 +1,43 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path(CMAKE_PATH path "/x/y/z/../../a/d") +if (NOT path STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") +endif() +cmake_path(CMAKE_PATH path NORMALIZE "/x/y/z/../../a/d") +if (NOT path STREQUAL "/x/a/d") + list (APPEND errors "'${path}' instead of '/x/a/d'") +endif() + +if (WIN32) + cmake_path(CMAKE_PATH path "/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "/x/a/d") + list (APPEND errors "'${path}' instead of '/x/a/d'") + endif() + + cmake_path(CMAKE_PATH path "//?/c:/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "c:/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of 'c:/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "//?/c:/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "c:/x/a/d") + list (APPEND errors "'${path}' instead of 'c:/x/a/d'") + endif() + + cmake_path(CMAKE_PATH path "\\\\?\\UNC/host/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "//host/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '//host/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "//host/x/a/d") + list (APPEND errors "'${path}' instead of '//host/x/a/d'") + endif() +endif() + +check_errors (CMAKE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/CMakeLists.txt b/Tests/RunCMake/cmake_path/CMakeLists.txt new file mode 100644 index 0000000..1f195c6 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18...3.19) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt new file mode 100644 index 0000000..674d942 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at COMPARE-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path COMPARE called with an unknown comparison operator: FOO. diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake new file mode 100644 index 0000000..7da5d29 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake @@ -0,0 +1,3 @@ + +set (path "/a/b") +cmake_path(COMPARE path FOO "/other" output) diff --git a/Tests/RunCMake/cmake_path/COMPARE.cmake b/Tests/RunCMake/cmake_path/COMPARE.cmake new file mode 100644 index 0000000..bc6b9b4 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE.cmake @@ -0,0 +1,22 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a///b/c") +cmake_path(COMPARE path EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' not equal to 'a/b/c'") +endif() + +set (path "a/b/d/../c") +cmake_path(COMPARE path NOT_EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' equal to 'a/b/c'") +endif() +cmake_path(NORMAL_PATH path) +cmake_path(COMPARE path EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' not equal to 'a/b/c'") +endif() + +check_errors (COMPARE ${errors}) diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt b/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT.cmake b/Tests/RunCMake/cmake_path/CONCAT.cmake new file mode 100644 index 0000000..62b5eb0 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT.cmake @@ -0,0 +1,20 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a/b") +cmake_path (CONCAT path "cd") +if (NOT path STREQUAL "/a/bcd") + list (APPEND errors "'${path}' instead of 'a/bcd'") +endif() + +set (path "/a/b") +cmake_path (CONCAT path "cd" "ef" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/bcdef") + list (APPEND errors "'${output}' instead of 'a/bcdef'") +endif() + +check_errors (CONCAT ${errors}) diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt new file mode 100644 index 0000000..9aa75ec --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at CONVERT-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path CONVERT called with an unknown action: FOO. diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake new file mode 100644 index 0000000..12ffccc --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake @@ -0,0 +1,2 @@ + +cmake_path(CONVERT "/a/b" FOO output) diff --git a/Tests/RunCMake/cmake_path/CONVERT.cmake b/Tests/RunCMake/cmake_path/CONVERT.cmake new file mode 100644 index 0000000..b08bc26 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT.cmake @@ -0,0 +1,110 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output) +if (NOT output STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'") +endif() +cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) +if (NOT output STREQUAL "/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'") +endif() + +if (WIN32) + cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'") + endif() + + cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "c:/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "c:/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/a/d'") + endif() + + cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "//host/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "//host/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/a/d'") + endif() +endif() + +if (WIN32) + cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d;c:/a/b/c/../d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d;c:/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d;c:/a/b/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;c:/a/b/d'") + endif() +else() + cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d;/a/b/c/../d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${outputh}' instead of '/x/y/z/../../a/d;/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d;/a/b/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;/a/b/d'") + endif() +endif() + + +if (WIN32) + cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "c:\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\b\\d'") + endif() + + cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d;c:\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d;c:\\a\\b\\d'") + endif() +else() + cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "/a//b/c/../d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a//b/c/../d'") + endif() + cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/a/b/d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a/b/d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d:/a/b/c/../d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d:/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d:/a/b/d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/a/d:/a/b/d'") + endif() +endif() + + +check_errors (CONVERT ${errors}) diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt new file mode 100644 index 0000000..71afc92 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at GET-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path GET called with an unknown action: FOO. diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake b/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake new file mode 100644 index 0000000..e09d6d7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake @@ -0,0 +1,3 @@ + +set (path "/a/b") +cmake_path(GET path FOO output) diff --git a/Tests/RunCMake/cmake_path/GET.cmake b/Tests/RunCMake/cmake_path/GET.cmake new file mode 100644 index 0000000..e68e654 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET.cmake @@ -0,0 +1,248 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +############################################### +## First test with a path defining all elements +############################################### +if (WIN32) + set (path "C:/aa/bb/cc.ext1.ext2") +else() + set (path "/aa/bb/cc.ext1.ext2") +endif() + +cmake_path(GET path ROOT_NAME output) +if (WIN32) + if (NOT output STREQUAL "C:") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") + endif() +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (WIN32) + if (NOT output STREQUAL "C:/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") + endif() +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "cc.ext1.ext2") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext1.ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext2") + list (APPEND errors "EXTENSION LAST_ONLY returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "cc") + list (APPEND errors "STEM returns bad data: ${output}") +endif() +cmake_path(GET path STEM LAST_ONLY output) +if (NOT output STREQUAL "cc.ext1") + list (APPEND errors "STEM LAST_ONLY returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL "aa/bb/cc.ext1.ext2") + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (WIN32) + if (NOT output STREQUAL "C:/aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "/aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") + endif() +endif() + +###################################### +## second, tests with missing elements +###################################### +set (path "aa/bb/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL path) + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (NOT output STREQUAL "aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") +endif() + +################################## +set (path "/aa/bb/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +################################### +set (path "/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL "") + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") +endif() + +################################### +set (path ".file") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +################################### +set (path ".file.ext") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file.ext") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +################################### +set (path ".file.ext1.ext2") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file.ext1.ext2") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext1.ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +check_errors (GET ${errors}) diff --git a/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH.cmake b/Tests/RunCMake/cmake_path/HASH.cmake new file mode 100644 index 0000000..dfcf2b2 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH.cmake @@ -0,0 +1,27 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path1 "a///b/c") +cmake_path(HASH path1 hash1) +set (path2 "a/b////c") +cmake_path(HASH path2 hash2) +if (NOT hash1 STREQUAL hash2) + list (APPEND errors "'hash values not equal for '${path1}' and '${path2}'") +endif() + +set (path1 "a///b/c/../d") +cmake_path(HASH path1 hash1) +set (path2 "a/b////d") +cmake_path(HASH path2 hash2) +if (hash1 STREQUAL hash2) + list (APPEND errors "'hash values equal for '${path1}' and '${path2}'") +endif() +cmake_path(HASH path1 hash1 NORMALIZE) +cmake_path(HASH path2 NORMALIZE hash2) +if (NOT hash1 STREQUAL hash2) + list (APPEND errors "'hash values not equal for '${path1}' and '${path2}'") +endif() + + +check_errors (HASH ${errors}) diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ITEM.cmake b/Tests/RunCMake/cmake_path/HAS_ITEM.cmake new file mode 100644 index 0000000..eb73bd5 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ITEM.cmake @@ -0,0 +1,232 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a/b") +cmake_path(HAS_ROOT_NAME path output) +if (output) + list (APPEND errors "ROOT_NAME: ${path} has root name") +endif() +cmake_path(HAS_ROOT_DIRECTORY path output) +if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") +endif() +cmake_path(HAS_ROOT_PATH path output) +if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") +endif() + +set (path "a/b") +cmake_path(HAS_ROOT_PATH path output) +if (output) + list (APPEND errors "ROOT_PATH: ${path} has root path") +endif() + +set (path "/a/b") +cmake_path(HAS_FILENAME path output) +if (NOT output) + list (APPEND errors "FILENAME: ${path} does not have filename") +endif() +set (path "a.b") +cmake_path(HAS_FILENAME path output) +if (NOT output) + list (APPEND errors "FILENAME: ${path} does not have filename") +endif() +set (path "/a/b/") +cmake_path(HAS_FILENAME path output) +if (output) + list (APPEND errors "FILENAME: ${path} has filename") +endif() +set (path "/") +cmake_path(HAS_FILENAME path output) +if (output) + list (APPEND errors "FILENAME: ${path} has filename") +endif() + +set (path "/a/b") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path "a.b") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path ".a") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path "/a/") +cmake_path(HAS_STEM path output) +if (output) + list (APPEND errors "STEM: ${path} has stem") +endif() +set (path "/") +cmake_path(HAS_STEM path output) +if (output) + list (APPEND errors "STEM: ${path} has stem") +endif() + +set (path "/a/b.c") +cmake_path(HAS_EXTENSION path output) +if (NOT output) + list (APPEND errors "EXTENSION: ${path} does not have extension") +endif() +set (path "b.c") +cmake_path(HAS_EXTENSION path output) +if (NOT output) + list (APPEND errors "EXTENSION: ${path} does not have extension") +endif() +set (path "/.a") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() +set (path "/a/") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() +set (path "/") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() + +set (path "/a/b") +cmake_path(HAS_RELATIVE_PATH path output) +if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") +endif() +set (path "/") +cmake_path(HAS_RELATIVE_PATH path output) +if (output) + list (APPEND errors "RELATIVE_PATH: ${path} has relative path") +endif() + +set (path "/a/b") +cmake_path(HAS_PARENT_PATH path output) +if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") +endif() +set (path "/") +cmake_path(HAS_PARENT_PATH path output) +if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") +endif() +set (path "a") +cmake_path(HAS_PARENT_PATH path output) +if (output) + list (APPEND errors "PARENT_PATH: ${path} has parent path") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "c:a/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (output) + list (APPEND errors "ROOT_DIRECTORY: ${path} has root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "//host/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "//host") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (output) + list (APPEND errors "ROOT_DIRECTORY: ${path} has root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "c:/a/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "c:a/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "//host/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "c:/a/b") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "c:/") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "c:") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "//host/") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "//host") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() +endif() + + +check_errors (HAS ${errors}) diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake b/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake new file mode 100644 index 0000000..794e786 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake @@ -0,0 +1,48 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a") +else() + set (path "/a") +endif() +cmake_path(IS_ABSOLUTE path output) +if (NOT output) + list (APPEND errors "'${path} is not absolute") +endif() + +set (path "a/b") +cmake_path(IS_ABSOLUTE path output) +if (output) + list (APPEND errors "'${path} is absolute") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(IS_ABSOLUTE path output) + if (NOT output) + list (APPEND errors "'${path} is not absolute") + endif() + + set (path "//host/b") + cmake_path(IS_ABSOLUTE path output) + if (NOT output) + list (APPEND errors "'${path} is not absolute") + endif() + + set (path "/a") + cmake_path(IS_ABSOLUTE path output) + if (output) + list (APPEND errors "'${path} is absolute") + endif() + + set (path "c:a") + cmake_path(IS_ABSOLUTE path output) + if (output) + list (APPEND errors "'${path} is absolute") + endif() +endif() + + +check_errors (IS_ABSOLUTE ${errors}) diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX.cmake b/Tests/RunCMake/cmake_path/IS_PREFIX.cmake new file mode 100644 index 0000000..53da93b --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX.cmake @@ -0,0 +1,22 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a///b/c") +cmake_path(IS_PREFIX path "a/b/c/d" output) +if (NOT output) + list (APPEND errors "'${path} is not prefix of 'a/b/c/d'") +endif() + +set (path "a///b/c/../d") +cmake_path(IS_PREFIX path "a/b/d/e" output) +if (output) + list (APPEND errors "'${path} is prefix of 'a/b/d/e'") +endif() +cmake_path(IS_PREFIX path "a/b/d/e" NORMALIZE output) +if (NOT output) + list (APPEND errors "'${path} is not prefix of 'a/b/d/e'") +endif() + + +check_errors (IS_PREFIX ${errors}) diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake b/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake new file mode 100644 index 0000000..ad12253 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake @@ -0,0 +1,48 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a") +else() + set (path "/a") +endif() +cmake_path(IS_RELATIVE path output) +if (output) + list (APPEND errors "'${path} is relative") +endif() + +set (path "a/b") +cmake_path(IS_RELATIVE path output) +if (NOT output) + list (APPEND errors "'${path} is not relative") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(IS_RELATIVE path output) + if (output) + list (APPEND errors "'${path} is relative") + endif() + + set (path "//host/b") + cmake_path(IS_RELATIVE path output) + if (output) + list (APPEND errors "'${path} is relative") + endif() + + set (path "/a") + cmake_path(IS_RELATIVE path output) + if (NOT output) + list (APPEND errors "'${path} is not relative") + endif() + + set (path "c:a") + cmake_path(IS_RELATIVE path output) + if (NOT output) + list (APPEND errors "'${path} is not relative") + endif() +endif() + + +check_errors (IS_RELATIVE ${errors}) diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake b/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake new file mode 100644 index 0000000..066c44d --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake @@ -0,0 +1,37 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a//b\\c/..\\d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "'${output}' instead of 'c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(NATIVE_PATH path output NORMALIZE) + if (NOT output STREQUAL "c:\\a\\b\\d") + list (APPEND errors "'${output}' instead of 'c:\\a\\b\\d'") + endif() + + set (path "//host/a//b\\c/..\\d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d") + list (APPEND errors "'${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(NATIVE_PATH path output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d") + list (APPEND errors "'${output}' instead of '\\\\host\\a\\b\\d'") + endif() +else() + set (path "/a//b/c/../d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "/a//b/c/../d") + list (APPEND errors "'${output}' instead of '/a//b/c/../d'") + endif() + cmake_path(NATIVE_PATH path NORMALIZE output) + if (NOT output STREQUAL "/a/b/d") + list (APPEND errors "'${output}' instead of '/a/b/d'") + endif() +endif() + +check_errors (NATIVE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake b/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake new file mode 100644 index 0000000..88db76a --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake @@ -0,0 +1,46 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/./b/..") +cmake_path(NORMAL_PATH path) +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +set (path "a/.///b/../") +cmake_path(NORMAL_PATH path) +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +set (path "a/.///b/../") +cmake_path(NORMAL_PATH path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/.///b/../") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/") + list (APPEND errors "'${output}' instead of 'a/'") +endif() + +if (WIN32) + set (path "//host/./b/..") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "//host/") + list (APPEND errors "'${path}' instead of '//host/'") + endif() + + set (path "//host/./b/../") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "//host/") + list (APPEND errors "'${path}' instead of '//host/'") + endif() + + set (path "c://a/.///b/../") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "c:/a/") + list (APPEND errors "'${path}' instead of 'c:/a/'") + endif() +endif() + +check_errors (NORMAL_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt b/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt new file mode 100644 index 0000000..e1d6592 --- /dev/null +++ b/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path OUTPUT_VARIABLE requires an argument. diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake new file mode 100644 index 0000000..ad23377 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake @@ -0,0 +1,41 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a/d") + cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "c:/a/d") + list (APPEND errors "'${path}' instead of 'c:/a/d'") + endif() +else() + set (path "/a/d") + cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "/a/d") + list (APPEND errors "'${path}' instead of '/a/d'") + endif() +endif() + +set (path "/a/d") +cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "/a/b/c" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/d") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "../../d") + list (APPEND errors "'${output}' instead of '../../d'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/a/d") +cmake_path(PROXIMATE_PATH path) +if (NOT path STREQUAL "a/d") + list (APPEND errors "'${path}' instead of 'a/d'") +endif() + +set (path "a/b/c") +cmake_path(PROXIMATE_PATH path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + + +check_errors (PROXIMATE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake new file mode 100644 index 0000000..522a899 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake @@ -0,0 +1,76 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a//d") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/b/c") +if (NOT path STREQUAL "../../d") + list (APPEND errors "'${path}' instead of '../../d'") +endif() + +set (path "/a//b///c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/d") +if (NOT path STREQUAL "../b/c") + list (APPEND errors "'${path}' instead of '../b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a") +if (NOT path STREQUAL "b/c") + list (APPEND errors "'${path}' instead of 'b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c/x/y") +if (NOT path STREQUAL "../..") + list (APPEND errors "'${path}' instead of '../..'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c") +if (NOT path STREQUAL ".") + list (APPEND errors "'${path}' instead of '.'") +endif() + +set (path "a/b") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "c/d") +if (NOT path STREQUAL "../../a/b") + list (APPEND errors "'${path}' instead of '../../a/b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path) +if (NOT path STREQUAL "../../b") + list (APPEND errors "'${path}' instead of '../../b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/../../b") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "../../b") + list (APPEND errors "'${output}' instead of '../../b'") +endif() + +if (WIN32) + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "/a/d") + list (APPEND errors "'${path}' instead of '/a/d'") + endif() + + set (path "c:/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +elseif() + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +endif() + +check_errors (RELATIVE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake new file mode 100644 index 0000000..ac06fde --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake @@ -0,0 +1,52 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e") + list (APPEND errors "'${path}' instead of 'a/b/c.e'") +endif() +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/c") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +set (path "a/b/c") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/.c") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/.c") + list (APPEND errors "'${path}' instead of 'a/b/.c'") +endif() +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/.c") + list (APPEND errors "'${path}' instead of 'a/b/.c'") +endif() + +set (path "a/b/.") +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/.") + list (APPEND errors "'${path}' instead of 'a/b/.'") +endif() + +check_errors (REMOVE_EXTENSION ${errors}) diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake b/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake new file mode 100644 index 0000000..385dcd0 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake @@ -0,0 +1,25 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REMOVE_FILENAME path) +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +cmake_path (REMOVE_FILENAME path) +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_FILENAME path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +check_errors (REMOVE_FILENAME ${errors}) diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake new file mode 100644 index 0000000..45c1575 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake @@ -0,0 +1,58 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "a/b/c.x") + list (APPEND errors "'${path}' instead of 'a/b/c.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".y") +if (NOT path STREQUAL "a/b/c.y") + list (APPEND errors "'${path}' instead of 'a/b/c.y'") +endif() +cmake_path (REPLACE_EXTENSION path "") +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e.x") + list (APPEND errors "'${path}' instead of 'a/b/c.e.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".y" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e.y") + list (APPEND errors "'${path}' instead of 'a/b/c.e.y'") +endif() +cmake_path (REPLACE_EXTENSION path "" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e") + list (APPEND errors "'${path}' instead of 'a/b/c.e'") +endif() + +set (path "/a/.b") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "/a/.b.x") + list (APPEND errors "'${path}' instead of '/a/.b.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY) +if (NOT path STREQUAL "/a/.b.x") + list (APPEND errors "'${path}' instead of '/a/.b.x'") +endif() + +set (path "/a/b") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "/a/b.x") + list (APPEND errors "'${path}' instead of '/a/b.x'") +endif() + +set (path "/a/b/") +cmake_path (REPLACE_EXTENSION path ".x" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b/") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/b/.x") + list (APPEND errors "'${output}' instead of '/a/b/.x'") +endif() + +check_errors (REPLACE_EXTENSION ${errors}) diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake b/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake new file mode 100644 index 0000000..f7a9600 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake @@ -0,0 +1,26 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REPLACE_FILENAME path "x.y") +if (NOT path STREQUAL "a/b/x.y") + list (APPEND errors "'${path}' instead of 'a/b/x.y'") +endif() + +set (path "a/b/") +cmake_path (REPLACE_FILENAME path "x.y") +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REPLACE_FILENAME path "" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +check_errors (REPLACE_FILENAME ${errors}) diff --git a/Tests/RunCMake/cmake_path/RunCMakeTest.cmake b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake new file mode 100644 index 0000000..ca9cba6 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake @@ -0,0 +1,191 @@ +include(RunCMake) + +# Validate parsing arguments + +## input path is not a variable +set (RunCMake-stderr-file "wrong-path-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET wrong_path ${subcommand} output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE wrong_path ${subcommand} path2 output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} wrong_path" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} wrong_path ${extra_args} output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## missing output parameter +set (RunCMake-stderr-file "missing-output-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## OUTPUT_VARIABLE without argument +set (RunCMake-stderr-file "OUTPUT_VARIABLE-no-arg-stderr.txt") + +foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-OUTPUT_VARIABLE-no-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## Invalid output variable +set (RunCMake-stderr-file "invalid-output-var-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-OUTPUT_VARIABLE-invalid-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## Unexpected arguments +set (RunCMake-stderr-file "unexpected-arg-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + if (subcommand STREQUAL "EXTENSION" OR subcommand STREQUAL "STEM") + set (extra_args LAST_ONLY) + else() + unset (extra_args) + endif() + run_cmake_command (GET-${subcommand}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand} ${extra_args} unexpected output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand} output unexpected" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + if (command STREQUAL "REPLACE_FILENAME" OR command STREQUAL "REPLACE_EXTENSION") + set (extra_args input) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args} unexpected" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX + HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args input) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args} unexpected output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() +unset (RunCMake-stderr-file) + +run_cmake(GET-wrong-operator) +run_cmake(CONVERT-wrong-operator) +run_cmake(COMPARE-wrong-operator) + +set (RunCMake_TEST_OPTIONS "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}") + +run_cmake(GET) +run_cmake(APPEND) +run_cmake(CONCAT) +run_cmake(REMOVE_FILENAME) +run_cmake(REPLACE_FILENAME) +run_cmake(REMOVE_EXTENSION) +run_cmake(REPLACE_EXTENSION) +run_cmake(NORMAL_PATH) +run_cmake(RELATIVE_PATH) +run_cmake(PROXIMATE_PATH) +run_cmake(ABSOLUTE_PATH) +run_cmake(CMAKE_PATH) +run_cmake(NATIVE_PATH) +run_cmake(CONVERT) +run_cmake(COMPARE) +run_cmake(HAS_ITEM) +run_cmake(IS_ABSOLUTE) +run_cmake(IS_RELATIVE) +run_cmake(IS_PREFIX) +run_cmake(HASH) diff --git a/Tests/RunCMake/cmake_path/call-cmake_path.cmake b/Tests/RunCMake/cmake_path/call-cmake_path.cmake new file mode 100644 index 0000000..70fd6f5 --- /dev/null +++ b/Tests/RunCMake/cmake_path/call-cmake_path.cmake @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 3.18...3.19) + +# define input variable +set (path "") + +separate_arguments(CMAKE_PATH_ARGUMENTS UNIX_COMMAND "${CMAKE_PATH_ARGUMENTS}") + +if (CHECK_INVALID_OUTPUT) + # special handling for CMAKE_PATH + list(GET CMAKE_PATH_ARGUMENTS 0 command) + if (command STREQUAL "CMAKE_PATH") + cmake_path(CMAKE_PATH "" "input") + else() + cmake_path(${CMAKE_PATH_ARGUMENTS} "") + endif() +else() + cmake_path(${CMAKE_PATH_ARGUMENTS}) +endif() diff --git a/Tests/RunCMake/cmake_path/check_errors.cmake b/Tests/RunCMake/cmake_path/check_errors.cmake new file mode 100644 index 0000000..d136971 --- /dev/null +++ b/Tests/RunCMake/cmake_path/check_errors.cmake @@ -0,0 +1,12 @@ + +function (CHECK_ERRORS command) + set (errors ${ARGN}) + if (errors) + string (LENGTH "${command}" length) + math (EXPR count "${length} + 2") + string (REPEAT " " ${count} shift) + list (TRANSFORM errors PREPEND "${shift}") + list (JOIN errors "\n" msg) + message (FATAL_ERROR "${command}: ${msg}") + endif() +endfunction() diff --git a/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt b/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt new file mode 100644 index 0000000..32a8948 --- /dev/null +++ b/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path Invalid name for output variable. diff --git a/Tests/RunCMake/cmake_path/missing-output-stderr.txt b/Tests/RunCMake/cmake_path/missing-output-stderr.txt new file mode 100644 index 0000000..8ac049b --- /dev/null +++ b/Tests/RunCMake/cmake_path/missing-output-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path [A-Z_]+ must be called with ((at least )?(two|three|four)|two or three|three or four) arguments. diff --git a/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt b/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt new file mode 100644 index 0000000..8f0e2f2 --- /dev/null +++ b/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path [A-Z_]+ (called with unexpected|must be called with two) arguments. diff --git a/Tests/RunCMake/cmake_path/wrong-path-stderr.txt b/Tests/RunCMake/cmake_path/wrong-path-stderr.txt new file mode 100644 index 0000000..c42b5a2 --- /dev/null +++ b/Tests/RunCMake/cmake_path/wrong-path-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path undefined variable for input path. |