aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cli-opts.sh56
-rwxr-xr-xtests/remotes.sh56
-rwxr-xr-xtests/tests-lib.sh17
3 files changed, 73 insertions, 56 deletions
diff --git a/tests/cli-opts.sh b/tests/cli-opts.sh
index 5c54775..9409aab 100755
--- a/tests/cli-opts.sh
+++ b/tests/cli-opts.sh
@@ -9,8 +9,8 @@ test_langs() {
testing 'langs'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=POSIX sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -19,8 +19,8 @@ test_langs() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=C sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -29,8 +29,8 @@ test_langs() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_US.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -39,8 +39,8 @@ test_langs() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_AU.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -49,8 +49,8 @@ test_langs() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=pt_BR.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -59,8 +59,8 @@ test_langs() {
assert_fgrep_stdout 'Opções'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=pt_PT.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -75,8 +75,8 @@ test_help_flags() {
testing 'help flags'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_US.UTF-8 sh src/git-permalink -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -85,8 +85,8 @@ test_help_flags() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_US.UTF-8 sh src/git-permalink --help 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -96,16 +96,16 @@ test_help_flags() {
assert_fgrep_stdout 'Options'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_US.UTF-8 sh src/git-permalink --something something -h 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 2
assert_usage "$ERR"
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
LANG=en_US.UTF-8 sh src/git-permalink --help more things 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -122,8 +122,8 @@ test_version_flags() {
REGEX='^git-permalink-[0-9\.]+ [0-9-]+$'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
sh src/git-permalink -V 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -131,8 +131,8 @@ test_version_flags() {
assert_grep_stdout "$REGEX"
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
sh src/git-permalink --version 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
@@ -140,16 +140,16 @@ test_version_flags() {
assert_grep_stdout "$REGEX"
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
sh src/git-permalink -V --abc xyz 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
assert_grep_stdout "$REGEX"
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
sh src/git-permalink --version things again 1>"$OUT" 2>"$ERR"
STATUS=$?
assert_status 0
diff --git a/tests/remotes.sh b/tests/remotes.sh
index 829f61d..7b1ba92 100755
--- a/tests/remotes.sh
+++ b/tests/remotes.sh
@@ -32,8 +32,8 @@ test_supported_remotes() {
testing 'supported remotes'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo git://euandreh.xyz/remembering
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -44,8 +44,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://git.sr.ht/~sircmpwn/ctools
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -55,8 +55,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://git.kernel.org/pub/scm/git/git.git
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -67,8 +67,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://git.savannah.gnu.org/guix.git
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -78,8 +78,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://notabug.org/cwebber/guile-gcrypt
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -90,8 +90,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://codeberg.org/dnkl/yambar
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -101,8 +101,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://bitbucket.org/uprojects/jsmn
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -113,8 +113,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://pagure.io/aquedoc
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -124,8 +124,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://gitlab.com/nonguix/nonguix
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -136,8 +136,8 @@ test_supported_remotes() {
cd - > /dev/null || exit 1
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://github.com/skeeto/elfeed
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -153,8 +153,8 @@ test_unsupported_remote() {
testing 'unsupported remotes'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
new_repo https://example.com/a/b
LANG=POSIX git permalink README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -163,8 +163,8 @@ test_unsupported_remote() {
assert_fgrep_stderr 'Unsupported origin: https://example.com'
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
git config git-permalink.template-commit-file 'before %s middle %s after'
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
@@ -173,8 +173,8 @@ test_unsupported_remote() {
assert_empty_stderr
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
git config --unset git-permalink.template-commit-file
git config git-permalink.template-file-commit 'before %s middle %s after'
git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
@@ -184,8 +184,8 @@ test_unsupported_remote() {
assert_empty_stderr
N="$LINENO"
- OUT="$(mktemp)"
- ERR="$(mktemp)"
+ OUT="$(mkstemp)"
+ ERR="$(mkstemp)"
git config --unset git-permalink.template-file-commit
LANG=POSIX git permalink -p README.md 123 1>"$OUT" 2>"$ERR"
STATUS=$?
diff --git a/tests/tests-lib.sh b/tests/tests-lib.sh
index a3ce7dc..03edc2d 100755
--- a/tests/tests-lib.sh
+++ b/tests/tests-lib.sh
@@ -121,3 +121,20 @@ uuid() {
head -1 | \
awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
}
+
+tmpname() {
+ echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname."
+}
+
+mkstemp() {
+ name="$(tmpname)"
+ touch "$name"
+ echo "$name"
+}
+
+mkdtemp() {
+ name="$(tmpname)"
+ rm -f "$name"
+ mkdir "$name"
+ echo "$name"
+}