From c7868053376bbce1336a0d6e6a9afce93084ebd0 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 22 Jun 2018 21:36:18 +0200 Subject: refactor and improve the test script When doing rdep tests merge the test dependencies first without FEATURES=test, as we do not want to test them. This avoids build failures because of failing tests or cycling dependencies, and usually reduces the build time a lot. --- tatt/scriptwriter.py | 1 + templates/revdep-header | 39 +++++-------------------------- templates/revdep-snippet | 7 +----- templates/tatt_functions.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++ templates/use-header | 39 ++++--------------------------- 5 files changed, 70 insertions(+), 73 deletions(-) create mode 100644 templates/tatt_functions.sh diff --git a/tatt/scriptwriter.py b/tatt/scriptwriter.py index 5cb5155..8623104 100644 --- a/tatt/scriptwriter.py +++ b/tatt/scriptwriter.py @@ -41,6 +41,7 @@ def scriptTemplate(job, config, filename): snippet = snippet.replace("@@BUILDLOGDIR@@", config['buildlogdir']) snippet = snippet.replace("@@KEYWORDFILE@@", config['unmaskfile']) snippet = snippet.replace("@@NEWKEYWORD@@", newkeyword) + snippet = snippet.replace("@@TEMPLATEDIR@@", config['template-dir']) return snippet def useCombiTestString(job, pack, config, port): diff --git a/templates/revdep-header b/templates/revdep-header index 5d01821..5731d5d 100644 --- a/templates/revdep-header +++ b/templates/revdep-header @@ -3,40 +3,13 @@ trap "echo 'signal captured, exiting the entire script...'; exit" SIGHUP SIGINT SIGTERM -function tatt_pkg_error -{ - local eout=${2} +export TATT_TEST_TYPE="rdep" +export TATT_REPORTFILE="@@REPORTFILE@@" +export TATT_BUILDLOGDIR="@@BUILDLOGDIR@@" +export TATT_EMERGEOPTS="@@EMERGEOPTS@@" - echo "${eout}" +source "@@TEMPLATEDIR@@tatt_functions.sh" - if [ -n "${USE}" ]; then - echo -n "USE='${USE}'" >> @@REPORTFILE@@ - fi - if [ -n "${FEATURES}" ]; then - echo -n " FEATURES='${FEATURES}'" >> @@REPORTFILE@@ - fi - - if [[ "${eout}" =~ REQUIRED_USE ]] ; then - echo " : REQUIRED_USE not satisfied (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ USE\ changes ]] ; then - echo " : USE dependencies not satisfied (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ keyword\ changes ]]; then - echo " : unkeyworded dependencies (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ Error:\ circular\ dependencies: ]]; then - echo " : circular dependencies (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ Blocked\ Packages ]]; then - echo " : blocked packages (probably) for ${1:?}" >> @@REPORTFILE@@ - else - echo " failed for ${1:?}" >> @@REPORTFILE@@ - fi - - CP=${1#=} - BUILDLOG=/var/tmp/portage/${CP}/temp/build.log - if [[ -n "@@BUILDLOGDIR@@" && -s "${BUILDLOG}" ]]; then - LOGNAME=$(mktemp -p "@@BUILDLOGDIR@@" "${CP/\//_}_rdep_XXXXX") - mv "${BUILDLOG}" "${LOGNAME}" - echo " log has been saved as ${LOGNAME}" >> @@REPORTFILE@@ - fi -} +export USE echo -e "revdep tests started on $(date)\n" >> @@REPORTFILE@@ diff --git a/templates/revdep-snippet b/templates/revdep-snippet index 03fa511..72d7dd2 100644 --- a/templates/revdep-snippet +++ b/templates/revdep-snippet @@ -1,6 +1 @@ -eout=$( @@FEATURES@@ @@USE@@ emerge -1 @@EMERGEOPTS@@ @@CPV@@ 2>&1 1>/dev/tty ) -if [[ $? == 0 ]] ; then - echo "@@FEATURES@@ @@USE@@ succeeded for @@CPV@@" >> @@REPORTFILE@@ -else - @@USE@@ @@FEATURES@@ tatt_pkg_error "@@CPV@@" "${eout}" -fi +@@USE@@ T@@FEATURES@@ tatt_test_pkg "@@CPV@@" diff --git a/templates/tatt_functions.sh b/templates/tatt_functions.sh new file mode 100644 index 0000000..9aeed69 --- /dev/null +++ b/templates/tatt_functions.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +function tatt_pkg_error +{ + local eout=${2} + + echo "${eout}" + + if [ -n "${USE}" ]; then + echo -n "USE='${USE}'" >> "${TATT_REPORTFILE}" + fi + if [ -n "${FEATURES}" ]; then + echo -n " FEATURES='${FEATURES}'" >> "${TATT_REPORTFILE}" + fi + + if [[ "${eout}" =~ REQUIRED_USE ]] ; then + echo " : REQUIRED_USE not satisfied (probably) for ${1:?}" >> "${TATT_REPORTFILE}" + elif [[ "${eout}" =~ USE\ changes ]] ; then + echo " : USE dependencies not satisfied (probably) for ${1:?}" >> "${TATT_REPORTFILE}" + elif [[ "${eout}" =~ keyword\ changes ]]; then + echo " : unkeyworded dependencies (probably) for ${1:?}" >> "${TATT_REPORTFILE}" + elif [[ "${eout}" =~ Error:\ circular\ dependencies: ]]; then + echo " : circular dependencies (probably) for ${1:?}" >> "${TATT_REPORTFILE}" + elif [[ "${eout}" =~ Blocked\ Packages ]]; then + echo " : blocked packages (probably) for ${1:?}" >> "${TATT_REPORTFILE}" + else + echo " failed for ${1:?}" >> "${TATT_REPORTFILE}" + fi + + CP=${1#=} + BUILDLOG=/var/tmp/portage/${CP}/temp/build.log + if [[ -n "${TATT_BUILDLOGDIR}" && -s "${BUILDLOG}" ]]; then + LOGNAME=$(mktemp -p "${TATT_BUILDLOGDIR}" "${CP/\//_}_${TATT_TEST_TYPE}_XXXXX") + mv "${BUILDLOG}" "${LOGNAME}" + echo " log has been saved as ${LOGNAME}" >> "${TATT_REPORTFILE}" + fi +} + +function tatt_test_pkg +{ + if [ -n "${TFEATURES}" ]; then + if ! emerge --onlydeps -1 --with-test-deps ${TATT_EMERGEOPTS} "${1:?}"; then + echo "merging test dependencies of ${1} failed" >> "${TATT_REPORTFILE}" + return 0 + fi + fi + + eout=$( FEATURES="${TFEATURES}" emerge -1 ${TATT_EMERGEOPTS} "${1:?}" 2>&1 1>/dev/tty ) + if [[ $? == 0 ]] ; then + if [ -n "${TFEATURES}" ]; then + echo -n "FEATURES='${TFEATURES}' " >> "${TATT_REPORTFILE}" + fi + echo "USE='${USE}' succeeded for ${1:?}" >> "${TATT_REPORTFILE}" + else + FEATURES="${TFEATURES}" tatt_pkg_error "${1:?}" "${eout}" + fi +} diff --git a/templates/use-header b/templates/use-header index 4000a68..d18e080 100644 --- a/templates/use-header +++ b/templates/use-header @@ -3,40 +3,11 @@ trap "echo 'signal captured, exiting the entire script...'; exit" SIGHUP SIGINT SIGTERM -function tatt_pkg_error -{ - local eout=${2} +export TATT_TEST_TYPE="use" +export TATT_REPORTFILE="@@REPORTFILE@@" +export TATT_BUILDLOGDIR="@@BUILDLOGDIR@@" +export TATT_EMERGEOPTS="@@EMERGEOPTS@@" - echo "${eout}" - - if [ -n "${USE}" ]; then - echo -n "USE='${USE}'" >> @@REPORTFILE@@ - fi - if [ -n "${FEATURES}" ]; then - echo -n " FEATURES='${FEATURES}'" >> @@REPORTFILE@@ - fi - - if [[ "${eout}" =~ REQUIRED_USE ]] ; then - echo " : REQUIRED_USE not satisfied (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ USE\ changes ]] ; then - echo " : USE dependencies not satisfied (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ keyword\ changes ]]; then - echo " : unkeyworded dependencies (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ Error:\ circular\ dependencies: ]]; then - echo " : circular dependencies (probably) for ${1:?}" >> @@REPORTFILE@@ - elif [[ "${eout}" =~ Blocked\ Packages ]]; then - echo " : blocked packages (probably) for ${1:?}" >> @@REPORTFILE@@ - else - echo " failed for ${1:?}" >> @@REPORTFILE@@ - fi - - CP=${1#=} - BUILDLOG=/var/tmp/portage/${CP}/temp/build.log - if [[ -n "@@BUILDLOGDIR@@" && -s "${BUILDLOG}" ]]; then - LOGNAME=$(mktemp -p "@@BUILDLOGDIR@@" "${CP/\//_}_use_XXXXX") - mv "${BUILDLOG}" "${LOGNAME}" - echo " log has been saved as ${LOGNAME}" >> @@REPORTFILE@@ - fi -} +source "@@TEMPLATEDIR@@tatt_functions.sh" echo -e "USE tests started on $(date)\n" >> @@REPORTFILE@@ -- cgit v1.2.3-65-gdbad