From f17711c546304a5e62a06796e0124c64284bfb9a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 22 Feb 2013 08:44:13 -0500 Subject: FPHSA: Convert FOUND_VAR failure test to RunCMake Move the Tests/FPHSA_InvalidFOUND_VAR test case over to a new RunCMake.FPHSA test with a BadFoundVar case. The RunCMake tests are built to cover failure cases easily and robustly. --- Tests/CMakeLists.txt | 3 --- Tests/FPHSA_InvalidFOUND_VAR/CMakeLists.txt | 5 ----- Tests/FPHSA_InvalidFOUND_VAR/FindBadFoundVar.cmake | 6 ------ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/FPHSA/BadFoundVar-result.txt | 1 + Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt | 7 +++++++ Tests/RunCMake/FPHSA/BadFoundVar.cmake | 3 +++ Tests/RunCMake/FPHSA/CMakeLists.txt | 3 +++ Tests/RunCMake/FPHSA/FindBadFoundVar.cmake | 6 ++++++ Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 3 +++ 10 files changed, 24 insertions(+), 14 deletions(-) delete mode 100644 Tests/FPHSA_InvalidFOUND_VAR/CMakeLists.txt delete mode 100644 Tests/FPHSA_InvalidFOUND_VAR/FindBadFoundVar.cmake create mode 100644 Tests/RunCMake/FPHSA/BadFoundVar-result.txt create mode 100644 Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt create mode 100644 Tests/RunCMake/FPHSA/BadFoundVar.cmake create mode 100644 Tests/RunCMake/FPHSA/CMakeLists.txt create mode 100644 Tests/RunCMake/FPHSA/FindBadFoundVar.cmake create mode 100644 Tests/RunCMake/FPHSA/RunCMakeTest.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2725202..f8e4afd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -147,9 +147,6 @@ if(BUILD_TESTING) # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) ADD_TEST_MACRO(FindPackageTest FindPackageTest) - ADD_TEST_MACRO(FPHSA_InvalidFOUND_VAR FPHSA_InvalidFOUND_VAR) - set_tests_properties(FPHSA_InvalidFOUND_VAR PROPERTIES - PASS_REGULAR_EXPRESSION "The argument for FOUND_VAR is .badfoundvar_FOUND., but only") ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll) ADD_TEST_MACRO(StringFileTest StringFileTest) ADD_TEST_MACRO(TryCompile TryCompile) diff --git a/Tests/FPHSA_InvalidFOUND_VAR/CMakeLists.txt b/Tests/FPHSA_InvalidFOUND_VAR/CMakeLists.txt deleted file mode 100644 index 6a88cf5..0000000 --- a/Tests/FPHSA_InvalidFOUND_VAR/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") - -find_package(BadFoundVar REQUIRED) diff --git a/Tests/FPHSA_InvalidFOUND_VAR/FindBadFoundVar.cmake b/Tests/FPHSA_InvalidFOUND_VAR/FindBadFoundVar.cmake deleted file mode 100644 index 152df5c..0000000 --- a/Tests/FPHSA_InvalidFOUND_VAR/FindBadFoundVar.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(BFV_FOO TRUE) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(BadFoundVar REQUIRED_VARS BFV_FOO - FOUND_VAR badfoundvar_FOUND ) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c55bb3a..dba772d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -56,6 +56,7 @@ if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(ExternalData) +add_RunCMake_test(FPHSA) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) diff --git a/Tests/RunCMake/FPHSA/BadFoundVar-result.txt b/Tests/RunCMake/FPHSA/BadFoundVar-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/BadFoundVar-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt b/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt new file mode 100644 index 0000000..4c739d8 --- /dev/null +++ b/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + The argument for FOUND_VAR is "badfoundvar_FOUND", but only + "BadFoundVar_FOUND" and "BADFOUNDVAR_FOUND" are valid names. +Call Stack \(most recent call first\): + FindBadFoundVar.cmake:5 \(find_package_handle_standard_args\) + BadFoundVar.cmake:3 \(find_package\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/FPHSA/BadFoundVar.cmake b/Tests/RunCMake/FPHSA/BadFoundVar.cmake new file mode 100644 index 0000000..07d4322 --- /dev/null +++ b/Tests/RunCMake/FPHSA/BadFoundVar.cmake @@ -0,0 +1,3 @@ +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +find_package(BadFoundVar REQUIRED) diff --git a/Tests/RunCMake/FPHSA/CMakeLists.txt b/Tests/RunCMake/FPHSA/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/FPHSA/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FPHSA/FindBadFoundVar.cmake b/Tests/RunCMake/FPHSA/FindBadFoundVar.cmake new file mode 100644 index 0000000..152df5c --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindBadFoundVar.cmake @@ -0,0 +1,6 @@ +set(BFV_FOO TRUE) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(BadFoundVar REQUIRED_VARS BFV_FOO + FOUND_VAR badfoundvar_FOUND ) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake new file mode 100644 index 0000000..0d48fa9 --- /dev/null +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(BadFoundVar) -- cgit v0.12