2009-07-24 23:58:23 +04:00
|
|
|
# Check the CMake source tree and report anything suspicious...
|
|
|
|
#
|
2009-07-25 21:32:07 +04:00
|
|
|
message("=============================================================================")
|
|
|
|
message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
|
|
|
|
message("")
|
2009-07-27 20:04:03 +04:00
|
|
|
message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'")
|
2009-07-25 21:32:07 +04:00
|
|
|
message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'")
|
2010-05-27 22:38:53 +04:00
|
|
|
message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
|
2009-12-04 22:50:37 +03:00
|
|
|
message("HOME='${HOME}'")
|
2009-07-25 21:32:07 +04:00
|
|
|
message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'")
|
|
|
|
message("")
|
2009-12-07 19:54:23 +03:00
|
|
|
string(REPLACE "\\" "\\\\" HOME "${HOME}")
|
2009-07-24 23:58:23 +04:00
|
|
|
|
|
|
|
|
2009-07-27 20:04:03 +04:00
|
|
|
# Is the build directory the same as or underneath the source directory?
|
|
|
|
# (i.e. - is it an "in source" build?)
|
|
|
|
#
|
|
|
|
set(in_source_build 0)
|
2015-05-14 16:50:34 +03:00
|
|
|
set(build_under_source 0)
|
2009-07-27 20:04:03 +04:00
|
|
|
|
2015-05-14 16:50:34 +03:00
|
|
|
string(FIND "${CMake_BINARY_DIR}" "${CMake_SOURCE_DIR}/" pos)
|
|
|
|
if(pos EQUAL 0)
|
|
|
|
message("build dir is *inside* source dir")
|
|
|
|
set(build_under_source 1)
|
|
|
|
elseif(CMake_SOURCE_DIR STREQUAL "${CMake_BINARY_DIR}")
|
2009-07-27 20:04:03 +04:00
|
|
|
message("build dir *is* source dir")
|
|
|
|
set(in_source_build 1)
|
|
|
|
else()
|
|
|
|
string(LENGTH "${CMake_SOURCE_DIR}" src_len)
|
|
|
|
string(LENGTH "${CMake_BINARY_DIR}" bin_len)
|
|
|
|
|
|
|
|
if(bin_len GREATER src_len)
|
|
|
|
math(EXPR substr_len "${src_len}+1")
|
|
|
|
string(SUBSTRING "${CMake_BINARY_DIR}" 0 ${substr_len} bin_dir)
|
|
|
|
if(bin_dir STREQUAL "${CMake_SOURCE_DIR}/")
|
|
|
|
message("build dir is under source dir")
|
|
|
|
set(in_source_build 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message("src_len='${src_len}'")
|
|
|
|
message("bin_len='${bin_len}'")
|
|
|
|
message("substr_len='${substr_len}'")
|
|
|
|
message("bin_dir='${bin_dir}'")
|
|
|
|
message("in_source_build='${in_source_build}'")
|
2015-05-14 16:50:34 +03:00
|
|
|
message("build_under_source='${build_under_source}'")
|
2009-07-27 20:04:03 +04:00
|
|
|
message("")
|
|
|
|
|
2015-05-14 16:50:34 +03:00
|
|
|
if(build_under_source)
|
|
|
|
message(STATUS "Skipping rest of test because build tree is under source tree")
|
|
|
|
return()
|
|
|
|
endif()
|
2009-07-27 20:04:03 +04:00
|
|
|
|
2012-03-02 19:24:43 +04:00
|
|
|
# If this does not appear to be a git checkout, just pass the test here
|
2010-05-27 22:38:53 +04:00
|
|
|
# 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...)
|
2009-12-07 19:54:23 +03:00
|
|
|
#
|
2010-05-27 22:38:53 +04:00
|
|
|
set(is_git_checkout 0)
|
|
|
|
if(EXISTS "${CMake_SOURCE_DIR}/.git")
|
|
|
|
set(is_git_checkout 1)
|
2009-12-07 19:54:23 +03:00
|
|
|
endif()
|
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
message("is_git_checkout='${is_git_checkout}'")
|
2009-07-25 21:32:07 +04:00
|
|
|
message("")
|
2009-12-04 22:50:37 +03:00
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
if(NOT is_git_checkout)
|
2012-03-02 19:24:43 +04:00
|
|
|
message("source tree is not a git checkout... test passes by early return...")
|
2010-05-27 22:38:53 +04:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# This test looks for the following types of changes in the source tree:
|
2009-07-25 21:32:07 +04:00
|
|
|
#
|
2009-07-25 01:12:37 +04:00
|
|
|
set(additions 0)
|
|
|
|
set(conflicts 0)
|
2009-07-24 23:58:23 +04:00
|
|
|
set(modifications 0)
|
2009-07-25 21:32:07 +04:00
|
|
|
set(nonadditions 0)
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2012-03-02 19:24:43 +04:00
|
|
|
# ov == output variable... conditionally filled in by either git below:
|
2010-05-27 22:38:53 +04:00
|
|
|
#
|
|
|
|
set(cmd "")
|
|
|
|
set(ov "")
|
|
|
|
set(ev "")
|
|
|
|
set(rv "")
|
|
|
|
|
2010-06-21 22:46:30 +04:00
|
|
|
# If no GIT_EXECUTABLE, see if we can figure out which git was used
|
|
|
|
# for the ctest_update step on this dashboard...
|
|
|
|
#
|
|
|
|
if(is_git_checkout AND NOT GIT_EXECUTABLE)
|
|
|
|
set(ctest_ini_file "")
|
|
|
|
set(exe "")
|
|
|
|
|
|
|
|
# Use the old name:
|
|
|
|
if(EXISTS "${CMake_BINARY_DIR}/DartConfiguration.tcl")
|
|
|
|
set(ctest_ini_file "${CMake_BINARY_DIR}/DartConfiguration.tcl")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# But if it exists, prefer the new name:
|
|
|
|
if(EXISTS "${CMake_BINARY_DIR}/CTestConfiguration.ini")
|
|
|
|
set(ctest_ini_file "${CMake_BINARY_DIR}/CTestConfiguration.ini")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# If there is a ctest ini file, read the update command or git command
|
|
|
|
# from it:
|
|
|
|
#
|
|
|
|
if(ctest_ini_file)
|
2010-06-27 16:29:15 +04:00
|
|
|
file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$")
|
|
|
|
string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}")
|
|
|
|
if("${line}" MATCHES "^\"")
|
|
|
|
string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
|
|
|
|
else()
|
|
|
|
string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
|
|
|
|
endif()
|
|
|
|
set(exe "${line}")
|
2010-06-21 22:46:30 +04:00
|
|
|
if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND")
|
|
|
|
set(exe "")
|
|
|
|
endif()
|
2010-06-27 16:29:15 +04:00
|
|
|
if(exe)
|
|
|
|
message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'")
|
|
|
|
endif()
|
2010-06-21 22:46:30 +04:00
|
|
|
|
|
|
|
if(NOT exe)
|
2010-06-27 16:29:15 +04:00
|
|
|
file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$")
|
|
|
|
string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}")
|
|
|
|
if("${line}" MATCHES "^\"")
|
|
|
|
string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
|
|
|
|
else()
|
|
|
|
string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
|
|
|
|
endif()
|
|
|
|
set(exe "${line}")
|
2010-06-21 22:46:30 +04:00
|
|
|
if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND")
|
|
|
|
set(exe "")
|
|
|
|
endif()
|
2010-06-27 16:29:15 +04:00
|
|
|
if(exe)
|
|
|
|
message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# If we have still not grokked the exe, look in the Update.xml file to see
|
|
|
|
# if we can parse it from there...
|
|
|
|
#
|
|
|
|
if(NOT exe)
|
|
|
|
file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml")
|
|
|
|
if(update_xml_file)
|
|
|
|
file(STRINGS "${update_xml_file}" line
|
|
|
|
REGEX "^.*<UpdateCommand>(.*)</UpdateCommand>$" LIMIT_COUNT 1)
|
|
|
|
string(REPLACE ""\;" "\"" line "${line}")
|
|
|
|
string(REGEX REPLACE "^.*<UpdateCommand>(.*)</UpdateCommand>$" "\\1" line "${line}")
|
|
|
|
if("${line}" MATCHES "^\"")
|
|
|
|
string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
|
|
|
|
else()
|
|
|
|
string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
|
|
|
|
endif()
|
|
|
|
if(line)
|
|
|
|
set(exe "${line}")
|
|
|
|
endif()
|
|
|
|
if(exe)
|
|
|
|
message("info: GIT_EXECUTABLE set by '<UpdateCommand>' from '${update_xml_file}'")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message("info: no Update.xml file...")
|
2010-06-21 22:46:30 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(exe)
|
|
|
|
set(GIT_EXECUTABLE "${exe}")
|
2010-06-27 16:29:15 +04:00
|
|
|
message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
|
|
|
|
message("")
|
|
|
|
|
|
|
|
if(NOT EXISTS "${GIT_EXECUTABLE}")
|
|
|
|
message(FATAL_ERROR "GIT_EXECUTABLE does not exist...")
|
|
|
|
endif()
|
2010-06-21 22:46:30 +04:00
|
|
|
else()
|
2010-06-27 16:29:15 +04:00
|
|
|
message(FATAL_ERROR "could not determine GIT_EXECUTABLE...")
|
2010-06-21 22:46:30 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
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("")
|
|
|
|
|
2010-05-28 00:43:28 +04:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} --version
|
|
|
|
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE version_output
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
message("=== output of 'git --version' ===")
|
|
|
|
message("${version_output}")
|
|
|
|
message("=== end output ===")
|
|
|
|
message("")
|
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
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("")
|
|
|
|
|
2010-06-21 22:46:30 +04:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} log -1
|
|
|
|
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE git_log_output
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
message("=== output of 'git log -1' ===")
|
|
|
|
message("${git_log_output}")
|
|
|
|
message("=== end output ===")
|
|
|
|
message("")
|
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
message("Copy/paste this command to reproduce:")
|
|
|
|
message("cd \"${CMake_SOURCE_DIR}\" && \"${GIT_EXECUTABLE}\" status")
|
|
|
|
message("")
|
|
|
|
|
|
|
|
set(cmd ${GIT_EXECUTABLE} status)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if(cmd)
|
2012-03-02 19:24:43 +04:00
|
|
|
# Use the HOME value passed in to the script for calling git so it can
|
|
|
|
# find its user/global config settings...
|
2010-05-27 22:38:53 +04:00
|
|
|
#
|
|
|
|
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}")
|
|
|
|
|
|
|
|
message("Results of running ${cmd}")
|
|
|
|
message("rv='${rv}'")
|
|
|
|
message("ov='${ov}'")
|
|
|
|
message("ev='${ev}'")
|
|
|
|
message("")
|
2010-05-28 00:43:28 +04:00
|
|
|
|
|
|
|
if(NOT rv STREQUAL 0)
|
2010-05-28 18:16:44 +04:00
|
|
|
if(is_git_checkout AND (rv STREQUAL "1"))
|
|
|
|
# Many builds of git return "1" from a "nothing is changed" git status call...
|
|
|
|
# Do not fail with an error for rv==1 with git...
|
2010-05-28 00:43:28 +04:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "error: ${cmd} attempt failed... (see output above)")
|
|
|
|
endif()
|
|
|
|
endif()
|
2010-05-27 22:38:53 +04:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "error: no COMMAND to run to analyze source tree...")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# Analyze output:
|
|
|
|
#
|
2009-07-24 23:58:23 +04:00
|
|
|
if(NOT ov STREQUAL "")
|
2009-07-25 21:32:07 +04:00
|
|
|
string(REPLACE ";" "\\\\;" lines "${ov}")
|
2009-07-25 01:12:37 +04:00
|
|
|
string(REPLACE "\n" "E;" lines "${lines}")
|
|
|
|
|
|
|
|
foreach(line ${lines})
|
2009-07-25 21:32:07 +04:00
|
|
|
message("'${line}'")
|
|
|
|
|
|
|
|
# But do not consider files that exist just because some user poked around
|
|
|
|
# the file system with Windows Explorer or with the Finder from a Mac...
|
|
|
|
# ('Thumbs.db' and '.DS_Store' files...)
|
|
|
|
#
|
|
|
|
set(consider 1)
|
|
|
|
set(ignore_files_regex "^(. |.*(/|\\\\))(\\.DS_Store|Thumbs.db)E$")
|
|
|
|
if(line MATCHES "${ignore_files_regex}")
|
|
|
|
message(" line matches '${ignore_files_regex}' -- not considered")
|
|
|
|
set(consider 0)
|
2009-07-25 01:12:37 +04:00
|
|
|
endif()
|
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
if(consider)
|
2010-05-27 22:38:53 +04:00
|
|
|
if(is_git_checkout)
|
2014-12-16 22:51:06 +03:00
|
|
|
if(line MATCHES "^#?[ \t]*modified:")
|
2010-05-27 22:38:53 +04:00
|
|
|
message(" locally modified file detected...")
|
|
|
|
set(modifications 1)
|
|
|
|
endif()
|
2009-07-25 21:32:07 +04:00
|
|
|
|
2014-12-16 22:51:06 +03:00
|
|
|
if(line MATCHES "^(# )?Untracked")
|
2010-05-27 22:38:53 +04:00
|
|
|
message(" locally non-added file/directory detected...")
|
|
|
|
set(nonadditions 1)
|
|
|
|
endif()
|
2009-07-25 21:32:07 +04:00
|
|
|
endif()
|
2009-07-25 01:12:37 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2009-07-24 23:58:23 +04:00
|
|
|
endif()
|
|
|
|
|
2010-05-27 22:38:53 +04:00
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
message("=============================================================================")
|
|
|
|
message("additions='${additions}'")
|
|
|
|
message("conflicts='${conflicts}'")
|
|
|
|
message("modifications='${modifications}'")
|
|
|
|
message("nonadditions='${nonadditions}'")
|
|
|
|
message("")
|
2009-07-24 23:58:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
# Decide if the test passes or fails:
|
|
|
|
#
|
2009-07-25 21:32:07 +04:00
|
|
|
message("=============================================================================")
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2009-07-24 23:58:23 +04:00
|
|
|
if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
# developers are allowed to have local additions and modifications...
|
2009-07-27 20:04:03 +04:00
|
|
|
set(is_dashboard 0)
|
2009-07-25 21:32:07 +04:00
|
|
|
message("interactive test run")
|
|
|
|
message("")
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2009-07-24 23:58:23 +04:00
|
|
|
else()
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2009-07-27 20:04:03 +04:00
|
|
|
set(is_dashboard 1)
|
2009-07-25 21:32:07 +04:00
|
|
|
message("dashboard test run")
|
|
|
|
message("")
|
|
|
|
|
|
|
|
# but dashboard machines are not allowed to have local additions or modifications...
|
|
|
|
if(additions)
|
|
|
|
message(FATAL_ERROR "test fails: local source tree additions")
|
|
|
|
endif()
|
2009-07-24 23:58:23 +04:00
|
|
|
|
|
|
|
if(modifications)
|
2009-07-25 21:32:07 +04:00
|
|
|
message(FATAL_ERROR "test fails: local source tree modifications")
|
2009-07-24 23:58:23 +04:00
|
|
|
endif()
|
2009-07-25 01:12:37 +04:00
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
#
|
2009-07-27 20:04:03 +04:00
|
|
|
# It's a dashboard run if ctest was run with '-D ExperimentalTest' or some
|
|
|
|
# other -D arg on its command line or if ctest is running a -S script to run
|
|
|
|
# a dashboard... Running ctest like that sets the DASHBOARD_TEST_FROM_CTEST
|
|
|
|
# env var.
|
2009-07-25 21:32:07 +04:00
|
|
|
#
|
|
|
|
|
2009-07-25 01:12:37 +04:00
|
|
|
endif()
|
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
|
|
|
|
# ...and nobody is allowed to have local non-additions or conflicts...
|
2009-07-25 01:12:37 +04:00
|
|
|
# Not even developers.
|
|
|
|
#
|
2009-07-25 21:32:07 +04:00
|
|
|
if(nonadditions)
|
2009-07-27 20:04:03 +04:00
|
|
|
if(in_source_build AND is_dashboard)
|
|
|
|
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
|
2010-05-27 22:38:53 +04:00
|
|
|
non-added source files that somebody forgot to 'git add'... - this is only ok
|
2009-07-27 20:04:03 +04:00
|
|
|
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()
|
2010-05-27 22:38:53 +04:00
|
|
|
message(FATAL_ERROR "test fails: local source tree non-additions: use git add before committing, or remove the files from the source tree")
|
2009-07-27 20:04:03 +04:00
|
|
|
endif()
|
2009-07-25 01:12:37 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(conflicts)
|
2009-07-25 21:32:07 +04:00
|
|
|
message(FATAL_ERROR "test fails: local source tree conflicts: resolve before committing")
|
2009-07-24 23:58:23 +04:00
|
|
|
endif()
|
|
|
|
|
2009-07-25 21:32:07 +04:00
|
|
|
|
|
|
|
# Still here? Good then...
|
|
|
|
#
|
|
|
|
message("test passes")
|
|
|
|
message("")
|