testing: handle empty glob cases

If kpatch-test looks for *.patch or *.test globs in a directory that
contains no such files, it will try to handle a single file named
"*.patch" or "*.test".

Set the global nullglob option to avoid this problem.  At the same time,
stop and whine to the user if no .patch files were found.
This commit is contained in:
Joe Lawrence 2017-01-09 11:12:28 -05:00
parent 23bc1bc93d
commit 1096da7155

View File

@ -40,6 +40,8 @@
# built from the *.patch files. They can be used for more custom tests above
# and beyond the simple loading and unloading tests.
shopt -s nullglob
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
ROOTDIR="$(readlink -f $SCRIPTDIR/../..)"
# TODO: option to use system-installed binaries instead
@ -95,6 +97,10 @@ done
if [[ ${#PATCH_LIST[@]} = 0 ]]; then
PATCH_LIST=($PATCHDIR/*.patch)
TEST_LIST=($PATCHDIR/*.test)
if [[ ${#PATCH_LIST[@]} = 0 ]]; then
echo "No patches found!"
exit 1
fi
else
for file in "${PATCH_LIST[@]}"; do
prefix=${file%%.patch}