Updated tests

This commit is contained in:
Héctor Molinero Fernández 2020-11-12 21:17:38 +01:00
commit 1d58f9b3ff
50 changed files with 865 additions and 167 deletions

View file

@ -0,0 +1,2 @@
single-entry-000.com
entry-with-comment-000.com

View file

@ -0,0 +1,2 @@
denied-entry-000.com
denied-entry-001.com

View file

@ -12,7 +12,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
# Set base environment. # Set base environment.
export HOSTNAME='hblock' export HOSTNAME='hblock'
export ETCDIR="${SCRIPT_DIR:?}/etc" export ETCDIR="${SCRIPT_DIR:?}/etc"
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt" export XDG_CONFIG_HOME="${ETCDIR:?}"
runInTestShell() { runInTestShell() {
${TEST_SHELL:-/bin/sh} -- "${@-}" 2>&1 ||: ${TEST_SHELL:-/bin/sh} -- "${@-}" 2>&1 ||:

View file

@ -0,0 +1,2 @@
Footer line 1
Footer line 2

View file

@ -0,0 +1,2 @@
Header line 1
Header line 2

View file

@ -13,7 +13,9 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
printf -- 'Test - Main: Double dash argument\n' export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
printf -- 'Test - Main - Argument: Double dash argument\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -- -v)" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -- -v)"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then

View file

@ -13,7 +13,9 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
printf -- 'Test - Main: Invalid long option\n' export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
printf -- 'Test - Main - Argument: Invalid long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --invalid='VALUE')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --invalid='VALUE')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then

View file

@ -13,7 +13,9 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
printf -- 'Test - Main: Invalid short option\n' export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
printf -- 'Test - Main - Argument: Invalid short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -i 'VALUE')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -i 'VALUE')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then

View file

@ -1,24 +0,0 @@
#!/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() {
printf -- 'Test - Main: Default options\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -0,0 +1 @@
[ERROR] No such file: /hblock/invalid.txt

View file

@ -0,0 +1,32 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 15
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,83 @@
#!/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:?}/sources.txt"
export HBLOCK_ALLOWLIST_FILE=''
printf -- 'Test - Main - Allowlist: "-A" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -A "${SCRIPT_DIR:?}/allowlist.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "--allowlist" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist="${SCRIPT_DIR:?}/allowlist.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "builtin" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='builtin')"
expected="$(cat -- "${0%.sh}"-builtin.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "none" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='none')"
expected="$(cat -- "${0%.sh}"-none.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "-" value\n'
actual="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='-')"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "--allowlist" long option with a non-existent file\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='/hblock/invalid.txt')"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable\n'
actual="$(HBLOCK_ALLOWLIST_FILE="${SCRIPT_DIR:?}/allowlist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable with a non-existent file\n'
actual="$(HBLOCK_ALLOWLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST" environment variable\n'
actual="$(HBLOCK_ALLOWLIST="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -13,21 +13,29 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
export HBLOCK_COMMENT='#' export HBLOCK_COMMENT='#'
printf -- 'Test - Main: "-C" short option\n' printf -- 'Test - Main - Comment: "-C" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -C '# %')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -C '# %')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main: "--comment" long option\n' printf -- 'Test - Main - Comment: "--comment" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --comment='# %')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --comment='# %')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main - Comment: "HBLOCK_COMMENT" environment variable\n'
actual="$(HBLOCK_COMMENT='# %' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
} }
main "${@-}" main "${@-}"

View file

@ -0,0 +1,34 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1 @@
[ERROR] No such file: /hblock/invalid.txt

View file

