From 34e32b751d8060f93646d3fa542ddea73de901c4 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Wed, 14 Sep 2022 16:17:22 +0200 Subject: ci: correctly generate tests reports Do not use make test to run the tests after the build, as it overwrites the report file for each single unit tests. Signed-off-by: Mauro Sardara Change-Id: Icdc55b31c1e36b213f977b76f8518ac16c393afc --- scripts/build-packages.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'scripts/build-packages.sh') diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh index 598b3f626..dddc98deb 100644 --- a/scripts/build-packages.sh +++ b/scripts/build-packages.sh @@ -17,6 +17,20 @@ set -euxo pipefail SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) source ${SCRIPT_PATH}/functions.sh +BUILD_PATH="${SCRIPT_PATH}/../packages" +TEST_REPORT_DIR="${BUILD_PATH}/reports" +BUILD_ROOT_DIR="${BUILD_PATH}/build-root/bin" +MAKE_FOLDER="${SCRIPT_PATH}/.." + +function execute_tests() { + mkdir -p "${TEST_REPORT_DIR}" + pushd "${BUILD_ROOT_DIR}" + for component in "${TEST_COMPONENTS[@]}"; do + GTEST_OUTPUT="xml:${TEST_REPORT_DIR}/${component}-report.xml" "./${component}_tests" + done + popd +} + # Parameters: # $1 = Package name # @@ -28,18 +42,11 @@ function build_package() { echo "*******************************************************************" # Run unit tests and make the package - export GTEST_OUTPUT="xml:report.xml" - make -C "${SCRIPT_PATH}/.." BUILD_PATH="${SCRIPT_PATH}/../packages" INSTALL_PREFIX=/usr test package-release - - pushd ${SCRIPT_PATH}/../packages - # Find and collect reports - mkdir -p reports - REPORTS=($(find . -iname 'report.xml')) - echo "${REPORTS[@]}" - for report in "${REPORTS[@]}"; do - mv "${report}" "reports/$(echo ${report} | awk -F/ '{print $(2)"-"$(NF)}')" - done + make -C "${MAKE_FOLDER}" BUILD_PATH="${BUILD_PATH}" INSTALL_PREFIX=/usr package-release + + execute_tests + pushd "${BUILD_PATH}" find . -not -name '*.deb' \ -not -name '*.rpm' \ -not -name 'reports' \ -- cgit 1.2.3-korg