2008-10-19 19:53:01 +04:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to run a child process and report output only on error.
|
|
|
|
function(run_child)
|
|
|
|
execute_process(${ARGN}
|
|
|
|
RESULT_VARIABLE FAILED
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
ERROR_VARIABLE OUTPUT
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
if(FAILED)
|
2014-04-06 23:51:33 +04:00
|
|
|
string(REPLACE "\n" "\n " OUTPUT "${OUTPUT}")
|
2009-08-12 06:01:49 +04:00
|
|
|
message(FATAL_ERROR "Child failed (${FAILED}), output is\n ${OUTPUT}\n"
|
|
|
|
"Command = [${ARGN}]\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to find the Update.xml file and check for expected entries.
|
|
|
|
function(check_updates build)
|
|
|
|
# Find the Update.xml file for the given build tree
|
|
|
|
set(PATTERN ${TOP}/${build}/Testing/*/Update.xml)
|
|
|
|
file(GLOB UPDATE_XML_FILE RELATIVE ${TOP} ${PATTERN})
|
|
|
|
string(REGEX REPLACE "//Update.xml$" "/Update.xml"
|
|
|
|
UPDATE_XML_FILE "${UPDATE_XML_FILE}"
|
|
|
|
)
|
|
|
|
if(NOT UPDATE_XML_FILE)
|
|
|
|
message(FATAL_ERROR "Cannot find Update.xml with pattern\n ${PATTERN}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-19 19:53:01 +04:00
|
|
|
message(" found ${UPDATE_XML_FILE}")
|
|
|
|
|
2011-07-29 18:24:06 +04:00
|
|
|
set(max_update_xml_size 16384)
|
|
|
|
|
2008-10-19 19:53:01 +04:00
|
|
|
# Read entries from the Update.xml file
|
2010-02-09 21:31:20 +03:00
|
|
|
set(types "Updated|Modified|Conflicting")
|
2008-10-19 19:53:01 +04:00
|
|
|
file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_ENTRIES
|
2010-02-09 21:31:20 +03:00
|
|
|
REGEX "<(${types}|FullName)>"
|
2011-07-29 18:24:06 +04:00
|
|
|
LIMIT_INPUT ${max_update_xml_size}
|
2008-10-19 19:53:01 +04:00
|
|
|
)
|
2013-11-01 00:24:57 +04:00
|
|
|
|
2010-02-09 21:31:20 +03:00
|
|
|
string(REGEX REPLACE
|
|
|
|
"[ \t]*<(${types})>[ \t]*;[ \t]*<FullName>([^<]*)</FullName>"
|
|
|
|
"\\1{\\2}" UPDATE_XML_ENTRIES "${UPDATE_XML_ENTRIES}")
|
2008-10-19 19:53:01 +04:00
|
|
|
|
2013-11-01 00:24:57 +04:00
|
|
|
# If specified, remove the given prefix from the files in Update.xml.
|
|
|
|
# Some VCS systems, like Perforce, return absolute locations
|
|
|
|
if(DEFINED REPOSITORY_FILE_PREFIX)
|
|
|
|
string(REPLACE
|
|
|
|
"${REPOSITORY_FILE_PREFIX}" ""
|
|
|
|
UPDATE_XML_ENTRIES "${UPDATE_XML_ENTRIES}")
|
|
|
|
endif()
|
|
|
|
|
2010-02-09 21:31:20 +03:00
|
|
|
# Compare expected and actual entries
|
|
|
|
set(EXTRA "${UPDATE_XML_ENTRIES}")
|
2010-05-04 17:35:27 +04:00
|
|
|
list(REMOVE_ITEM EXTRA ${ARGN} ${UPDATE_EXTRA} ${UPDATE_MAYBE})
|
|
|
|
set(MISSING "${ARGN}" ${UPDATE_EXTRA})
|
2014-01-22 05:02:25 +04:00
|
|
|
if(NOT "" STREQUAL "${UPDATE_XML_ENTRIES}")
|
|
|
|
list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES})
|
|
|
|
endif()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
2009-12-18 16:13:51 +03:00
|
|
|
if(NOT UPDATE_NOT_GLOBAL)
|
2009-12-18 19:01:24 +03:00
|
|
|
set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS})
|
|
|
|
string(REPLACE ";" "|" rev_regex "${rev_elements}")
|
|
|
|
set(rev_regex "^\t<(${rev_regex})>[^<\n]+</(${rev_regex})>$")
|
2009-12-18 16:13:51 +03:00
|
|
|
file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS
|
|
|
|
REGEX "${rev_regex}"
|
2011-07-29 18:24:06 +04:00
|
|
|
LIMIT_INPUT ${max_update_xml_size}
|
2009-12-18 16:13:51 +03:00
|
|
|
)
|
|
|
|
foreach(r IN LISTS UPDATE_XML_REVISIONS)
|
|
|
|
string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}")
|
|
|
|
set(element_${element} 1)
|
|
|
|
endforeach()
|
|
|
|
foreach(element ${rev_elements})
|
|
|
|
if(NOT element_${element})
|
|
|
|
list(APPEND MISSING "global <${element}> element")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2008-10-19 19:53:01 +04:00
|
|
|
# Report the result
|
2010-02-09 21:31:20 +03:00
|
|
|
set(MSG "")
|
2008-10-19 19:53:01 +04:00
|
|
|
if(MISSING)
|
|
|
|
# List the missing entries
|
2010-02-09 21:31:20 +03:00
|
|
|
set(MSG "${MSG}Update.xml is missing expected entries:\n")
|
2008-10-19 19:53:01 +04:00
|
|
|
foreach(f ${MISSING})
|
|
|
|
set(MSG "${MSG} ${f}\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
|
|
|
else()
|
2010-02-09 21:31:20 +03:00
|
|
|
# Success
|
|
|
|
message(" no entries missing from Update.xml")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
2010-02-09 21:31:20 +03:00
|
|
|
# Report the result
|
|
|
|
if(EXTRA)
|
|
|
|
# List the extra entries
|
|
|
|
set(MSG "${MSG}Update.xml has extra unexpected entries:\n")
|
|
|
|
foreach(f ${EXTRA})
|
|
|
|
set(MSG "${MSG} ${f}\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
|
|
|
else()
|
2010-02-09 21:31:20 +03:00
|
|
|
# Success
|
|
|
|
message(" no extra entries in Update.xml")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2010-02-09 21:31:20 +03:00
|
|
|
|
|
|
|
if(MSG)
|
2008-10-19 19:53:01 +04:00
|
|
|
# Provide the log file
|
|
|
|
file(GLOB UPDATE_LOG_FILE
|
|
|
|
${TOP}/${build}/Testing/Temporary/LastUpdate*.log)
|
|
|
|
if(UPDATE_LOG_FILE)
|
2011-07-29 18:24:06 +04:00
|
|
|
file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size})
|
2014-04-06 23:51:33 +04:00
|
|
|
string(REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}")
|
2008-10-19 19:53:01 +04:00
|
|
|
set(MSG "${MSG}Update log:\n ${UPDATE_LOG}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2008-10-19 19:53:01 +04:00
|
|
|
set(MSG "${MSG}No update log found!")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
# Display the error message
|
|
|
|
message(FATAL_ERROR "${MSG}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to create initial content.
|
|
|
|
function(create_content dir)
|
|
|
|
file(MAKE_DIRECTORY ${TOP}/${dir})
|
|
|
|
|
|
|
|
# An example CTest project configuration file.
|
|
|
|
file(WRITE ${TOP}/${dir}/CTestConfig.cmake
|
|
|
|
"# CTest Configuration File
|
|
|
|
set(CTEST_PROJECT_NAME TestProject)
|
|
|
|
set(CTEST_NIGHTLY_START_TIME \"21:00:00 EDT\")
|
|
|
|
")
|
|
|
|
|
|
|
|
# Some other files.
|
|
|
|
file(WRITE ${TOP}/${dir}/foo.txt "foo\n")
|
|
|
|
file(WRITE ${TOP}/${dir}/bar.txt "bar\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to update content.
|
2009-02-23 23:59:07 +03:00
|
|
|
function(update_content dir added_var removed_var dirs_var)
|
2008-10-19 19:53:01 +04:00
|
|
|
file(APPEND ${TOP}/${dir}/foo.txt "foo line 2\n")
|
|
|
|
file(WRITE ${TOP}/${dir}/zot.txt "zot\n")
|
|
|
|
file(REMOVE ${TOP}/${dir}/bar.txt)
|
2009-02-23 23:59:07 +03:00
|
|
|
file(MAKE_DIRECTORY ${TOP}/${dir}/subdir)
|
|
|
|
file(WRITE ${TOP}/${dir}/subdir/foo.txt "foo\n")
|
|
|
|
file(WRITE ${TOP}/${dir}/subdir/bar.txt "bar\n")
|
|
|
|
set(${dirs_var} subdir PARENT_SCOPE)
|
|
|
|
set(${added_var} zot.txt subdir/foo.txt subdir/bar.txt PARENT_SCOPE)
|
2008-10-19 19:53:01 +04:00
|
|
|
set(${removed_var} bar.txt PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
2009-02-23 23:59:07 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to change existing files
|
|
|
|
function(change_content dir)
|
|
|
|
file(APPEND ${TOP}/${dir}/foo.txt "foo line 3\n")
|
|
|
|
file(APPEND ${TOP}/${dir}/subdir/foo.txt "foo line 2\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2009-02-23 23:59:07 +03:00
|
|
|
|
2009-02-26 17:22:16 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to create local modifications before update
|
|
|
|
function(modify_content dir)
|
|
|
|
file(APPEND ${TOP}/${dir}/CTestConfig.cmake "# local modification\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2009-02-26 17:22:16 +03:00
|
|
|
|
2008-10-19 19:53:01 +04:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to write CTestConfiguration.ini content.
|
|
|
|
function(create_build_tree src_dir bin_dir)
|
|
|
|
file(MAKE_DIRECTORY ${TOP}/${bin_dir})
|
|
|
|
file(WRITE ${TOP}/${bin_dir}/CTestConfiguration.ini
|
|
|
|
"# CTest Configuration File
|
|
|
|
SourceDirectory: ${TOP}/${src_dir}
|
|
|
|
BuildDirectory: ${TOP}/${bin_dir}
|
|
|
|
Site: test.site
|
|
|
|
BuildName: user-test
|
|
|
|
")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to write the dashboard test script.
|
2010-06-08 23:58:39 +04:00
|
|
|
function(create_dashboard_script bin_dir custom_text)
|
2008-10-19 19:53:01 +04:00
|
|
|
# Write the dashboard script.
|
2010-06-08 23:58:39 +04:00
|
|
|
file(WRITE ${TOP}/${bin_dir}.cmake
|
2008-10-19 19:53:01 +04:00
|
|
|
"# CTest Dashboard Script
|
|
|
|
set(CTEST_DASHBOARD_ROOT \"${TOP}\")
|
|
|
|
set(CTEST_SITE test.site)
|
|
|
|
set(CTEST_BUILD_NAME dash-test)
|
|
|
|
set(CTEST_SOURCE_DIRECTORY \${CTEST_DASHBOARD_ROOT}/dash-source)
|
2010-06-08 23:58:39 +04:00
|
|
|
set(CTEST_BINARY_DIRECTORY \${CTEST_DASHBOARD_ROOT}/${bin_dir})
|
2008-10-19 19:53:01 +04:00
|
|
|
${custom_text}
|
|
|
|
# Start a dashboard and run the update step
|
|
|
|
ctest_start(Experimental)
|
|
|
|
ctest_update(SOURCE \${CTEST_SOURCE_DIRECTORY})
|
|
|
|
")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to run the dashboard through the command line
|
|
|
|
function(run_dashboard_command_line bin_dir)
|
|
|
|
run_child(
|
|
|
|
WORKING_DIRECTORY ${TOP}/${bin_dir}
|
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND} -M Experimental -T Start -T Update
|
|
|
|
)
|
|
|
|
|
|
|
|
# Verify the updates reported by CTest.
|
2010-02-10 19:48:09 +03:00
|
|
|
list(APPEND UPDATE_MAYBE Updated{subdir})
|
2010-06-09 00:37:04 +04:00
|
|
|
set(_modified Modified{CTestConfig.cmake})
|
|
|
|
if(UPDATE_NO_MODIFIED)
|
|
|
|
set(_modified "")
|
|
|
|
endif()
|
2010-02-09 21:31:20 +03:00
|
|
|
check_updates(${bin_dir}
|
|
|
|
Updated{foo.txt}
|
|
|
|
Updated{bar.txt}
|
|
|
|
Updated{zot.txt}
|
|
|
|
Updated{subdir/foo.txt}
|
|
|
|
Updated{subdir/bar.txt}
|
2010-06-09 00:37:04 +04:00
|
|
|
${_modified}
|
2010-02-09 21:31:20 +03:00
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
2014-08-13 21:45:08 +04:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to find the Update.xml file and make sure
|
|
|
|
# it only has the Revision in it and no updates
|
|
|
|
function(check_no_update bin_dir)
|
|
|
|
set(PATTERN ${TOP}/${bin_dir}/Testing/*/Update.xml)
|
|
|
|
file(GLOB UPDATE_XML_FILE RELATIVE ${TOP} ${PATTERN})
|
|
|
|
string(REGEX REPLACE "//Update.xml$" "/Update.xml"
|
|
|
|
UPDATE_XML_FILE "${UPDATE_XML_FILE}")
|
|
|
|
message(" found ${UPDATE_XML_FILE}")
|
|
|
|
set(rev_regex "Revision|PriorRevision")
|
|
|
|
file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS
|
|
|
|
REGEX "^\t<(${rev_regex})>[^<\n]+</(${rev_regex})>$"
|
|
|
|
)
|
|
|
|
set(found_revisons FALSE)
|
|
|
|
foreach(r IN LISTS UPDATE_XML_REVISIONS)
|
|
|
|
if("${r}" MATCHES "PriorRevision")
|
|
|
|
message(FATAL_ERROR "Found PriorRevision in no update test")
|
|
|
|
endif()
|
|
|
|
if("${r}" MATCHES "<Revision>")
|
|
|
|
set(found_revisons TRUE)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(found_revisons)
|
|
|
|
message(" found <Revision> in no update test")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR " missing <Revision> in no update test")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
2008-10-19 19:53:01 +04:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to run the dashboard through a script
|
2010-06-08 23:58:39 +04:00
|
|
|
function(run_dashboard_script bin_dir)
|
2008-10-19 19:53:01 +04:00
|
|
|
run_child(
|
|
|
|
WORKING_DIRECTORY ${TOP}
|
2010-06-08 23:58:39 +04:00
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND} -S ${bin_dir}.cmake -V
|
2008-10-19 19:53:01 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
# Verify the updates reported by CTest.
|
2013-10-23 02:11:22 +04:00
|
|
|
list(APPEND UPDATE_MAYBE Updated{subdir} Updated{CTestConfig.cmake})
|
2014-08-13 21:45:08 +04:00
|
|
|
if(NO_UPDATE)
|
|
|
|
check_no_update(${bin_dir})
|
|
|
|
else()
|
|
|
|
check_updates(${bin_dir}
|
|
|
|
Updated{foo.txt}
|
|
|
|
Updated{bar.txt}
|
|
|
|
Updated{zot.txt}
|
|
|
|
Updated{subdir/foo.txt}
|
|
|
|
Updated{subdir/bar.txt}
|
|
|
|
)
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-10-19 19:53:01 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to initialize the testing directory.
|
|
|
|
function(init_testing)
|
|
|
|
file(REMOVE_RECURSE ${TOP})
|
|
|
|
file(MAKE_DIRECTORY ${TOP})
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|