commit: 0e2500322f370644624ceded132b709c8731b0fb
parent 705f275eddd2c5c30b43f95af0698742e127a1ac
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 14 Aug 2024 19:02:28 +0200
cmd/mktemp: print tmpdir when used
Diffstat:
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/cmd/mktemp.c b/cmd/mktemp.c
@@ -64,6 +64,8 @@ main(int argc, char *argv[])
strerror(errno));
return 1;
}
+
+ printf("%s/", tmpdir);
}
if(o_create_dir)
diff --git a/test-cmd/mktemp.sh b/test-cmd/mktemp.sh
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: MPL-2.0
target="$(dirname "$0")/../cmd/mktemp"
-plans=7
+plans=8
. "$(dirname "$0")/tap.sh"
t_mktemp()
@@ -15,19 +15,20 @@ t_mktemp()
ret="$?"
out="${out%/}"
- test -f "$out"
+ test -f "${out%
+}"
test_ret="$?"
rm -f "${out%
}"
- if [ "$ret" != 0 ] && [ "$test_ret" != 0 ]; then
+ if [ "$ret" == 0 ] && [ "$test_ret" == 0 ]; then
+ printf 'ok %d - %s\n' "$count" "$1"
+ else
printf 'not ok %d - %s\n' "$count" "$1"
printf '# exit code: %d\n' "$ret"
- printf '# test -f => %d\n' "$?"
+ printf '# test -f => %d\n' "$test_ret"
err=1
- else
- printf 'ok %d - %s\n' "$count" "$1"
fi
printf "$out" | sed -e 's;^;# ;'
}
@@ -41,19 +42,20 @@ t_mkdtemp()
ret="$?"
out="${out%/}"
- test -d "$out"
+ test -d "${out%
+}"
test_ret="$?"
rm -fr "${out%
}"
- if [ "$ret" != 0 ] && [ "$test_ret" != 0 ]; then
+ if [ "$ret" == 0 ] && [ "$test_ret" == 0 ]; then
+ printf 'ok %d - %s\n' "$count" "$1"
+ else
printf 'not ok %d - %s\n' "$count" "$1"
printf '# exit code: %d\n' "$ret"
- printf '# test -d => %d\n' "$?"
+ printf '# test -d => %d\n' "$test_ret"
err=1
- else
- printf 'ok %d - %s\n' "$count" "$1"
fi
printf "$out" | sed -e 's;^;# ;'
}
@@ -63,6 +65,7 @@ t_mkdtemp()
t_mktemp noargs ''
t_mktemp template 'template.XXXXXX'
t_mktemp tmpdir '-t'
+t_mktemp tmpdir '-t template.XXXXXX'
t_mkdtemp dir '-d'
t_mkdtemp dir_template '-d template.XXXXXX'
t_mkdtemp dir_tmpdir '-dt'