hblock/resources/tests/test-main-feature-lenient.sh
Héctor Molinero Fernández e34217ee24 Removed double dash from "printf".
It's not necessary and the Toybox implementation interprets it literally.
2021-02-28 16:27:42 +01:00

50 lines
1.5 KiB
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_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
export HBLOCK_LENIENT='false'
printf 'Test - Main - Lenient: "-l" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -l)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf 'Test - Main - Lenient: "--lenient" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --lenient)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf 'Test - Main - Lenient: "HBLOCK_LENIENT" environment variable\n'
actual="$(set -a; HBLOCK_LENIENT='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
export HBLOCK_LENIENT='true'
printf 'Test - Main - Lenient: "--no-lenient" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-lenient)"
expected="$(cat -- "${0%.sh}"-false.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"