1 # Check the CMake source tree and report anything suspicious...
3 message("=============================================================================")
4 message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
6 message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'")
7 message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'")
8 message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'")
9 message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'")
13 # Is the build directory the same as or underneath the source directory?
14 # (i.e. - is it an "in source" build?)
16 set(in_source_build 0)
18 if(CMake_SOURCE_DIR STREQUAL "${CMake_BINARY_DIR}")
19 message("build dir *is* source dir")
20 set(in_source_build 1)
22 string(LENGTH "${CMake_SOURCE_DIR}" src_len)
23 string(LENGTH "${CMake_BINARY_DIR}" bin_len)
25 if(bin_len GREATER src_len)
26 math(EXPR substr_len "${src_len}+1")
27 string(SUBSTRING "${CMake_BINARY_DIR}" 0 ${substr_len} bin_dir)
28 if(bin_dir STREQUAL "${CMake_SOURCE_DIR}/")
29 message("build dir is under source dir")
30 set(in_source_build 1)
35 message("src_len='${src_len}'")
36 message("bin_len='${bin_len}'")
37 message("substr_len='${substr_len}'")
38 message("bin_dir='${bin_dir}'")
39 message("in_source_build='${in_source_build}'")
43 # Check with "cvs -q -n up -dP" if there are any local modifications to the
46 message("=============================================================================")
47 message("Copy/paste this command to reproduce:")
48 message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP")
50 execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP
51 WORKING_DIRECTORY ${CMake_SOURCE_DIR}
56 message("Results of running '${CVS_EXECUTABLE} -q -n up -dP'")
69 if(NOT ov STREQUAL "")
70 string(REPLACE ";" "\\\\;" lines "${ov}")
71 string(REPLACE "\n" "E;" lines "${lines}")
73 foreach(line ${lines})
76 # But do not consider files that exist just because some user poked around
77 # the file system with Windows Explorer or with the Finder from a Mac...
78 # ('Thumbs.db' and '.DS_Store' files...)
81 set(ignore_files_regex "^(. |.*(/|\\\\))(\\.DS_Store|Thumbs.db)E$")
82 if(line MATCHES "${ignore_files_regex}")
83 message(" line matches '${ignore_files_regex}' -- not considered")
88 if(line MATCHES "^A ")
89 message(" locally added file/directory detected...")
93 if(line MATCHES "^C ")
94 message(" conflict detected...")
98 if(line MATCHES "^M ")
99 message(" locally modified file detected...")
103 if(line MATCHES "^\\? ")
104 message(" locally non-added file/directory detected...")
111 message("=============================================================================")
112 message("additions='${additions}'")
113 message("conflicts='${conflicts}'")
114 message("modifications='${modifications}'")
115 message("nonadditions='${nonadditions}'")
119 # Decide if the test passes or fails:
121 message("=============================================================================")
123 if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
125 # developers are allowed to have local additions and modifications...
127 message("interactive test run")
133 message("dashboard test run")
136 # but dashboard machines are not allowed to have local additions or modifications...
138 message(FATAL_ERROR "test fails: local source tree additions")
142 message(FATAL_ERROR "test fails: local source tree modifications")
146 # It's a dashboard run if ctest was run with '-D ExperimentalTest' or some
147 # other -D arg on its command line or if ctest is running a -S script to run
148 # a dashboard... Running ctest like that sets the DASHBOARD_TEST_FROM_CTEST
155 # ...and nobody is allowed to have local non-additions or conflicts...
156 # Not even developers.
159 if(in_source_build AND is_dashboard)
161 warning: test results confounded because this is an 'in-source' build - cannot
162 distinguish between non-added files that are in-source build products and
163 non-added source files that somebody forgot to 'cvs add'... - this is only ok
164 if this is intentionally an in-source dashboard build... Developers should
165 use out-of-source builds to verify a clean source tree with this test...
167 Allowing test to pass despite the warning message...
170 message(FATAL_ERROR "test fails: local source tree non-additions: use cvs add before committing, or remove the files from the source tree")
175 message(FATAL_ERROR "test fails: local source tree conflicts: resolve before committing")
179 # Still here? Good then...
181 message("test passes")