aboutsummaryrefslogtreecommitdiff
path: root/tests/cli-opts.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-07-15 14:56:58 -0300
committerEuAndreh <eu@euandre.org>2021-07-15 15:22:12 -0300
commit42354876de823f52a431eac900d360c074c6198d (patch)
tree0b640a85a4375d51c01b9f05937eb562e776a5bf /tests/cli-opts.sh
parentTODOs.md: Add #task-f4807694-2187-5cb5-115e-c5970a052f1f (diff)
downloadgit-permalink-42354876de823f52a431eac900d360c074c6198d.tar.gz
git-permalink-42354876de823f52a431eac900d360c074c6198d.tar.xz
aux/lib.sh: Add mkstemp and mkdtemp, and copy uuid over
The tests were relying on the unspecified and non-standartized behaviour of "mktemp". Now they use "mkstemp()", a shim sh function to provide the expected behaviour, and an accompanying "mkdtemp()" function is also defined. To further decouple from specific implementations and OS-behaviours and quirks, a aux/lib.sh file containing both those functions was added. Its purpose is to also allow code under aux/ to not depend on specific behaviour. "mkdtemp()" had to be replicated in aux/ci/ci-build.sh, since it runs outside the repository.
Diffstat (limited to 'tests/cli-opts.sh')
-rwxr-xr-xtests/cli-opts.sh56
1 files changed, 28 insertions, 28 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