From 9ae317a81b223ec8e2c097f4cf637fdd0ea34e63 Mon Sep 17 00:00:00 2001 From: Michal Domonkos Date: Thu, 26 Oct 2023 17:31:06 +0200 Subject: [PATCH] Refactor rpmtests wrapper Don't symlink rpmtests itself, we can run it directly from the installation directory in the test tree. This eliminates some extra cd-ing. No functional change. --- tests/rpmtests.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/rpmtests.sh b/tests/rpmtests.sh index e821d9dff..77749aee0 100755 --- a/tests/rpmtests.sh +++ b/tests/rpmtests.sh @@ -1,21 +1,20 @@ #!/bin/bash # -# Wrapper for rpmtests that looks for atlocal in the script's directory instead -# of $PWD or the one specified with -C. In addition, implements the -L | --log -# option to print the test log when done. +# Wrapper around rpmtests that adds a couple of useful options/overrides: +# -C, --directory DIR +# like original -C but loads atlocal from script's directory if missing +# -L, --log +# print the test log when done SCRIPT_DIR=$(dirname $(readlink -f $0)) -SCRIPT_FILES="rpmtests atlocal mktree.common" +SCRIPT_FILES="atlocal mktree.common" -TARGET_DIR=$PWD PRINT_LOG=0 -cd "$SCRIPT_DIR" - while [ $# != 0 ]; do case $1 in -C | --directory ) - TARGET_DIR="$2" + cd "$2" shift ;; -L | --log ) @@ -28,15 +27,13 @@ while [ $# != 0 ]; do shift done -# Symlink script files into $TARGET_DIR, prefer local versions though +# Symlink script files into $PWD, prefer local versions though for file in $SCRIPT_FILES; do - [ -f "$TARGET_DIR/$file" ] || ln -s $PWD/$file $TARGET_DIR/ + [ -f "$file" ] || ln -s $SCRIPT_DIR/$file . done -cd "$TARGET_DIR" - # Run the test suite -./rpmtests "$@"; RC=$? +$SCRIPT_DIR/rpmtests "$@"; RC=$? [ $PRINT_LOG == 1 ] && cat rpmtests.log # Clean up the symlinks