CheckSourceTreeTest.cmake.in 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Check the CMake source tree and report anything suspicious...
  2. #
  3. message(STATUS
  4. "=============================================================================")
  5. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  6. message(STATUS "")
  7. message(STATUS "CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'")
  8. message(STATUS "CVS_EXECUTABLE='${CVS_EXECUTABLE}'")
  9. message(STATUS "ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'")
  10. message(STATUS "")
  11. # Check with "cvs -q -n up -dP" if there are any local modifications to the
  12. # CMake source tree:
  13. #
  14. message(STATUS "")
  15. message(STATUS
  16. "=============================================================================")
  17. execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP
  18. WORKING_DIRECTORY ${CMake_SOURCE_DIR}
  19. OUTPUT_VARIABLE ov
  20. ERROR_VARIABLE ev
  21. RESULT_VARIABLE rv)
  22. set(additions 0)
  23. set(conflicts 0)
  24. set(modifications 0)
  25. if(NOT ov STREQUAL "")
  26. string(REPLACE "\\\\;" ";" lines "${ov}")
  27. string(REPLACE "\n" "E;" lines "${lines}")
  28. foreach(line ${lines})
  29. message(STATUS "${line}")
  30. if(line MATCHES "^\\? ")
  31. message(STATUS "locally added file/directory detected...")
  32. set(additions 1)
  33. endif()
  34. if(line MATCHES "^C ")
  35. message(STATUS "conflict detected...")
  36. set(conflicts 1)
  37. endif()
  38. if(line MATCHES "^M ")
  39. message(STATUS "locally modified file detected...")
  40. set(modifications 1)
  41. endif()
  42. endforeach()
  43. endif()
  44. message(STATUS "Results of running '${CVS_EXECUTABLE} -q -n up -dP'")
  45. message(STATUS "rv='${rv}'")
  46. message(STATUS "ov='${ov}'")
  47. message(STATUS "ev='${ev}'")
  48. message(STATUS "")
  49. message(STATUS "additions='${additions}'")
  50. message(STATUS "conflicts='${conflicts}'")
  51. message(STATUS "modifications='${modifications}'")
  52. # Decide if the test passes or fails:
  53. #
  54. message(STATUS "")
  55. message(STATUS
  56. "=============================================================================")
  57. if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
  58. # developers are allowed to have local modifications...
  59. message(STATUS "interactive test run")
  60. message(STATUS "")
  61. else()
  62. message(STATUS "dashboard test run")
  63. message(STATUS "")
  64. # but dashboard machines are not allowed to have local modifications...
  65. if(modifications)
  66. message(FATAL_ERROR "test fails: source tree modifications")
  67. endif()
  68. endif()
  69. # ...and nobody is allowed to have local additions or conflicts...
  70. # Not even developers.
  71. #
  72. if(additions)
  73. message(FATAL_ERROR "test fails: source tree additions: use cvs add before committing or remove the files from the source tree")
  74. endif()
  75. if(conflicts)
  76. message(FATAL_ERROR "test fails: source tree conflicts: resolve before committing")
  77. endif()
  78. message(STATUS "test passes")
  79. message(STATUS "")