Hi Paul, Jim, A few years ago Paul removed '-t' from mktemp to accommodate NetBSD [1]. The change was then reverted since Jim preferred the directory name created with -t. The issue arrives again because although it "works" it silently litters /tmp with empty directories.
Here is an example on NetBSD 10.0: $ gnulib-tool --create-testdir --dir testdir1 localeconv $ cd testdir1 $ ./configure $ make check $ ls /tmp gnulib-python-cache-collin ssh-6fF5RmMxl5Rr ssh-y2OL0VTqIZcc $ ls /tmp/ -p.Aa9x3xH3 -p.QDECT3St gnulib-python-cache-collin ssh-6fF5RmMxl5Rr ssh-y2OL0VTqIZcc Originally I thought that this was due to GNU getopt rearranging options or something, since I don't think NetBSD does that. However, it looks like NetBSD creates two directories and the first one is ignored by the test framework. Here is before and after removing '-t' and using "set -x" at the top of init.sh (NetBSD): # Before: unset TMPDIR using redirections: 2>/dev/null do { d='/tmp/-p.COeKGNtW gt-test-init.sh.74sa' # After: unset TMPDIR using redirections: 2>/dev/null do { d=/home/collin/.local/src/gnulib/testdir1/gltests/gt-test-init.sh.5ii7 So the removal of '-t' fixes things on NetBSD. Here is the names created before and after removing '-t' with Coreutils 9.5: # Before: d=/home/collin/.local/src/gnulib/testdir1/gltests/gt-test-init.sh.cx71 # After: d=/home/collin/.local/src/gnulib/testdir1/gltests/gt-test-init.sh.ma3i I don't see a difference, but I am not very familiar with mktemp so perhaps I am missing something. I've gone ahead and committed this to solve the issue but feel free to change it with this added information. Collin [1] https://lists.gnu.org/archive/html/bug-gnulib/2016-03/msg00071.html
>From c07e16b04eca6e678977bc4f7a5358bf98805431 Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Sat, 8 Jun 2024 02:56:48 -0700 Subject: [PATCH] test-framework-sh: Don't leave temporary directories on NetBSD. Reported by Taylor R Campbell <riastr...@netbsd.org> in <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58319> * tests/init.sh (mktempd_): Don't use mktemp with the -t option as it leads to uncleaned temporary directories on NetBSD. --- ChangeLog | 8 ++++++++ tests/init.sh | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b9cda80d82..58fe6afdba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-08 Collin Funk <collin.fu...@gmail.com> + + test-framework-sh: Don't leave temporary directories on NetBSD. + Reported by Taylor R Campbell <riastr...@netbsd.org> in + <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58319> + * tests/init.sh (mktempd_): Don't use mktemp with the -t option as it + leads to uncleaned temporary directories on NetBSD. + 2024-06-07 Bruno Haible <br...@clisp.org> pthread_sigmask tests: Avoid failure due to known NetBSD 10.0 bug. diff --git a/tests/init.sh b/tests/init.sh index c5ec5cfd58..4689b6b758 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -344,7 +344,7 @@ mktempd_ () esac # First, try to use mktemp. - d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` && + d=`unset TMPDIR; { mktemp -d -p "$destdir_" "$template_"; } 2>/dev/null` && # The resulting name must be in the specified directory. case $d in "$destdir_slash_"*) :;; *) false;; esac && -- 2.45.2