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.
This commit is contained in:
Michal Domonkos 2023-10-26 17:31:06 +02:00 committed by Panu Matilainen
parent 61000db0bc
commit 9ae317a81b
1 changed files with 10 additions and 13 deletions

View File

@ -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