Skip to content

Commit

Permalink
t/testenv.sh: fix macOS test temp directory name
Browse files Browse the repository at this point in the history
In commit cc41ca5 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.<random>,
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.
  • Loading branch information
chrisd8088 committed Sep 19, 2024
1 parent 8ed6087 commit 399006a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion t/testenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 399006a

Please sign in to comment.