Skip to content

Commit

Permalink
os-autoinst-testapi-usage: Allow to import for testability and extend…
Browse files Browse the repository at this point in the history
…ability
  • Loading branch information
okurz committed Oct 18, 2024
1 parent 532aad8 commit 7881226
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions os-autoinst-testapi-usage
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@ EOF
exit "$1"
}

opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1
eval set -- "$opts"
while true; do
case "$1" in
-h | --help) usage 0 ;;
--)
shift
break
;;
*) break ;;
esac
done

which rg &> /dev/null || {
echo "rg (ripgrep) not found, please install it first" >&2
exit 2
}

if [ -f "$1" ]; then
testapi_path=$1
else
testapi_path=$1/testapi.pm
fi
shift

[ -r "$testapi_path" ] || {
echo "$testapi_path not found" >&2
exit 1
}
grep -q 'package testapi' "$testapi_path" || echo "Warning: provided file does not look like testapi.pm" >&2

while (($#)); do
get_function_list | while read -r; do
echo "$1 - ${REPLY} : $(rgg "${REPLY}" "$1" | tail -8 | head -n1)"
main() {
opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1
eval set -- "$opts"
while true; do
case "$1" in
-h | --help) usage 0 ;;
--)
shift
break
;;
*) break ;;
esac
done
which rg &> /dev/null || {
echo "rg (ripgrep) not found, please install it first" >&2
exit 2
}
if [ -f "$1" ]; then
testapi_path=$1
else
testapi_path=$1/testapi.pm
fi
shift
done
[ -r "$testapi_path" ] || {
echo "$testapi_path not found" >&2
exit 1
}
grep -q 'package testapi' "$testapi_path" || echo "Warning: provided file does not look like testapi.pm" >&2
while (($#)); do
get_function_list | while read -r; do
echo "$1 - ${REPLY} : $(rgg "${REPLY}" "$1" | tail -8 | head -n1)"
done
shift
done
}

caller 0 > /dev/null || main "$@"

0 comments on commit 7881226

Please sign in to comment.