@ -0,0 +1,33 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 16
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,35 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 18
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 denied-entry-000.com
0.0.0.0 denied-entry-001.com
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,83 @@
#!/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:?}/sources.txt"
export HBLOCK_DENYLIST_FILE=''
printf -- 'Test - Main - Denylist: "-D" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -D "${SCRIPT_DIR:?}/denylist.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "--denylist" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist="${SCRIPT_DIR:?}/denylist.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "--denylist" long option with "builtin" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='builtin')"
expected="$(cat -- "${0%.sh}"-builtin.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "--denylist" long option with "none" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='none')"
expected="$(cat -- "${0%.sh}"-none.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "--denylist" long option with "-" value\n'
actual="$(cat -- "${SCRIPT_DIR:?}/denylist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='-')"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "--denylist" long option with a non-existent file\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='/hblock/invalid.txt')"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable\n'
actual="$(HBLOCK_DENYLIST_FILE="${SCRIPT_DIR:?}/denylist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable with a non-existent file\n'
actual="$(HBLOCK_DENYLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST" environment variable\n'
actual="$(HBLOCK_DENYLIST="$(cat -- "${SCRIPT_DIR:?}/denylist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -0,0 +1,34 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1 @@
[ERROR] No such file: /hblock/invalid.txt

View file

@ -0,0 +1,34 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,39 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST
# BEGIN FOOTER
Footer line 1
Footer line 2
# END FOOTER

View file

@ -0,0 +1,83 @@
#!/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:?}/sources.txt"
export HBLOCK_FOOTER_FILE=''
printf -- 'Test - Main - Footer: "-F" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -F "${SCRIPT_DIR:?}/footer.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "--footer" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer="${SCRIPT_DIR:?}/footer.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "--footer" long option with "builtin" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='builtin')"
expected="$(cat -- "${0%.sh}"-builtin.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "--footer" long option with "none" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='none')"
expected="$(cat -- "${0%.sh}"-none.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "--footer" long option with "-" value\n'
actual="$(cat -- "${SCRIPT_DIR:?}/footer.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='-')"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "--footer" long option with a non-existent file\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='/hblock/invalid.txt')"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable\n'
actual="$(HBLOCK_FOOTER_FILE="${SCRIPT_DIR:?}/footer.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable with a non-existent file\n'
actual="$(HBLOCK_FOOTER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER" environment variable\n'
actual="$(HBLOCK_FOOTER="$(cat -- "${SCRIPT_DIR:?}/footer.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -0,0 +1,34 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1 @@
[ERROR] No such file: /hblock/invalid.txt

View file

@ -0,0 +1,22 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,27 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
Header line 1
Header line 2
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,83 @@
#!/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:?}/sources.txt"
export HBLOCK_HEADER_FILE=''
printf -- 'Test - Main - Header: "-H" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -H "${SCRIPT_DIR:?}/header.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "--header" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header="${SCRIPT_DIR:?}/header.txt")"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "--header" long option with "builtin" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='builtin')"
expected="$(cat -- "${0%.sh}"-builtin.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "--header" long option with "none" value\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='none')"
expected="$(cat -- "${0%.sh}"-none.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "--header" long option with "-" value\n'
actual="$(cat -- "${SCRIPT_DIR:?}/header.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='-')"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "--header" long option with a non-existent file\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='/hblock/invalid.txt')"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable\n'
actual="$(HBLOCK_HEADER_FILE="${SCRIPT_DIR:?}/header.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable with a non-existent file\n'
actual="$(HBLOCK_HEADER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-invalid.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Header: "HBLOCK_HEADER" environment variable\n'
actual="$(HBLOCK_HEADER="$(cat -- "${SCRIPT_DIR:?}/header.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -0,0 +1,34 @@
# Generated with: https://github.com/hectorm/hblock
# Blocked domains: 17
# BEGIN HEADER
127.0.0.1 localhost hblock
255.255.255.255 broadcasthost
::1 localhost hblock
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# END HEADER
# BEGIN BLOCKLIST
0.0.0.0 entry-with-comment-000.com
0.0.0.0 entry-with-comment-001.com
0.0.0.0 entry-with-comment-002.com
0.0.0.0 entry-with-comment-003.com
0.0.0.0 entry-with-comment-004.com
0.0.0.0 entry-with-prefix-000.com
0.0.0.0 entry-with-prefix-001.com
0.0.0.0 entry-with-prefix-002.com
0.0.0.0 entry-with-prefix-003.com
0.0.0.0 entry-with-prefix-004.com
0.0.0.0 entry-with-prefix-005.com
0.0.0.0 entry-with-prefix-006.com
0.0.0.0 hblock-check.molinero.dev
0.0.0.0 single-entry-000.com
0.0.0.0 single-entry-001.com
0.0.0.0 single-entry-002.com
0.0.0.0 single-entry-003.com
# END BLOCKLIST

View file

@ -0,0 +1,50 @@
#!/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:?}/sources.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="$(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 "${@-}"

View file

@ -13,21 +13,29 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
export HBLOCK_REDIRECTION='0.0.0.0' export HBLOCK_REDIRECTION='0.0.0.0'
printf -- 'Test - Main: "-R" short option\n' printf -- 'Test - Main - Redirection: "-R" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -R '::1')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -R '::1')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main: "--redirection" long option\n' printf -- 'Test - Main - Redirection: "--redirection" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --redirection='::1')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --redirection='::1')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main - Redirection: "HBLOCK_REDIRECTION" environment variable\n'
actual="$(HBLOCK_REDIRECTION='::1' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
} }
main "${@-}" main "${@-}"

