From f811441e257cafb975dfcd16f14b4378beee524e Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 25 Jan 2013 10:00:57 +0100 Subject: tests: skip time consuming mock builds for code-only changes tests/basic/rpm.t takes a bulk of the time for the regression tests. Often the building of the rpm is not affected at all and therefor the tests does not add any value. With this change the rpmbuild/mock test will only be run when some changes affect the build system. Changes affecting 'tests/', 'doc/', '*.py', *.c' and '*.h' do not trigger the test anymore. Change-Id: Ic188b9e26cde3113b2bdf9cd1fab56d9fd85a4b7 BUG: 904005 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/4429 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- tests/basic/rpm.t | 27 ++++++++++++++++++++++++++- tests/include.rc | 9 +++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/basic/rpm.t b/tests/basic/rpm.t index 45818ef6..f7854981 100755 --- a/tests/basic/rpm.t +++ b/tests/basic/rpm.t @@ -2,7 +2,6 @@ . $(dirname $0)/../include.rc -cleanup RESULT_DIR=$(mktemp -d -p /var/tmp rpm-tests.XXXXXXXX) # enable some extra debugging @@ -12,6 +11,32 @@ then set -x fi +# detect the branch we're based off +if [ -n "${BRANCH}" ] ; then + # $BRANCH is set in the environment (by Jenkins or other) + GIT_PARENT="origin/${BRANCH}" +else + # get a reference to the latest clean tree + GIT_PARENT=$(git describe --abbrev=0) +fi + +# check for changed files +CHANGED_FILES=$(git diff --name-only ${GIT_PARENT}) +# filter out any files not affecting the build itself +CHANGED_FILES=$(grep -E -v \ + -e '\.c$' \ + -e '\.h$' \ + -e '\.py$' \ + -e '^tests/' \ + <<< "${CHANGED_FILES}") +if [ -z "${CHANGED_FILES}" ] +then + # only contents of files were changed, no need to retest rpmbuild + SKIP_TESTS + cleanup + exit 0 +fi + # checkout the sources to a new directory to execute ./configure and all REPO=${PWD} COMMIT=$(git describe) diff --git a/tests/include.rc b/tests/include.rc index 90bcb8ec..03ffe4a5 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -154,6 +154,15 @@ function _EXPECT_WITHIN() } +function SKIP_TESTS() +{ + dbg "Skipping tests $t-$testcnt"; + while [ $t -le $testcnt ]; do + true ; test_footer; + done +} + + function cleanup() { killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true; -- cgit