Use loop for interface functions
This commit is contained in:
parent
4123b712fc
commit
cf4a38367e
|
@ -34,19 +34,19 @@ export TEXTDOMAIN=${PROJECT_NAME}-tests
|
|||
export TEXTDOMAINDIR="/usr/share/locale"
|
||||
|
||||
function show_help {
|
||||
echo ''
|
||||
echo $"${PROJECT_NAME}-tests"
|
||||
echo ''
|
||||
echo $'Runs tests on the system'
|
||||
echo ''
|
||||
echo $' --help Show help'
|
||||
echo ''
|
||||
exit 0
|
||||
echo ''
|
||||
echo $"${PROJECT_NAME}-tests"
|
||||
echo ''
|
||||
echo $'Runs tests on the system'
|
||||
echo ''
|
||||
echo $' --help Show help'
|
||||
echo ''
|
||||
exit 0
|
||||
}
|
||||
|
||||
function test_app_function_type {
|
||||
filename=$1
|
||||
fn_type=$2
|
||||
filename=$1
|
||||
fn_type=$2
|
||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
||||
app_function=$(cat "${filename}" | grep "function ${fn_type}_${app_name} {" | awk -F "${fn_type}_" '{print $2}' | awk -F ' ' '{print $1}')
|
||||
if [ ! ${app_function} ]; then
|
||||
|
@ -63,28 +63,34 @@ function test_app_functions {
|
|||
else
|
||||
FILES=/usr/bin/${PROJECT_NAME}-app-*
|
||||
fi
|
||||
|
||||
|
||||
# check that these functions exist
|
||||
interface_functions=( install remove backup )
|
||||
|
||||
# for all the app scripts
|
||||
for filename in $FILES
|
||||
do
|
||||
test_app_function_type ${filename} install
|
||||
test_app_function_type ${filename} remove
|
||||
test_app_function_type ${filename} backup
|
||||
done
|
||||
# for each expected interface function
|
||||
for f in "${interface_functions[@]}"
|
||||
do
|
||||
test_app_function_type ${filename} $f
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
while [[ $# > 1 ]]
|
||||
do
|
||||
key="$1"
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
case $key in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo $'Running tests'
|
||||
|
|
Loading…
Reference in New Issue