diff --git a/abuild.in b/abuild.in index 8fb4131..50175ca 100755 --- a/abuild.in +++ b/abuild.in @@ -2731,7 +2731,6 @@ usage() { CTARGET Arch or hostspec of machine to generate compiler for EOF - exit 0 } APKBUILD="${APKBUILD:-./APKBUILD}" @@ -2745,7 +2744,7 @@ while getopts ":AcdD:fFhkKmnP:qrRs:uvV" opt; do 'D') DESCRIPTION=$OPTARG;; 'f') force="-f";; 'F') forceroot="-F";; - 'h') usage;; + 'h') usage; exit 0;; 'k') keep="-k";; 'K') keep_build="-K";; 'm') disable_colors @@ -2757,7 +2756,7 @@ while getopts ":AcdD:fFhkKmnP:qrRs:uvV" opt; do 's') SRCDEST=$OPTARG;; 'v') set -x;; 'V') echo "$program $program_version"; exit 0;; - '?') die "Unrecognized option: $OPTARG";; + '?') error "Unrecognized option: $OPTARG"; usage >&2; exit 1;; esac done shift $(( $OPTIND - 1 )) diff --git a/tests/abuild_test b/tests/abuild_test new file mode 100755 index 0000000..fb3e683 --- /dev/null +++ b/tests/abuild_test @@ -0,0 +1,21 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/test_env.sh +init_tests \ + abuild_help \ + abuild_invalid_opt + +DATADIR=$(atf_get_srcdir)/testdata +export ABUILD_SHAREDIR=$(atf_get_srcdir)/.. + +abuild_help_body() { + atf_check -s exit:0 \ + -o match:"usage:" \ + abuild -h +} + +abuild_invalid_opt_body() { + atf_check -s exit:1 \ + -e match:"usage:" \ + abuild -@ +}