hblock/resources/tests/test-main-regex-opt.sh
Héctor Molinero Fernández 9f716ffb94 Updated tests
2020-10-31 16:25:46 +01:00

39 lines
948 B
Bash
Executable file

#!/bin/sh
# Author: Héctor Molinero Fernández <hector@molinero.dev>
# License: MIT, https://opensource.org/licenses/MIT
# Repository: https://github.com/hectorm/hblock
set -eu
export LC_ALL='C'
SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
# shellcheck disable=SC1090
. "${SCRIPT_DIR:?}"/env.sh
main() {
export HBLOCK_REGEX='false'
# shellcheck disable=SC2155
export HBLOCK_ALLOWLIST="$(cat <<-'EOF'
.*-00[0-3]\.com$
^entry-with-comment-
EOF
)"
printf -- 'Test - Main: "-r" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -r)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main: "--regex" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --regex)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"