Skip to content

Commit f423ef5

Browse files
peffgitster
authored andcommitted
tests: allow user to specify trash directory location
The tests generate a large amount of I/O activity creating and destroying repositories and files. We can improve the time it takes to run the test suite by creating trash directories on filesystems with better performance characteristic, even though we may not want the rest of the git repository on those filesystems (e.g., because they are not network connected, or because they are temporary ramdisks). For example, on a dual processor system: $ cd t && time make -j32 real 1m51.562s user 0m59.260s sys 1m20.933s # /dev/shm is tmpfs $ cd t && time make -j32 GIT_TEST_OPTS="--root=/dev/shm" real 1m1.484s user 0m53.555s sys 1m5.264s We almost halve the wall clock time, and we utilize the dual processors much better. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91c8b82 commit f423ef5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

t/test-lib.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ do
114114
valgrind=t; verbose=t; shift ;;
115115
--tee)
116116
shift ;; # was handled already
117+
--root=*)
118+
root=$(expr "z$1" : 'z[^=]*=\(.*\)')
119+
shift ;;
117120
*)
118121
echo "error: unknown test option '$1'" >&2; exit 1 ;;
119122
esac
@@ -645,7 +648,11 @@ fi
645648

646649
# Test repository
647650
test="trash directory.$(basename "$0" .sh)"
648-
TRASH_DIRECTORY="$TEST_DIRECTORY/$test"
651+
test -n "$root" && test="$root/$test"
652+
case "$test" in
653+
/*) TRASH_DIRECTORY="$test" ;;
654+
*) TRASH_DIRECTORY="$TEST_DIRECTORY/$test" ;;
655+
esac
649656
test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
650657
rm -fr "$test" || {
651658
GIT_EXIT_OK=t

0 commit comments

Comments
 (0)