From fd343a1a36c4f6ff62f67acfc5506fb2592858b3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 21 Sep 2010 10:23:09 -0400 Subject: Add a "Contract" test for VTK. The test downloads and builds VTK. The idea is that we can make sure that CMake is staying backwards compatible by testing projects against CMake as the changes are made in CMake. Because these tests will take a long time to run, they will not be enabled by default. Instead, they will be enabled by putting a cache variable into CMake. --- Tests/CMakeLists.txt | 11 ++++++++++- Tests/Contracts/vtk542/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Tests/Contracts/vtk542/CMakeLists.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5e88b5c..82ea48b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -11,7 +11,7 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project ${proj} - --test-command ${COMMAND}) + --test-command ${COMMAND} ${ARGN}) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) @@ -1757,6 +1757,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -D source_dir:STRING=${CMAKE_CURRENT_SOURCE_DIR}/Tutorial/Step3 -D CMAKE_CTEST_COMMAND:STRING=${CMAKE_CTEST_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeWizardTest.cmake) + # If the cache variable CMAKE_CONTRACT_PROJECTS is set + # then the dashboard will run a contract with CMake test of that + # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run + # the vtk542 contract test. + FOREACH(project ${CMAKE_CONTRACT_PROJECTS}) + ADD_TEST_MACRO(Contracts.${project} + VTK-build/bin/CommonCxxTests otherArrays) + SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT 5400) + ENDFOREACH() ENDIF(BUILD_TESTING) SUBDIRS(CMakeTests) diff --git a/Tests/Contracts/vtk542/CMakeLists.txt b/Tests/Contracts/vtk542/CMakeLists.txt new file mode 100644 index 0000000..cfb8b16 --- /dev/null +++ b/Tests/Contracts/vtk542/CMakeLists.txt @@ -0,0 +1,30 @@ +# The VTK external project for CMake +# --------------------------------------------------------------------------- +cmake_minimum_required(VERSION 2.8) +project(vtk542) +include(ExternalProject) + + +set(vtk_source "${CMAKE_CURRENT_BINARY_DIR}/VTK-source") +set(vtk_binary "${CMAKE_CURRENT_BINARY_DIR}/VTK-build") + +ExternalProject_Add(VTK + DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} + URL "http://www.vtk.org/files/release/5.4/vtk-5.4.2.tar.gz" + URL_MD5 c2c797091d4b2128d9a1bd32c4b78227 + SOURCE_DIR ${vtk_source} + BINARY_DIR ${vtk_binary} + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS + -DBUILD_EXAMPLES:BOOL=ON + -DBUILD_TESTING:BOOL=ON + INSTALL_COMMAND "" + ) +# make it so that each build will run make in the VTK build tree +ExternalProject_Add_Step(VTK forcebuild + COMMAND ${CMAKE_COMMAND} + -E remove ${CMAKE_CURRENT_BUILD_DIR}/VTK-prefix/src/VTK-stamp/VTK-build + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + ) -- cgit v0.12 From 942ace83935fdb3272e026f21c56a6682b78d6de Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 21 Sep 2010 15:08:13 -0400 Subject: Fix contract test so it is not hard coded to the vtk542 test. --- Tests/CMakeLists.txt | 10 +++++++++- Tests/Contracts/vtk542/RunTest.cmake | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Tests/Contracts/vtk542/RunTest.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 82ea48b..895cb2a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1761,9 +1761,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # then the dashboard will run a contract with CMake test of that # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run # the vtk542 contract test. + # For each Contract test, the project should provide a directory + # with at least one CMakeLists.txt file that uses ExternalProject + # to download and configure the project. The directory should also + # contain a RunTest.cmake file that has a single set of the format: + # SET(project_RUN_TEST testToRun) + # The testToRun should be a test executable that can be run to + # smoke test the build. FOREACH(project ${CMAKE_CONTRACT_PROJECTS}) + INCLUDE(Contracts/${project}/RunTest.cmake) ADD_TEST_MACRO(Contracts.${project} - VTK-build/bin/CommonCxxTests otherArrays) + ${${project}_RUN_TEST}) SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT 5400) ENDFOREACH() ENDIF(BUILD_TESTING) diff --git a/Tests/Contracts/vtk542/RunTest.cmake b/Tests/Contracts/vtk542/RunTest.cmake new file mode 100644 index 0000000..4f48e5c --- /dev/null +++ b/Tests/Contracts/vtk542/RunTest.cmake @@ -0,0 +1 @@ +SET(vtk542_RUN_TEST VTK-build/bin/CommonCxxTests otherArrays) -- cgit v0.12 From c81ad34e85fcc18fe8095b01e3b06d2cf1005155 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 8 Oct 2010 15:09:24 -0400 Subject: Add a contract test for building the CSE. To activate the CSE contract test on a given Linux machine's CMake dashboard, put CMAKE_CONTRACT_PROJECTS:STRING=cse-snapshot in the CMake dashboard's initial cache. The chosen snapshot does not generate subproject dependency info right now. That code was in a previous revision in the CSE's svn repo that apparently has not been merged into the present cse git repository master branch. After that is fixed up in the cse repo, we can update the tag here so that the snapshot built here can run a sub-project based dashboard script. For now, it runs as one big build step, building 'all'. --- Tests/CMakeLists.txt | 6 +- Tests/Contracts/cse-snapshot/CMakeLists.txt | 100 ++++++++++++++++++++++++ Tests/Contracts/cse-snapshot/Dashboard.cmake.in | 76 ++++++++++++++++++ Tests/Contracts/cse-snapshot/RunTest.cmake | 3 + 4 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 Tests/Contracts/cse-snapshot/CMakeLists.txt create mode 100644 Tests/Contracts/cse-snapshot/Dashboard.cmake.in create mode 100644 Tests/Contracts/cse-snapshot/RunTest.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 895cb2a..ed12c65 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -21,7 +21,11 @@ IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) FILE(MAKE_DIRECTORY "${TEST_HOME}") FILE(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. -SET(ENV{HOME} \"${TEST_HOME}\")") +# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that +# need access to the real HOME directory. +SET(ENV{CTEST_REAL_HOME} \"$ENV{HOME}\") +SET(ENV{HOME} \"${TEST_HOME}\") +") ENDIF() # Choose a default configuration for CTest tests. diff --git a/Tests/Contracts/cse-snapshot/CMakeLists.txt b/Tests/Contracts/cse-snapshot/CMakeLists.txt new file mode 100644 index 0000000..a2f5e9c --- /dev/null +++ b/Tests/Contracts/cse-snapshot/CMakeLists.txt @@ -0,0 +1,100 @@ +cmake_minimum_required(VERSION 2.8) +project(cse-snapshot) + +include(ExternalProject) + +include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL) +include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL) + +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() +endif() + +set(tag "510345e4360ac3b07ddb29e527207297f7cc6d89") +string(SUBSTRING "${tag}" 0 8 shorttag) + +set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}") +set(binary_dir "${base_dir}/build") +set(script_dir "${base_dir}") +set(source_dir "${base_dir}/src") + +if(NOT DEFINED BUILDNAME) + set(BUILDNAME "CMakeContract-${shorttag}") +endif() + +if(NOT DEFINED SITE) + site_name(SITE) +endif() + +if(NOT DEFINED PROCESSOR_COUNT) + # Unknown: + set(PROCESSOR_COUNT 0) + + # Linux: + set(cpuinfo_file "/proc/cpuinfo") + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs PROCESSOR_COUNT) + endif() + + # Mac: + if(APPLE) + find_program(cmd_sysctl "sysctl") + if(cmd_sysctl) + execute_process(COMMAND ${cmd_sysctl} -n hw.ncpu + OUTPUT_VARIABLE PROCESSOR_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + endif() + + # Windows: + if(WIN32) + set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}") + endif() +endif() + +find_package(Git) +if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "error: could not find git") + # adjust PATH to find git, or set GIT_EXECUTABLE in LocalOverrides.cmake +endif() + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" + "${script_dir}/Dashboard.cmake" + @ONLY) + +# Source dir for this project exists outside the CMake build tree because it +# is absolutely huge. +# +if(EXISTS "${source_dir}/.git") + # If it exists already, download is a complete no-op: + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +else() + # If it does not yet exist, download clones the git repository: + ExternalProject_Add(download-${PROJECT_NAME} + SOURCE_DIR "${source_dir}" + GIT_REPOSITORY "git://public.kitware.com/cse.git" + GIT_TAG "${tag}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endif() + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_CTEST_COMMAND} -S "${script_dir}/Dashboard.cmake" + INSTALL_COMMAND "" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/Contracts/cse-snapshot/Dashboard.cmake.in b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in new file mode 100644 index 0000000..138eb3f --- /dev/null +++ b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in @@ -0,0 +1,76 @@ +# This "ctest -S" script may be configured to drive a nightly dashboard on any +# Linux machine. +# +set(CTEST_BINARY_DIRECTORY "@binary_dir@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_SITE "@SITE@") +set(CTEST_SOURCE_DIRECTORY "@source_dir@") +set(PROCESSOR_COUNT "@PROCESSOR_COUNT@") + +# Assume a Linux build, with a make that supports -j. Modify this script if +# assumption is ever invalid. +# +if(PROCESSOR_COUNT) + set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}") +endif() + +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'") +ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}") + +# Intentionally no ctest_update step in this script. This script is run as a +# "Contract" test on a CMake dashboard submission using the just-built ctest +# as the driver. The download step in the Contract CMakeLists file takes care +# of setting up the source tree before calling this ctest -S script. The idea +# is that the source tree will be the same every day, so there should not be +# an "update" step for this build. + +message("Configuring CSE in binary dir '${CTEST_BINARY_DIRECTORY}'") +set_property(GLOBAL PROPERTY SubProject "CSE-toplevel") +set_property(GLOBAL PROPERTY Label "CSE-toplevel") + +ctest_start("Experimental") + +set(CSE_TOPLEVEL_OPTIONS + -DEXTERNAL_PROJECT_DASHBOARD_BUILD:BOOL=ON + -DEXTERNAL_PROJECT_TESTS:BOOL=ON + -DCSE_INSTALL_PREFIX:PATH=${CTEST_BINARY_DIRECTORY}/built + -DCSE_SUBSET:STRING=ALL + -DCTEST_SITE:STRING=${CTEST_SITE} +) + +ctest_configure(OPTIONS "${CSE_TOPLEVEL_OPTIONS}") + +# The configure step produces a file listing the CSE packages and dependencies. +# This file also generates Project.xml and stores it in ${PROJECT_XML}. +# +set(subprojects "") +if(EXISTS "${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + message("Including CSEBuildtimeDepends.cmake") + include("${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + set(subprojects ${CSE_ALL_SORTED}) + message("Submitting Project.xml") + ctest_submit(FILES ${PROJECT_XML}) +endif() + +message("Submitting CSE configure results") +ctest_submit() + +if(subprojects) + message("Building by looping over subprojects...") + foreach(subproject ${subprojects}) + message("########## ${subproject} ##########") + set_property(GLOBAL PROPERTY SubProject "${subproject}") + set_property(GLOBAL PROPERTY Label "${subproject}") + ctest_build(TARGET "${subproject}" APPEND) + message("Submitting ${subproject} build results") + ctest_submit(PARTS build) + endforeach() +else() + message("Building all...") + ctest_build(APPEND) + message("Submitting build results") + ctest_submit(PARTS build) +endif() diff --git a/Tests/Contracts/cse-snapshot/RunTest.cmake b/Tests/Contracts/cse-snapshot/RunTest.cmake new file mode 100644 index 0000000..7eb6301 --- /dev/null +++ b/Tests/Contracts/cse-snapshot/RunTest.cmake @@ -0,0 +1,3 @@ +set(exe "$ENV{HOME}/.cmake/Contracts/cse-snapshot/510345e4/build/built/Release/git-1.6.5.2/bin/git") +set(args help clone) +set(cse-snapshot_RUN_TEST ${exe} ${args}) -- cgit v0.12 From 1e4fd5fc9cf294400a2d6b07a02368da942187bc Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 22 Oct 2010 14:31:36 -0400 Subject: Enable overriding contract test timeout values. Use a longer value as the default timeout (6 hours). For a per-contract-test timeout value, set ${project}_TEST_TIMEOUT in the project's RunTest.cmake file. To use a longer value for all non-specific contract tests, set a CMake cache variable named CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT. All timeout values are in seconds. Also, patch up last commit to defer evaluation of ENV{HOME} until EnforceConfig.cmake is included at ctest time. This allows Windows machines to have "\\" characters in the HOME environment variable if they want to. --- Tests/CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ed12c65..5155858 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -23,7 +23,7 @@ IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that # need access to the real HOME directory. -SET(ENV{CTEST_REAL_HOME} \"$ENV{HOME}\") +SET(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\") SET(ENV{HOME} \"${TEST_HOME}\") ") ENDIF() @@ -1776,7 +1776,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ INCLUDE(Contracts/${project}/RunTest.cmake) ADD_TEST_MACRO(Contracts.${project} ${${project}_RUN_TEST}) - SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT 5400) + # Contract test timeout in seconds. + # Default to 6 hours. + IF(DEFINED ${project}_TEST_TIMEOUT) + SET(timeout ${${project}_TEST_TIMEOUT}) + ELSEIF(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT) + SET(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT}) + ELSE() + SET(timeout 21600) + ENDIF() + SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT ${timeout}) ENDFOREACH() ENDIF(BUILD_TESTING) -- cgit v0.12 From f6f3ae5bcd3d560947cfde1c578c42dd979d0c47 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 28 Oct 2010 14:41:30 -0400 Subject: Update tag in the Contracts/cse-snapshot test. Also: - allow local variables 'repo' and 'tag' to be overridden by the optional LocalOverrides.cmake - print out STATUS messages to see the variable values in CMake configure output --- Tests/Contracts/cse-snapshot/CMakeLists.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Tests/Contracts/cse-snapshot/CMakeLists.txt b/Tests/Contracts/cse-snapshot/CMakeLists.txt index a2f5e9c..9134210 100644 --- a/Tests/Contracts/cse-snapshot/CMakeLists.txt +++ b/Tests/Contracts/cse-snapshot/CMakeLists.txt @@ -13,8 +13,18 @@ if(NOT DEFINED HOME) set(HOME "$ENV{HOME}") endif() endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED repo) + set(repo "git://public.kitware.com/cse.git") +endif() +message(STATUS "repo='${repo}'") + +if(NOT DEFINED tag) + set(tag "cc1dcb95439a21ab1d58f444d93481598414196e") +endif() +message(STATUS "tag='${tag}'") -set(tag "510345e4360ac3b07ddb29e527207297f7cc6d89") string(SUBSTRING "${tag}" 0 8 shorttag) set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}") @@ -25,10 +35,12 @@ set(source_dir "${base_dir}/src") if(NOT DEFINED BUILDNAME) set(BUILDNAME "CMakeContract-${shorttag}") endif() +message(STATUS "BUILDNAME='${BUILDNAME}'") if(NOT DEFINED SITE) site_name(SITE) endif() +message(STATUS "SITE='${SITE}'") if(NOT DEFINED PROCESSOR_COUNT) # Unknown: @@ -56,12 +68,14 @@ if(NOT DEFINED PROCESSOR_COUNT) set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}") endif() endif() +message(STATUS "PROCESSOR_COUNT='${PROCESSOR_COUNT}'") find_package(Git) if(NOT GIT_EXECUTABLE) message(FATAL_ERROR "error: could not find git") # adjust PATH to find git, or set GIT_EXECUTABLE in LocalOverrides.cmake endif() +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" @@ -83,7 +97,7 @@ else() # If it does not yet exist, download clones the git repository: ExternalProject_Add(download-${PROJECT_NAME} SOURCE_DIR "${source_dir}" - GIT_REPOSITORY "git://public.kitware.com/cse.git" + GIT_REPOSITORY "${repo}" GIT_TAG "${tag}" CONFIGURE_COMMAND "" BUILD_COMMAND "" -- cgit v0.12