diff options
author | David Cole <david.cole@kitware.com> | 2010-05-27 18:38:53 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2010-05-27 19:44:57 (GMT) |
commit | 1dd316563a7bd7dc97aeb3f9632f232bf7267e57 (patch) | |
tree | 0ffd4b28835123982c467a723a566331875ab0f9 /Tests/CMakeTests/CheckSourceTreeTest.cmake.in | |
parent | 282a119e355f86e20cc04fabd98083de2799c0ea (diff) | |
download | CMake-1dd316563a7bd7dc97aeb3f9632f232bf7267e57.zip CMake-1dd316563a7bd7dc97aeb3f9632f232bf7267e57.tar.gz CMake-1dd316563a7bd7dc97aeb3f9632f232bf7267e57.tar.bz2 |
Add git support to the CMake.CheckSourceTree test.
Additionally, output some more information in both cvs
and git cases. When it is a cvs checkout, echo the contents
of CVS/Root and CVS/Repository to the test output. When it
is a git checkout, echo the output of 'git branch -a'.
This will allow us to see more details about any given CMake
source tree right in the CDash results for this test.
Diffstat (limited to 'Tests/CMakeTests/CheckSourceTreeTest.cmake.in')
-rw-r--r-- | Tests/CMakeTests/CheckSourceTreeTest.cmake.in | 201 |
1 files changed, 150 insertions, 51 deletions
diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index 1cfadcb..82207e4 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -6,6 +6,7 @@ message("") message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") +message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") message("HOME='${HOME}'") message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") message("") @@ -42,55 +43,138 @@ message("in_source_build='${in_source_build}'") message("") -# If this does not appear to be a CVS checkout, just pass the test here and now. -# (Do not let the test fail if it is run in a tree *exported* from CVS or -# unpacked from a .zip file source installer...) +# If this does not appear to be a git or CVS checkout, just pass the test here +# and now. (Do not let the test fail if it is run in a tree *exported* from a +# repository or unpacked from a .zip file source installer...) # -if(NOT EXISTS "${CMake_SOURCE_DIR}/CVS/Root") - message("source tree is not a CVS checkout... test passes by early return...") - return() +set(is_git_checkout 0) +if(EXISTS "${CMake_SOURCE_DIR}/.git") + set(is_git_checkout 1) endif() +set(is_cvs_checkout 0) +if(EXISTS "${CMake_SOURCE_DIR}/CVS/Root") + set(is_cvs_checkout 1) +endif() -# Check with "cvs -q -n up -dP" if there are any local modifications to the -# CMake source tree: -# -message("=============================================================================") -message("Copy/paste this command to reproduce:") -message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") +message("is_git_checkout='${is_git_checkout}'") +message("is_cvs_checkout='${is_cvs_checkout}'") message("") -# Use the HOME value passed in to the script for calling cvs so it can find -# its .cvspass and other file(s) -# -set(original_ENV_HOME "$ENV{HOME}") -set(ENV{HOME} "${HOME}") - -execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE ov - ERROR_VARIABLE ev - RESULT_VARIABLE rv) - -set(ENV{HOME} "${original_ENV_HOME}") - -message("Results of running '${CVS_EXECUTABLE} -q -n up -dP'") -message("rv='${rv}'") -message("ov='${ov}'") -message("ev='${ev}'") -message("") +if(NOT is_cvs_checkout) +if(NOT is_git_checkout) + message("source tree is neither git nor CVS checkout... test passes by early return...") + return() +endif() +endif() -if(NOT rv STREQUAL 0) - message(FATAL_ERROR "error: 'cvs -q -n up -dP' attempt failed... (see output above)") +if(is_cvs_checkout) +if(is_git_checkout) + message("warning: source tree has both git *and* CVS file system bits???") + # should this condition be a FATAL_ERROR test failure...? +endif() endif() -# Analyze cvs output: + +# This test looks for the following types of changes in the source tree: # set(additions 0) set(conflicts 0) set(modifications 0) set(nonadditions 0) +# ov == output variable... conditionally filled in by either cvs or git below: +# +set(cmd "") +set(ov "") +set(ev "") +set(rv "") + + +if(is_cvs_checkout AND CVS_EXECUTABLE) + # Check with "cvs -q -n up -dP" if there are any local modifications to the + # CMake source tree: + # + message("=============================================================================") + message("This is a cvs checkout, using cvs to verify source tree....") + message("") + + file(READ "${CMake_SOURCE_DIR}/CVS/Root" contents) + message("=== content of CVS/Root ===") + message("${contents}") + message("=== end content ===") + message("") + + file(READ "${CMake_SOURCE_DIR}/CVS/Repository" contents) + message("=== content of CVS/Repository ===") + message("${contents}") + message("=== end content ===") + message("") + + message("Copy/paste this command to reproduce:") + message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") + message("") + + set(cmd ${CVS_EXECUTABLE} -q -n up -dP) +endif() + + +if(is_git_checkout AND GIT_EXECUTABLE) + # Check with "git status" if there are any local modifications to the + # CMake source tree: + # + message("=============================================================================") + message("This is a git checkout, using git to verify source tree....") + message("") + + execute_process(COMMAND ${GIT_EXECUTABLE} branch -a + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE git_branch_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("=== output of 'git branch -a' ===") + message("${git_branch_output}") + message("=== end output ===") + message("") + + message("Copy/paste this command to reproduce:") + message("cd \"${CMake_SOURCE_DIR}\" && \"${GIT_EXECUTABLE}\" status") + message("") + + set(cmd ${GIT_EXECUTABLE} status) +endif() + + +if(cmd) + # Use the HOME value passed in to the script for calling cvs/git so it can + # find its .cvspass or user/global config settings... + # + set(original_ENV_HOME "$ENV{HOME}") + set(ENV{HOME} "${HOME}") + + execute_process(COMMAND ${cmd} + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE ov + ERROR_VARIABLE ev + RESULT_VARIABLE rv) + + set(ENV{HOME} "${original_ENV_HOME}") + + if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error: ${cmd} attempt failed... (see output above)") + endif() + + message("Results of running ${cmd}") + message("rv='${rv}'") + message("ov='${ov}'") + message("ev='${ev}'") + message("") +else() + message(FATAL_ERROR "error: no COMMAND to run to analyze source tree...") +endif() + + +# Analyze output: +# if(NOT ov STREQUAL "") string(REPLACE ";" "\\\\;" lines "${ov}") string(REPLACE "\n" "E;" lines "${lines}") @@ -110,29 +194,44 @@ if(NOT ov STREQUAL "") endif() if(consider) - if(line MATCHES "^A ") - message(" locally added file/directory detected...") - set(additions 1) - endif() - - if(line MATCHES "^C ") - message(" conflict detected...") - set(conflicts 1) + if(is_cvs_checkout) + if(line MATCHES "^A ") + message(" locally added file/directory detected...") + set(additions 1) + endif() + + if(line MATCHES "^C ") + message(" conflict detected...") + set(conflicts 1) + endif() + + if(line MATCHES "^M ") + message(" locally modified file detected...") + set(modifications 1) + endif() + + if(line MATCHES "^\\? ") + message(" locally non-added file/directory detected...") + set(nonadditions 1) + endif() endif() - if(line MATCHES "^M ") - message(" locally modified file detected...") - set(modifications 1) - endif() + if(is_git_checkout) + if(line MATCHES "^#[ \t]*modified:") + message(" locally modified file detected...") + set(modifications 1) + endif() - if(line MATCHES "^\\? ") - message(" locally non-added file/directory detected...") - set(nonadditions 1) + if(line MATCHES "^# Untracked") + message(" locally non-added file/directory detected...") + set(nonadditions 1) + endif() endif() endif() endforeach() endif() + message("=============================================================================") message("additions='${additions}'") message("conflicts='${conflicts}'") @@ -185,14 +284,14 @@ if(nonadditions) message(" warning: test results confounded because this is an 'in-source' build - cannot distinguish between non-added files that are in-source build products and -non-added source files that somebody forgot to 'cvs add'... - this is only ok +non-added source files that somebody forgot to 'git add'... - this is only ok if this is intentionally an in-source dashboard build... Developers should use out-of-source builds to verify a clean source tree with this test... Allowing test to pass despite the warning message... ") else() - message(FATAL_ERROR "test fails: local source tree non-additions: use cvs add before committing, or remove the files from the source tree") + message(FATAL_ERROR "test fails: local source tree non-additions: use git add before committing, or remove the files from the source tree") endif() endif() |