View file

@ -0,0 +1,63 @@
#!/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:?}/sources.txt"
export HBLOCK_REGEX='false'
# shellcheck disable=SC2155
export HBLOCK_ALLOWLIST="$(cat <<-'EOF'
.*-00[0-3]\.com$
^entry-with-comment-
EOF
)"
printf -- 'Test - Main - Regex: "-r" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -r)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Regex: "--regex" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --regex)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main - Regex: "HBLOCK_REGEX" environment variable\n'
actual="$(HBLOCK_REGEX='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}"-true.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
export HBLOCK_REGEX='true'
# shellcheck disable=SC2155
export HBLOCK_ALLOWLIST="$(cat <<-'EOF'
.*-00[0-3]\.com$
^entry-with-comment-
single-entry-000.com
EOF
)"
printf -- 'Test - Main - Regex: "--no-regex" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-regex)"
expected="$(cat -- "${0%.sh}"-false.out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -13,21 +13,29 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
export HBLOCK_TEMPLATE='%R %D' export HBLOCK_TEMPLATE='%R %D'
printf -- 'Test - Main: "-T" short option\n' printf -- 'Test - Main - Template: "-T" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -T '%D\n\t└─ %R')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -T '%D\n\t└─ %R')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main: "--template" long option\n' printf -- 'Test - Main - Template: "--template" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --template='%D\n\t└─ %R')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --template='%D\n\t└─ %R')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main - Template: "HBLOCK_TEMPLATE" environment variable\n'
actual="$(HBLOCK_TEMPLATE='%D\n\t└─ %R' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
} }
main "${@-}" main "${@-}"

View file

@ -13,21 +13,29 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
. "${SCRIPT_DIR:?}"/env.sh . "${SCRIPT_DIR:?}"/env.sh
main() { main() {
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/sources.txt"
export HBLOCK_WRAP='1' export HBLOCK_WRAP='1'
printf -- 'Test - Main: "-W" short option\n' printf -- 'Test - Main - Wrap: "-W" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -W '5')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -W '5')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main: "--wrap" long option\n' printf -- 'Test - Main - Wrap: "--wrap" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --wrap='5')" actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --wrap='5')"
expected="$(cat -- "${0%.sh}".out)" expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then if ! assertEquals "${actual?}" "${expected?}"; then
exit 1 exit 1
fi fi
printf -- 'Test - Main - Wrap: "HBLOCK_WRAP" environment variable\n'
actual="$(HBLOCK_WRAP='5' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
} }
main "${@-}" main "${@-}"

View file

@ -1,33 +0,0 @@
#!/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_LENIENT='false'
printf -- 'Test - Main: "-l" short option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -l)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
printf -- 'Test - Main: "--lenient" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --lenient)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -1,26 +0,0 @@
#!/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_LENIENT='true'
printf -- 'Test - Main: "--no-lenient" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-lenient)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -1,33 +0,0 @@
#!/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='true'
# shellcheck disable=SC2155
export HBLOCK_ALLOWLIST="$(cat <<-'EOF'
.*-00[0-3]\.com$
^entry-with-comment-
single-entry-000.com
EOF
)"
printf -- 'Test - Main: "--no-regex" long option\n'
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-regex)"
expected="$(cat -- "${0%.sh}".out)"
if ! assertEquals "${actual?}" "${expected?}"; then
exit 1
fi
}
main "${@-}"

View file

@ -1,39 +0,0 @@
#!/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 "${@-}"