aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xaux/tests-lib.sh11
-rwxr-xr-xtests/cli-opts.sh14
-rwxr-xr-xtests/install-uninstall.sh4
-rwxr-xr-xtests/remotes.sh14
4 files changed, 43 insertions, 0 deletions
diff --git a/aux/tests-lib.sh b/aux/tests-lib.sh
index 007282a..a3ce7dc 100755
--- a/aux/tests-lib.sh
+++ b/aux/tests-lib.sh
@@ -5,6 +5,7 @@ red="\033[0;31m"
green="\033[0;32m"
yellow="\033[0;33m"
+N=
OUT=
ERR=
STATUS=
@@ -14,10 +15,15 @@ ERROR() {
printf "${red}ERROR${end}"
}
+print_debug_info() {
+ printf 'LINENO: %s\nOUT: %s\nERR: %s\n' "$N" "$OUT" "$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
}
@@ -26,6 +32,7 @@ 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
}
@@ -34,6 +41,7 @@ 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
}
@@ -50,6 +58,7 @@ assert_stream() {
if [ "$(cat "$2")" != "$3" ]; then
printf '\nERR: Bad %s (%s)\n\nexpected: %s\ngot: %s\n' \
"$1" "$2" "$3" "$(cat "$2")" >&2
+ print_debug_info
exit 1
fi
}
@@ -66,6 +75,7 @@ assert_grep_stream() {
if ! grep -qE "$3" "$2"; then
printf '\nERR: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \
"$1" "$2" "$3" "$(cat "$2")" >&2
+ print_debug_info
exit 1
fi
}
@@ -82,6 +92,7 @@ assert_fgrep_stream() {
if ! grep -Fq -- "$3" "$2"; then
printf '\nERR: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \
"$1" "$2" "$3" "$(cat "$2")" >&2
+ print_debug_info
exit 1
fi
}
diff --git a/tests/cli-opts.sh b/tests/cli-opts.sh
index 54b9aee..d5783e2 100755
--- a/tests/cli-opts.sh
+++ b/tests/cli-opts.sh
@@ -8,6 +8,7 @@ export PATH="$PWD/tests:$PATH"
test_langs() {
testing 'langs'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=POSIX sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -17,6 +18,7 @@ test_langs() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=C sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -26,6 +28,7 @@ test_langs() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_US.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -35,6 +38,7 @@ test_langs() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_AU.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -44,6 +48,7 @@ test_langs() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=pt_BR.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -53,6 +58,7 @@ test_langs() {
assert_fgrep_stdout 'Uso'
assert_fgrep_stdout 'Opções'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=pt_PT.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -68,6 +74,7 @@ test_langs() {
test_help_flags() {
testing 'help flags'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_US.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
@@ -77,6 +84,7 @@ test_help_flags() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_US.UTF-8 sh src/git-permalink --help 1>"$OUT" 2>"$ERR"
@@ -87,6 +95,7 @@ test_help_flags() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_US.UTF-8 sh src/git-permalink --something something -h 1>"$OUT" 2>"$ERR"
@@ -96,6 +105,7 @@ test_help_flags() {
assert_fgrep_stdout 'Usage'
assert_fgrep_stdout 'Options'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
LANG=en_US.UTF-8 sh src/git-permalink --help more things 1>"$OUT" 2>"$ERR"
@@ -113,6 +123,7 @@ test_version_flags() {
testing 'version flags'
REGEX='^git-permalink-[0-9\.]+ [0-9-]+$'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
sh src/git-permalink -V 1>"$OUT" 2>"$ERR"
@@ -121,6 +132,7 @@ test_version_flags() {
assert_empty_stderr
assert_grep_stdout "$REGEX"
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
sh src/git-permalink --version 1>"$OUT" 2>"$ERR"
@@ -129,6 +141,7 @@ test_version_flags() {
assert_empty_stderr
assert_grep_stdout "$REGEX"
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
sh src/git-permalink -V --abc xyz 1>"$OUT" 2>"$ERR"
@@ -136,6 +149,7 @@ test_version_flags() {
assert_status 0
assert_grep_stdout "$REGEX"
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
sh src/git-permalink --version things again 1>"$OUT" 2>"$ERR"
diff --git a/tests/install-uninstall.sh b/tests/install-uninstall.sh
index c0b402a..6bfdac0 100755
--- a/tests/install-uninstall.sh
+++ b/tests/install-uninstall.sh
@@ -9,6 +9,7 @@ PATH="$TEST_DESTDIR/usr/local/bin:$PATH"
test_install_uninstall_targets() {
testing 'install uninstall targets'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
make DESTDIR="$TEST_DESTDIR" install 1>"$OUT" 2>"$ERR"
@@ -18,6 +19,7 @@ test_install_uninstall_targets() {
assert_grep_stdout '^git-permalink-[0-9\.]+ [0-9-]+$'
assert_empty_stderr
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
find "$TEST_DESTDIR" -type f | wc -l 1>"$OUT" 2>"$ERR"
@@ -26,6 +28,7 @@ test_install_uninstall_targets() {
assert_stdout '5'
assert_empty_stderr
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
make DESTDIR="$TEST_DESTDIR" uninstall 1>"$OUT" 2>"$ERR"
@@ -35,6 +38,7 @@ test_install_uninstall_targets() {
assert_empty_stdout
assert_fgrep_stderr 'not a git command'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
find "$TEST_DESTDIR" -type f | wc -l 1>"$OUT" 2>"$ERR"
diff --git a/tests/remotes.sh b/tests/remotes.sh
index 4d6a8a2..3ed842c 100755
--- a/tests/remotes.sh
+++ b/tests/remotes.sh
@@ -31,6 +31,7 @@ new_repo() {
test_supported_remotes() {
testing 'supported remotes'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo git://euandreh.xyz/remembering
@@ -42,6 +43,7 @@ test_supported_remotes() {
assert_fgrep_stderr 'xdg-open: https://git.euandreh.xyz'
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://git.sr.ht/~sircmpwn/ctools
@@ -52,6 +54,7 @@ test_supported_remotes() {
assert_empty_stderr
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://git.kernel.org/pub/scm/git/git.git
@@ -63,6 +66,7 @@ test_supported_remotes() {
assert_fgrep_stderr 'xdg-open: https://git.kernel.org'
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://git.savannah.gnu.org/guix.git
@@ -73,6 +77,7 @@ test_supported_remotes() {
assert_empty_stderr
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://notabug.org/cwebber/guile-gcrypt
@@ -84,6 +89,7 @@ test_supported_remotes() {
assert_fgrep_stderr 'xdg-open: https://notabug.org'
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://codeberg.org/dnkl/yambar
@@ -94,6 +100,7 @@ test_supported_remotes() {
assert_empty_stderr
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://bitbucket.org/uprojects/jsmn
@@ -105,6 +112,7 @@ test_supported_remotes() {
assert_fgrep_stderr 'xdg-open: https://bitbucket.org'
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://pagure.io/aquedoc
@@ -115,6 +123,7 @@ test_supported_remotes() {
assert_empty_stderr
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://gitlab.com/nonguix/nonguix
@@ -126,6 +135,7 @@ test_supported_remotes() {
assert_fgrep_stderr 'xdg-open: https://gitlab.com/nonguix/nonguix'
cd - > /dev/null || exit 1
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://github.com/skeeto/elfeed
@@ -142,6 +152,7 @@ test_supported_remotes() {
test_unsupported_remote() {
testing 'unsupported remotes'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
new_repo https://example.com/a/b
@@ -151,6 +162,7 @@ test_unsupported_remote() {
assert_empty_stdout
assert_fgrep_stderr 'Unsupported origin: https://example.com'
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
git config git-permalink.template-commit-file 'before %s middle %s after'
@@ -160,6 +172,7 @@ test_unsupported_remote() {
assert_grep_stdout 'before .+ middle README.md after'
assert_empty_stderr
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
git config --unset git-permalink.template-commit-file
@@ -170,6 +183,7 @@ test_unsupported_remote() {
assert_grep_stdout 'before README.md middle .+ after'
assert_empty_stderr
+ N="$LINENO"
OUT="$(mktemp)"
ERR="$(mktemp)"
git config --unset git-permalink.template-file-commit