From aa8b889eb556629d58fbb13ca44eefcc6f7e01c1ea0a93acaf588c9b34ba3046 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 11 Mar 2019 12:47:45 +0000 Subject: [PATCH] Correct tests.sh. OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=299 --- tests.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests.sh b/tests.sh index 4ae0563..2640d35 100644 --- a/tests.sh +++ b/tests.sh @@ -86,7 +86,7 @@ require_git() { git version >/dev/null 2>&1 ; } ################################################################################ -[ "${#TESTS[@]}" -eq 0 ] || abort "integration tests executable not found in $DOCKER_DIR" +[ "${#TESTS[@]}" -gt 0 ] || abort "integration tests executable not found in $DOCKER_DIR" [ "$EUID" -eq 0 ] || abort "this script must be run as root" [ -n "$VERSION" ] || abort "could not obtain version" @@ -191,8 +191,8 @@ cleanup() { systemctl restart docker.service log "Removing images and containers..." - docker ps -aq | xargs docker rm -f - docker images -q | xargs docker rmi -f + docker ps -aq | xargs docker rm -f &>/dev/null || : + docker images -q | xargs docker rmi -f &>/dev/null || : log "Removing extra files and restoring backups..." restore_backup /etc/subuid /etc/subgid @@ -202,14 +202,16 @@ trap cleanup EXIT cd "$DOCKER_DIR" -log "Preparing the environment..." export MAKEDIR="$SCRIPTS_DIR/make" export DOCKER_HOST="$DOCKER_TEST_HOST" -bundle .integration-daemon-setup # Clean up all images on the host -- this is key to avoid test run failures. -docker ps -aq | xargs docker rm -f -docker images -q | xargs docker rmi -f +log "Cleaning the environment..." +docker ps -aq | xargs docker rm -f &>/dev/null || : +docker images -q | xargs docker rmi -f &>/dev/null || : + +log "Preparing the environment..." +bundle .integration-daemon-setup # XXX: Really this should be sourced from the Dockerfile but this is good # enough for now. This comes from the Docker 18.09.1-ce Dockerfile. @@ -223,11 +225,12 @@ ln -sf "$FROZEN_IMAGES_DIR" "$FROZEN_IMAGES_LINK" debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \ hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c +rm "$TEST_LOG" for TEST in "${TESTS[@]}" do cd "$(dirname "$TEST")" log "Running integration test ($TEST)..." | tee -a "$TEST_LOG" - "$TEST" "${TEST_ARGS[@]}" 2>&1 | tee -a "$TEST_LOG" || /bin/true + "$TEST" "${TEST_ARGS[@]}" 2>&1 | tee -a "$TEST_LOG" || : done if [ -n "$ENABLE_XUNIT" ] ; then log "Generating xunit logs..."