aboutsummaryrefslogtreecommitdiff
path: root/tests/tests-lib.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-28 07:22:55 -0300
committerEuAndreh <eu@euandre.org>2021-06-28 07:23:33 -0300
commit9ff2e3088d04a069b786f30a0fd86bccd7c0686e (patch)
treea01691686958c349ecb02c260ed989328212e9e2 /tests/tests-lib.sh
parentTODOs.md: Add #task-06c8ef1b-15ed-5932-3391-8c02ff759e7a (diff)
downloadremembering-9ff2e3088d04a069b786f30a0fd86bccd7c0686e.tar.gz
remembering-9ff2e3088d04a069b786f30a0fd86bccd7c0686e.tar.xz
git mv tests/tests-lib.sh tests/lib.sh
Diffstat (limited to 'tests/tests-lib.sh')
-rwxr-xr-xtests/tests-lib.sh123
1 files changed, 0 insertions, 123 deletions
diff --git a/tests/tests-lib.sh b/tests/tests-lib.sh
deleted file mode 100755
index 76f22e3..0000000
--- a/tests/tests-lib.sh
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/bin/sh
-
-end="\033[0m"
-red="\033[0;31m"
-green="\033[0;32m"
-yellow="\033[0;33m"
-
-N=
-OUT=
-ERR=
-STATUS=
-
-ERROR() {
- # shellcheck disable=2059
- printf "${red}ERROR${end}"
-}
-
-print_debug_info() {
- printf 'LINENO: %s\nOUT: %s\n%s: %s\n' "$N" "$OUT" "$(ERROR)" "$ERR" >&2
-}
-
-assert_status() {
- if [ "$STATUS" != "$1" ]; then
- printf '\n%s: Bad status.\n\nexpected: %s\ngot: %s\n' \
- "$(ERROR)" "$1" "$STATUS" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_usage() {
- if ! grep -Fq 'Usage' "$1"; then
- echo 'Expected to find "Usage" text, it was missing:' >&2
- cat "$1" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_empty_stream() {
- if [ -s "$2" ]; then
- printf '\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' \
- "$(ERROR)" "$1" "$2" "$(cat "$2")" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_empty_stdout() {
- assert_empty_stream STDOUT "$OUT"
-}
-
-assert_empty_stderr() {
- assert_empty_stream STDERR "$ERR"
-}
-
-assert_stream() {
- if [ "$(cat "$2")" != "$3" ]; then
- printf '\n%s: Bad %s (%s)\n\nexpected: %s\ngot: %s\n' \
- "$(ERROR)" "$1" "$2" "$3" "$(cat "$2")" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_stdout() {
- assert_stream STDOUT "$OUT" "$1"
-}
-
-assert_stderr() {
- assert_stream STDERR "$ERR" "$1"
-}
-
-assert_grep_stream() {
- if ! grep -qE "$3" "$2"; then
- printf '\n%s: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \
- "$(ERROR)" "$1" "$2" "$3" "$(cat "$2")" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_grep_stdout() {
- assert_grep_stream STDOUT "$OUT" "$1"
-}
-
-assert_grep_stderr() {
- assert_grep_stream STDERR "$ERR" "$1"
-}
-
-assert_fgrep_stream() {
- if ! grep -Fq -- "$3" "$2"; then
- printf '\n%s: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \
- "$(ERROR)" "$1" "$2" "$3" "$(cat "$2")" >&2
- print_debug_info
- exit 1
- fi
-}
-
-assert_fgrep_stdout() {
- assert_fgrep_stream STDOUT "$OUT" "$1"
-}
-
-assert_fgrep_stderr() {
- assert_fgrep_stream STDERR "$ERR" "$1"
-}
-
-testing() {
- printf "${yellow}testing${end}: %s..." "$1" >&2
-}
-
-test_ok() {
- # shellcheck disable=2059
- printf " ${green}OK${end}.\n" >&2
-}
-
-uuid() {
- # Taken from:
- # https://serverfault.com/a/799198
- od -xN20 /dev/urandom | \
- head -1 | \
- awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
-}