From 9644978f0ea82d67c82d04a8cd3b25f09b38c956 Mon Sep 17 00:00:00 2001 From: Chris Darroch Date: Sat, 24 Aug 2024 19:06:17 -0700 Subject: [PATCH] t/testenv.sh: fix macOS test temp directory name In commit cc41ca541361372323ccafd9d4f14797151c421c we changed the template used for our call to mktemp(1) to add a suffix of "XXXXXX" in order to comply with the requirements of the GNU version of that command, which expects at least 3 "X" characters in a template for a temporary file or directory name. However, on macOS, the BSD version of mktemp(1) treats these as literal "X" characters if the -t option is used, because in this case the following argument is interpreted as a prefix, not a template. Thus we actually create temporary directories on macOS of the form /var/folders/.../git-lfs_TEMP.XXXXXX., with 8 random characters appended by the command. Since the "X" characters are unnecessary in this case, we adjust our definition of the TEMPDIR_PREFIX variable to leave them off when our tests are running on macOS. --- t/testenv.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/testenv.sh b/t/testenv.sh index 30fbe9228d..0018a35958 100644 --- a/t/testenv.sh +++ b/t/testenv.sh @@ -77,7 +77,12 @@ BINPATH="$ROOTDIR/bin" PATH="$BINPATH:$PATH" # Always provide a test dir outside our git repo if not specified -TEMPDIR_PREFIX="git-lfs_TEMP.XXXXXX" +if [ "$IS_MAC" -eq 1 ]; then + TEMPDIR_PREFIX="git-lfs_TEMP" +else + TEMPDIR_PREFIX="git-lfs_TEMP.XXXXXX" +fi + if [ -z "$GIT_LFS_TEST_DIR" ]; then GIT_LFS_TEST_DIR=$(mktemp -d -t "$TEMPDIR_PREFIX") GIT_LFS_TEST_DIR=$(resolve_symlink $GIT_LFS_TEST_DIR)