From c869984ea013f99c3104abaf17d553b08c4b17c2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 23:53:52 +0200 Subject: RunCMake: Allow specifying the source dir and file to test. This will allow decoupling the name of the test from the name and location of the source file under test, which means one source file can be used for multiple tests. Rename the PARENT_SCOPE test in RunCMake.set to not use a keyword of the if() command as a file name. As the filename is now used with an if condition, this causes a conflict. --- Tests/RunCMake/RunCMake.cmake | 9 ++++++-- Tests/RunCMake/set/PARENT_SCOPE-result.txt | 1 - Tests/RunCMake/set/PARENT_SCOPE.cmake | 33 ------------------------------ Tests/RunCMake/set/ParentScope-result.txt | 1 + Tests/RunCMake/set/ParentScope.cmake | 33 ++++++++++++++++++++++++++++++ Tests/RunCMake/set/RunCMakeTest.cmake | 2 +- 6 files changed, 42 insertions(+), 37 deletions(-) delete mode 100644 Tests/RunCMake/set/PARENT_SCOPE-result.txt delete mode 100644 Tests/RunCMake/set/PARENT_SCOPE.cmake create mode 100644 Tests/RunCMake/set/ParentScope-result.txt create mode 100644 Tests/RunCMake/set/ParentScope.cmake diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index ed3afc5..4ed2f43 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -25,7 +25,9 @@ function(run_cmake test) unset(expect_std${o}) endif() endforeach() - set(RunCMake_TEST_SOURCE_DIR "${top_src}") + if (NOT RunCMake_TEST_SOURCE_DIR) + set(RunCMake_TEST_SOURCE_DIR "${top_src}") + endif() if(NOT RunCMake_TEST_BINARY_DIR) set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") endif() @@ -36,6 +38,9 @@ function(run_cmake test) if(NOT DEFINED RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS "") endif() + if (NOT RunCMake_TEST_FILE) + set(RunCMake_TEST_FILE "${test}") + endif() if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() @@ -52,7 +57,7 @@ function(run_cmake test) COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" -G "${RunCMake_GENERATOR}" -T "${RunCMake_GENERATOR_TOOLSET}" - -DRunCMake_TEST=${test} + -DRunCMake_TEST=${RunCMake_TEST_FILE} --no-warn-unused-cli ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/set/PARENT_SCOPE-result.txt deleted file mode 100644 index 573541a..0000000 --- a/Tests/RunCMake/set/PARENT_SCOPE-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/set/PARENT_SCOPE.cmake b/Tests/RunCMake/set/PARENT_SCOPE.cmake deleted file mode 100644 index 9bd6bca..0000000 --- a/Tests/RunCMake/set/PARENT_SCOPE.cmake +++ /dev/null @@ -1,33 +0,0 @@ -set(FOO ) -set(BAR "bar") -set(BAZ "baz") -set(BOO "boo") - -function(_parent_scope) - set(FOO "foo" PARENT_SCOPE) - set(BAR "" PARENT_SCOPE) - set(BAZ PARENT_SCOPE) - unset(BOO PARENT_SCOPE) -endfunction() - -_parent_scope() - -if(NOT DEFINED FOO) - message(FATAL_ERROR "FOO not defined") -elseif(NOT "${FOO}" STREQUAL "foo") - message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"") -endif() - -if(NOT DEFINED BAR) - message(FATAL_ERROR "BAR not defined") -elseif(NOT "${BAR}" STREQUAL "") - message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"") -endif() - -if(DEFINED BAZ) - message(FATAL_ERROR "BAZ defined") -endif() - -if(DEFINED BOO) - message(FATAL_ERROR "BOO defined") -endif() diff --git a/Tests/RunCMake/set/ParentScope-result.txt b/Tests/RunCMake/set/ParentScope-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/set/ParentScope-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/set/ParentScope.cmake b/Tests/RunCMake/set/ParentScope.cmake new file mode 100644 index 0000000..9bd6bca --- /dev/null +++ b/Tests/RunCMake/set/ParentScope.cmake @@ -0,0 +1,33 @@ +set(FOO ) +set(BAR "bar") +set(BAZ "baz") +set(BOO "boo") + +function(_parent_scope) + set(FOO "foo" PARENT_SCOPE) + set(BAR "" PARENT_SCOPE) + set(BAZ PARENT_SCOPE) + unset(BOO PARENT_SCOPE) +endfunction() + +_parent_scope() + +if(NOT DEFINED FOO) + message(FATAL_ERROR "FOO not defined") +elseif(NOT "${FOO}" STREQUAL "foo") + message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"") +endif() + +if(NOT DEFINED BAR) + message(FATAL_ERROR "BAR not defined") +elseif(NOT "${BAR}" STREQUAL "") + message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"") +endif() + +if(DEFINED BAZ) + message(FATAL_ERROR "BAZ defined") +endif() + +if(DEFINED BOO) + message(FATAL_ERROR "BOO defined") +endif() diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake index 5d036e3..1b51ea2 100644 --- a/Tests/RunCMake/set/RunCMakeTest.cmake +++ b/Tests/RunCMake/set/RunCMakeTest.cmake @@ -1,3 +1,3 @@ include(RunCMake) -run_cmake(PARENT_SCOPE) +run_cmake(ParentScope) -- cgit v0.12