From f74a8405b6caa8ac253ce0357642a244ab192410 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 14:36:58 +0100 Subject: Test error cases in find_dependency. --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/find_dependency/CMakeLists.txt | 4 ++++ Tests/RunCMake/find_dependency/EXACT-no-version-result.txt | 1 + Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt | 6 ++++++ Tests/RunCMake/find_dependency/EXACT-no-version.cmake | 4 ++++ Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake | 2 ++ Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake | 11 +++++++++++ Tests/RunCMake/find_dependency/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/find_dependency/extra-args-result.txt | 1 + Tests/RunCMake/find_dependency/extra-args-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/extra-args.cmake | 4 ++++ Tests/RunCMake/find_dependency/invalid-arg-3-result.txt | 1 + Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/invalid-arg-3.cmake | 4 ++++ 14 files changed, 54 insertions(+) create mode 100644 Tests/RunCMake/find_dependency/CMakeLists.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-result.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version.cmake create mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake create mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake create mode 100644 Tests/RunCMake/find_dependency/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/find_dependency/extra-args-result.txt create mode 100644 Tests/RunCMake/find_dependency/extra-args-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/extra-args.cmake create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-result.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d401a93..499d12b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -49,6 +49,7 @@ add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(find_dependency) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) set(SKIP_VISIBILITY 0) diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt new file mode 100644 index 0000000..04d09f2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt new file mode 100644 index 0000000..6f4fc04 --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:35 \(message\): + Invalid arguments to find_dependency. EXACT may only be specified if a + VERSION is specified +Call Stack \(most recent call first\): + EXACT-no-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake new file mode 100644 index 0000000..b05665b7 --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 EXACT) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..7d55ef6 --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake @@ -0,0 +1,2 @@ + +add_library(Pack1::Lib INTERFACE IMPORTED) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake new file mode 100644 index 0000000..b85104a --- /dev/null +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(EXACT-no-version) +run_cmake(invalid-arg-3) +run_cmake(extra-args) diff --git a/Tests/RunCMake/find_dependency/extra-args-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt new file mode 100644 index 0000000..1b52380 --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:47 \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + extra-args.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake new file mode 100644 index 0000000..209645a --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt new file mode 100644 index 0000000..c36148f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:42 \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + invalid-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake new file mode 100644 index 0000000..40ede07 --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACTYPO) -- cgit v0.12