changed: simplify the check-commits handling

now portable cmake code instead of a shell script

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@2934 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
akva 2014-10-07 16:18:10 +00:00 committed by Knut Morten Okstad
parent 8422b69752
commit 183f650024
6 changed files with 90 additions and 131 deletions

View File

@ -26,8 +26,5 @@ ADD_SUBDIRECTORY(Stokes)
ADD_SUBDIRECTORY(ThermoElasticity)
ADD_SUBDIRECTORY(HDF5toVTx)
# Generate regtest script with correct paths
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/Common/scripts/regtest.sh.in
regtest.sh)
# Add 'check' target which builds all test applications, then executes the tests
add_check_target()

View File

@ -0,0 +1,84 @@
find_package(Git REQUIRED)
macro(sanity_check message)
if(status_code)
message(FATAL_ERROR "${message}")
endif()
endmacro()
# Check that there are no changes in working-tree
execute_process(COMMAND ${GIT_EXECUTABLE} diff --quiet
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
sanity_check("Cannot run with working tree changes. Commit, stash or drop them.")
# Setup base of tests
set(check_base $ENV{CHECK_BASE})
if(NOT check_base)
set(check_base trunk)
endif()
# Setup end of tests
set(check_head $ENV{CHECK_HEAD})
if(NOT check_head)
set(check_head HEAD)
endif()
# Setup target to build
set(check_target $ENV{CHECK_TARGET})
if(NOT check_target)
set(check_target check)
endif()
# Build threads
set(build_threads $ENV{CHECK_THREADS})
if(NOT build_threads)
if(UNIX)
execute_process(COMMAND nproc
OUTPUT_VARIABLE build_threads)
string(REGEX REPLACE "(\r?\n)+$" "" build_threads "${build_threads}")
endif()
endif()
# Record current HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE current_branch
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(REGEX REPLACE "(\r?\n)+$" "" current_branch "${current_branch}")
# Grab revision list
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list ${check_base}..${check_head} --reverse
OUTPUT_VARIABLE rev_list
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(REPLACE "\n" ";" rev_list ${rev_list})
foreach(rev ${rev_list})
# Checkout
message("Testing revision ${rev}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${rev}
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
sanity_check("Failed to checkout ${rev}")
# Build
foreach(tgt ${check_target})
if(build_threads GREATER 2)
execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${tgt}" "--use-stderr" "--" "-j${build_threads}"
RESULT_VARIABLE status_code)
else()
execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${tgt}" "--use-stderr"
RESULT_VARIABLE status_code)
endif()
sanity_check("Failed to build target '${tgt}'")
endforeach()
if(status_code)
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
sanity_check("Failed to build target for revision ${rev}")
endforeach()
message("Everything checks out fine")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

View File

@ -1 +0,0 @@
EXECUTE_PROCESS(COMMAND ${CMAKE_BINARY_DIR}/check-patchseries.sh "@CMAKE_BUILD_TYPE@" "${PROJECT_SOURCE_DIR}" "@IFEM_AS_SUBMODULE@")

View File

@ -1,38 +0,0 @@
#!/bin/bash
# check-patchseries.sh
# Arne Morten Kvarving / SINTEF
# Oct 2012
# Convenience script that compiles and runs regression tests
# for a series of commits. Use the CHECK_BASE enviroment variable
# to control the base of the series. It then checks the revisions
# between the base and HEAD of the current branch
# Params: See doregtests.sh
#
# Assumes it it is run from top of the source tree
# and that the script sits in the 'scripts' directory
# directly off the top of the tree.
branch=`git branch|grep \*|awk -F ' ' '{print $2}'`
base=$CHECK_BASE
head=$CHECK_HEAD
if [ -z $base ]
then
git branch --list --remote|grep trunk && base=trunk
git branch --list --remote|grep git-svn && base=git-svn
fi
test -z $base && base="trunk"
test -z $head && last="HEAD"
for rev in `git rev-list $base..$last --reverse`; do
git checkout $rev
if ! @CMAKE_BINARY_DIR@/doregtests.sh $@
then
echo "Something failed for rev $rev"
git checkout $branch
exit 1
fi
done
git checkout $branch
echo "Everything checks out."

View File

@ -1,86 +0,0 @@
#!/bin/bash
# doregtest.sh
# Arne Morten Kvarving / SINTEF
# Oct 2012
# Convenience script that compiles and runs regression tests
# Params: $1 - build configuration
# Params: $2..$@ - directories to run tests in
#
# Assumes it it is run from top of the source tree
# and that the script sits in the 'scripts' directory
# directly off the top of the tree.
# Configure and build a directory
# Params: $1 - configuration directory
# $2 - root configuration directory
# $3 - directory to configure for
Build() {
if ! test -d $1
then
# Copy config off root dir
config=`cmake -L $2|grep =`
cmakeopt=""
IFS=$'\n'
for line in $config; do
opt=`echo $line | sed -e 's/=/="/g' -e 's/$/"/g'`
cmakeopt="-D$opt $cmakeopt"
done
mkdir $1
cd $1
cmake $3 $cmakeopt
else
# Make sure build system is up to date
if [ "$4" == "OFF" ] || [ "$4" == "0" ]
then
cd $1
cmake $3
fi
fi
threads=$CHECK_THREADS
test -z $thread && threads=3
if ! make -j$threads
then
globres=1
return
fi
}
globres=0
ROOT=@PROJECT_SOURCE_DIR@/
rm -f $ROOT/failed.log
# Build root lib
if [ "$3" == "OFF" ] || [ "$3" == "0" ]
then
rootconfig=@IFEM_PATH@/$1
test -d $rootconfig || rootconfig=@IFEM_PATH@/
cd $rootconfig
Build "$rootconfig" "$rootconfig" "$rootconfig/.."
fi
if test $globres -eq 0
then
test -d $ROOT/$1 && builddir=$2/$1
test -d $ROOT/$1 || builddir=$2
Build "$builddir" "$rootconfig" "$ROOT" "$3"
if test $globres -eq 0
then
if [ "$CHECKMODE" != "buildonly" ]
then
if ! make test
then
globres=1
fi
fi
fi
fi
if test $globres -eq 1
then
echo "Some tests failed, see failed.log in root of repository for details"
fi
exit $globres

View File

@ -102,8 +102,11 @@ IF(IFEM_PATH OR IFEM_AS_SUBMODULE)
ENDIF(GETB_LIBRARIES)
ENDIF(IFEM_USE_GETBEAM)
ENDIF(IFEM_AS_SUBMODULE)
CONFIGURE_FILE(${IFEM_PATH}/Apps/Common/cmake/CheckCommits.cmake.in CheckCommits.cmake)
ADD_CUSTOM_TARGET(check-commits COMMAND ${CMAKE_COMMAND} -P CheckCommits.cmake)
add_custom_target(check-commits
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${IFEM_PATH}/Apps/Common/cmake/CheckCommits.cmake)
ELSE(IFEM_PATH OR IFEM_AS_SUBMODULE)
# Build wants system IFEM
IF(NOT DEFINED FORCE_SYSTEM_IFEM OR NOT "${FORCE_SYSTEM_IFEM}")