Skip to content

Commit

Permalink
add support for running the tests in parallel
Browse files Browse the repository at this point in the history
By isolating each test temporary directory.
  • Loading branch information
benoit-pierre committed Aug 19, 2023
1 parent 1a7885f commit e4ea63b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions prog/reg_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ if [ -z "${srcdir}" ]; then
srcdir="${0%/*}"
fi

export LEPT_TMPDIR="${PWD}/${TEST_NAME}.tmp"

exec "$@" /bin/sh -c 'cd "$1" && "$2" generate && "$2" compare' -- "${srcdir}" "${PWD}/${TEST}"
10 changes: 8 additions & 2 deletions src/utils2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,7 @@ genPathname(const char *dir,
{
l_int32 is_macos = FALSE;
l_int32 is_win32 = FALSE;
char *cdir, *pathout;
char *cdir, *pathout, *tmpdir;
l_int32 dirlen, namelen;
size_t size;

Expand Down Expand Up @@ -3109,6 +3109,7 @@ size_t size;
return (char *)ERROR_PTR("pathout not made", __func__, NULL);
}

tmpdir = getenv("LEPT_TMPDIR");
#ifdef __APPLE__
is_macos = TRUE;
#endif /* __APPLE__ */
Expand All @@ -3120,10 +3121,15 @@ size_t size;
* There is no path rewriting on unix, and on win32, we do not
* rewrite unless the specified directory is /tmp or
* a subdirectory of /tmp */
if ((!is_macos && !is_win32) || dirlen < 4 ||
if ((!is_macos && !is_win32 && tmpdir == NULL) || dirlen < 4 ||
(dirlen == 4 && strncmp(cdir, "/tmp", 4) != 0) || /* not in "/tmp" */
(dirlen > 4 && strncmp(cdir, "/tmp/", 5) != 0)) { /* not in "/tmp/" */
stringCopy(pathout, cdir, dirlen);
} else if (tmpdir != NULL) {
stringCopy(pathout, tmpdir, strlen(tmpdir));
/* Add the rest of cdir */
if (dirlen > 4)
stringCat(pathout, size, cdir + 4);
} else if (is_macos) { /* Rewrite for macOS with "/tmp" specified for the directory. */
#ifdef __APPLE__
char tmpdir[PATH_MAX];
Expand Down

0 comments on commit e4ea63b

Please sign in to comment.