summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt44
-rw-r--r--Tests/Module/ExternalData/CMakeLists.txt5
-rw-r--r--Tests/Module/ExternalData/Data Space.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data1Check.cmake6
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CompilerChange/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt1
-rw-r--r--Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt5
-rw-r--r--Tests/RunCMake/CompilerChange/EmptyCompiler.cmake3
-rw-r--r--Tests/RunCMake/CompilerChange/FindCompiler.cmake2
-rw-r--r--Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerChange/FirstCompiler.cmake3
-rw-r--r--Tests/RunCMake/CompilerChange/RunCMakeTest.cmake58
-rw-r--r--Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt4
-rw-r--r--Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerChange/SecondCompiler.cmake3
-rwxr-xr-xTests/RunCMake/CompilerChange/cc.sh.in2
-rw-r--r--Tests/RunCMake/RunCMake.cmake8
18 files changed, 135 insertions, 21 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index f8e4afd..13c2aad 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -50,6 +50,26 @@ if(BUILD_TESTING)
set(TEST_CompileCommandOutput 1)
endif()
+ set(MAKE_IS_GNU )
+ if(${CMAKE_TEST_MAKEPROGRAM} MATCHES make)
+ execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version
+ RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
+ if("${res}" STREQUAL "0")
+ if("${out}" MATCHES "GNU")
+ set(MAKE_IS_GNU 1)
+ endif()
+ endif()
+ endif()
+
+ # some old versions of make simply cannot handle spaces in paths
+ if (MAKE_IS_GNU OR
+ "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
+ "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland")
+ set(MAKE_SUPPORTS_SPACES 1)
+ else()
+ set(MAKE_SUPPORTS_SPACES 0)
+ endif()
+
set(build_generator_args
--build-generator ${CMAKE_TEST_GENERATOR}
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
@@ -327,6 +347,7 @@ if(BUILD_TESTING)
--build-project ExternalDataTest
--build-noclean
--force-new-ctest-process
+ --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
--test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
@@ -384,7 +405,8 @@ if(BUILD_TESTING)
# mainly it tests that cmake doesn't crash when generating these project files.
if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop")
# check which generators we have
- exec_program(${CMAKE_CMAKE_COMMAND} ARGS --help OUTPUT_VARIABLE cmakeOutput )
+ execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
+ OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
# check for the Eclipse generator
if ("${cmakeOutput}" MATCHES Eclipse)
add_test(Simple_EclipseGenerator ${CMAKE_CTEST_COMMAND}
@@ -1237,24 +1259,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys")
endif()
- set(MAKE_IS_GNU )
- if(${CMAKE_TEST_MAKEPROGRAM} MATCHES make)
- exec_program(
- ${CMAKE_TEST_MAKEPROGRAM} ARGS no_such_target --version
- RETURN_VALUE res OUTPUT_VARIABLE out
- )
- if("${res}" EQUAL 0)
- if("${out}" MATCHES "GNU")
- set(MAKE_IS_GNU 1)
- endif()
- endif()
- endif()
- # only add this test on platforms that support it
- # some old versions of make simply cannot handle spaces in paths
- if (MAKE_IS_GNU OR
- "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland")
+ if(MAKE_SUPPORTS_SPACES)
add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
@@ -2397,7 +2403,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(TEST_CompileCommandOutput)
set(CompileCommandOutput_EXTRA_OPTIONS
- --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_IS_GNU})
+ --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
ADD_TEST_MACRO(CompileCommandOutput
"${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
endif()
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
index 607e9b9..a379dca 100644
--- a/Tests/Module/ExternalData/CMakeLists.txt
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -14,10 +14,15 @@ set(ExternalData_URL_TEMPLATES
set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData")
file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test
+if(MAKE_SUPPORTS_SPACES)
+ set(Data1CheckSpaces -D "DataSpace=DATA{Data Space.dat}")
+endif()
+
ExternalData_Add_Test(Data1
NAME Data1Check
COMMAND ${CMAKE_COMMAND}
-D Data=DATA{Data.dat}
+ ${Data1CheckSpaces}
-D SeriesA=DATA{SeriesA.dat,:}
-D SeriesB=DATA{SeriesB.dat,:}
-D SeriesC=DATA{SeriesC.dat,:}
diff --git a/Tests/Module/ExternalData/Data Space.dat.md5 b/Tests/Module/ExternalData/Data Space.dat.md5
new file mode 100644
index 0000000..70e39bd
--- /dev/null
+++ b/Tests/Module/ExternalData/Data Space.dat.md5
@@ -0,0 +1 @@
+8c018830e3efa5caf3c7415028335a57
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
index b99d7ae..f40b76c 100644
--- a/Tests/Module/ExternalData/Data1Check.cmake
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -2,6 +2,12 @@ file(STRINGS "${Data}" lines LIMIT_INPUT 1024)
if(NOT "x${lines}" STREQUAL "xInput file already transformed.")
message(SEND_ERROR "Input file:\n ${Data}\ndoes not have expected content, but [[${lines}]]")
endif()
+if(DEFINED DataSpace)
+ file(STRINGS "${DataSpace}" lines LIMIT_INPUT 1024)
+ if(NOT "x${lines}" STREQUAL "xInput file already transformed.")
+ message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
+ endif()
+endif()
set(SeriesAn1 "1\\.dat")
set(SeriesBn1 "_1\\.dat")
set(SeriesCn1 "\\.1\\.dat")
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 320ebcc..c55bb3a 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -52,6 +52,9 @@ if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3)
endif()
add_RunCMake_test(CMP0019)
+if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
+ add_RunCMake_test(CompilerChange)
+endif()
add_RunCMake_test(ExternalData)
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(GeneratorToolset)
diff --git a/Tests/RunCMake/CompilerChange/CMakeLists.txt b/Tests/RunCMake/CompilerChange/CMakeLists.txt
new file mode 100644
index 0000000..3b92518
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8)
+if(NOT RunCMake_TEST)
+ set(RunCMake_TEST "$ENV{RunCMake_TEST}") # needed when cache is deleted
+endif()
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt
new file mode 100644
index 0000000..4745b25
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt
@@ -0,0 +1,5 @@
+You have changed variables that require your cache to be deleted.
+Configure will be re-run and you may have to reset some variables.
+The following variables have changed:
+CMAKE_C_COMPILER= *(
+|$)
diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake
new file mode 100644
index 0000000..c87ec49
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
diff --git a/Tests/RunCMake/CompilerChange/FindCompiler.cmake b/Tests/RunCMake/CompilerChange/FindCompiler.cmake
new file mode 100644
index 0000000..297ab2f
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/FindCompiler.cmake
@@ -0,0 +1,2 @@
+enable_language(C)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt
new file mode 100644
index 0000000..17621b7
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt
@@ -0,0 +1 @@
+-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc1.sh"
diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler.cmake b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake
new file mode 100644
index 0000000..c87ec49
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
diff --git a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake
new file mode 100644
index 0000000..d383716
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake
@@ -0,0 +1,58 @@
+include(RunCMake)
+
+# Detect the compiler in use in the current environment.
+run_cmake(FindCompiler)
+include(${RunCMake_BINARY_DIR}/FindCompiler-build/cc.cmake)
+if(NOT CMAKE_C_COMPILER)
+ message(FATAL_ERROR "FindCompiler provided no compiler!")
+endif()
+if(NOT IS_ABSOLUTE "${CMAKE_C_COMPILER}")
+ message(FATAL_ERROR "FindCompiler provided non-absolute path \"${CMAKE_C_COMPILER}\"!")
+endif()
+if(NOT EXISTS "${CMAKE_C_COMPILER}")
+ message(FATAL_ERROR "FindCompiler provided non-existing path \"${CMAKE_C_COMPILER}\"!")
+endif()
+
+# Now that we have the full compiler path, hide CC.
+unset(ENV{CC})
+
+# Wrap around the real compiler so we can change the compiler
+# path without changing the underlying compiler.
+set(ccIn ${RunCMake_SOURCE_DIR}/cc.sh.in)
+set(cc1 ${RunCMake_BINARY_DIR}/cc1.sh)
+set(cc2 ${RunCMake_BINARY_DIR}/cc2.sh)
+set(cc3 CMAKE_C_COMPILER-NOTFOUND)
+configure_file(${ccIn} ${cc1} @ONLY IMMEDIATE)
+configure_file(${ccIn} ${cc2} @ONLY IMMEDIATE)
+
+# Use a single build tree for remaining tests without cleaning.
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+
+# Check build with compiler wrapper 1.
+set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc1})
+set(ENV{RunCMake_TEST} "FirstCompiler")
+run_cmake(FirstCompiler)
+include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
+if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc1}")
+ message(FATAL_ERROR "FirstCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc1}")
+endif()
+
+# Check rebuild with compiler wrapper 2.
+set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc2})
+set(ENV{RunCMake_TEST} "SecondCompiler")
+run_cmake(SecondCompiler)
+include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
+if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc2}")
+ message(FATAL_ERROR "SecondCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc2}")
+endif()
+
+# Check failure with an empty compiler string.
+set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=)
+set(ENV{RunCMake_TEST} "EmptyCompiler")
+run_cmake(EmptyCompiler)
+include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
+if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc3}")
+ message(FATAL_ERROR "Empty built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc3}")
+endif()
diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt b/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt
new file mode 100644
index 0000000..3a01c53
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt
@@ -0,0 +1,4 @@
+You have changed variables that require your cache to be deleted.
+Configure will be re-run and you may have to reset some variables.
+The following variables have changed:
+CMAKE_C_COMPILER=.*/Tests/RunCMake/CompilerChange/cc2.sh
diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt
new file mode 100644
index 0000000..26ca964
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt
@@ -0,0 +1 @@
+-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc2.sh"
diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler.cmake b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake
new file mode 100644
index 0000000..c87ec49
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
diff --git a/Tests/RunCMake/CompilerChange/cc.sh.in b/Tests/RunCMake/CompilerChange/cc.sh.in
new file mode 100755
index 0000000..1d400e6
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/cc.sh.in
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec "@CMAKE_C_COMPILER@" "$@"
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 40b98d4..00faa4c 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -26,8 +26,12 @@ function(run_cmake test)
endif()
endforeach()
set(RunCMake_TEST_SOURCE_DIR "${top_src}")
- set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build")
- file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ if(NOT RunCMake_TEST_BINARY_DIR)
+ set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build")
+ endif()
+ if(NOT RunCMake_TEST_NO_CLEAN)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ endif()
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")