From 00a00f6dda513cc943636d6b7df174e71ba015de Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 30 Jan 2025 20:27:13 +0100 Subject: [PATCH] chore(linux): preserve log files when running tests under Docker This change copies the log files that get created during a test run to the `build/docker-linux/tmp` directory. Also fixes a bug when not running in docker. Also create log file for test server. --- linux/ibus-keyman/tests/scripts/run-tests.sh | 6 +++++- linux/ibus-keyman/tests/scripts/test-helper.inc.sh | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/linux/ibus-keyman/tests/scripts/run-tests.sh b/linux/ibus-keyman/tests/scripts/run-tests.sh index 012dee996f..4b28327259 100755 --- a/linux/ibus-keyman/tests/scripts/run-tests.sh +++ b/linux/ibus-keyman/tests/scripts/run-tests.sh @@ -65,7 +65,11 @@ function run_tests() { setup "$DISPLAY_SERVER" "$ENV_FILE" "$CLEANUP_FILE" "$PID_FILE" --standalone - echo "# NOTE: When the tests fail check /tmp/ibus-engine-keyman.log and /tmp/ibus-daemon.log!" + if [[ "${DOCKER_RUNNING:-false}" == "true" ]]; then + echo "# NOTE: When the tests fail check ibus-engine-keyman.log, ibus-daemon.log and km-test-server.log in build/docker-linux/tmp/!" + else + echo "# NOTE: When the tests fail check /tmp/ibus-engine-keyman.log, /tmp/ibus-daemon.log and /tmp/km-test-server.log!" + fi echo "" if [ $# -gt 0 ]; then diff --git a/linux/ibus-keyman/tests/scripts/test-helper.inc.sh b/linux/ibus-keyman/tests/scripts/test-helper.inc.sh index 940c5ad310..3287acd05c 100755 --- a/linux/ibus-keyman/tests/scripts/test-helper.inc.sh +++ b/linux/ibus-keyman/tests/scripts/test-helper.inc.sh @@ -140,7 +140,7 @@ function _setup_test_dbus_server() { CLEANUP_FILE=$2 # Start test dbus server. This will create `/tmp/km-test-server.env`. - "${TOP_BINDIR}/tests/km-dbus-test-server" &> /dev/null & + "${TOP_BINDIR}/tests/km-dbus-test-server" &> /tmp/km-test-server.log & sleep 1 cat /tmp/km-test-server.env >> "$ENV_FILE" @@ -251,7 +251,7 @@ function _setup_ibus() { #shellcheck disable=SC2086 ibus-daemon ${ARG_VERBOSE-} --daemonize --panel=disable --address=unix:abstract="${TEMP_DATA_DIR}/test-ibus" ${IBUS_CONFIG-} &> /tmp/ibus-daemon.log PID=$(pgrep -f "${TEMP_DATA_DIR}/test-ibus") - if [[ "${STANDALONE}" == "--standalone" ]] && [[ ! "${DOCKER_RUNNING:-false}" ]]; then + if [[ "${STANDALONE}" == "--standalone" ]] && [[ "${DOCKER_RUNNING:-false}" != "true" ]]; then # manual test run echo "if kill -9 ${PID}; then ibus restart || ibus start; fi # ibus-daemon" >> "${CLEANUP_FILE}" else @@ -321,6 +321,15 @@ function cleanup() { rm "$CLEANUP_FILE" echo "# Finished shutdown of processes." fi + + if [[ "${DOCKER_RUNNING:-false}" == "true" ]]; then + # Note: build/tmp is build/docker-linux/tmp on the host! + BUILD_TMP="$(dirname "$0")/../../../build/tmp" + mkdir -p "${BUILD_TMP}" + [[ -f /tmp/ibus-engine-keyman.log ]] && mv /tmp/ibus-engine-keyman.log "${BUILD_TMP}/ibus-engine-keyman.log" + [[ -f /tmp/ibus-daemon.log ]] && mv /tmp/ibus-daemon.log "${BUILD_TMP}/ibus-daemon.log" + [[ -f /tmp/km-test-server.log ]] && mv /tmp/km-test-server.log "${BUILD_TMP}/km-test-server.log" + fi } function exit_on_package_build() {