summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
blob: 25381f7cf029bcfd758b829e51480e4afa97179d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Check the CMake source tree and report anything suspicious...
#
message(STATUS
  "=============================================================================")
message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
message(STATUS "")
message(STATUS "CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'")
message(STATUS "CVS_EXECUTABLE='${CVS_EXECUTABLE}'")
message(STATUS "ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'")
message(STATUS "")


# Check with "cvs -q -n up -dP" if there are any local modifications to the
# CMake source tree:
#
message(STATUS "")
message(STATUS
  "=============================================================================")
execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP
  WORKING_DIRECTORY ${CMake_SOURCE_DIR}
  OUTPUT_VARIABLE ov
  ERROR_VARIABLE ev
  RESULT_VARIABLE rv)

set(additions 0)
set(conflicts 0)
set(modifications 0)

if(NOT ov STREQUAL "")
  string(REPLACE "\\\\;" ";" lines "${ov}")
  string(REPLACE "\n" "E;" lines "${lines}")

  foreach(line ${lines})
    message(STATUS "${line}")

    if(line MATCHES "^\\? ")
      message(STATUS "locally added file/directory detected...")
      set(additions 1)
    endif()

    if(line MATCHES "^C ")
      message(STATUS "conflict detected...")
      set(conflicts 1)
    endif()

    if(line MATCHES "^M ")
      message(STATUS "locally modified file detected...")
      set(modifications 1)
    endif()
  endforeach()
endif()

message(STATUS "Results of running '${CVS_EXECUTABLE} -q -n up -dP'")
message(STATUS "rv='${rv}'")
message(STATUS "ov='${ov}'")
message(STATUS "ev='${ev}'")
message(STATUS "")
message(STATUS "additions='${additions}'")
message(STATUS "conflicts='${conflicts}'")
message(STATUS "modifications='${modifications}'")


# Decide if the test passes or fails:
#
message(STATUS "")
message(STATUS
  "=============================================================================")

if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")

  # developers are allowed to have local modifications...
  message(STATUS "interactive test run")
  message(STATUS "")

else()

  message(STATUS "dashboard test run")
  message(STATUS "")

  # but dashboard machines are not allowed to have local modifications...
  if(modifications)
    message(FATAL_ERROR "test fails: source tree modifications")
  endif()

endif()

# ...and nobody is allowed to have local additions or conflicts...
# Not even developers.
#
if(additions)
  message(FATAL_ERROR "test fails: source tree additions: use cvs add before committing or remove the files from the source tree")
endif()

if(conflicts)
  message(FATAL_ERROR "test fails: source tree conflicts: resolve before committing")
endif()

message(STATUS "test passes")
message(STATUS "")