]> gitweb.ps.run Git - ps-cgit/blobdiff - tests/setup.sh
tests: add Valgrind support
[ps-cgit] / tests / setup.sh
index 1d8677a783ec5d5b877a8d2a259c88d36b96ff14..5476cedde9580dcd7d2bdfe3403796ae6e7c0025 100755 (executable)
 # run_test 'repo index' 'cgit_url "/" | tidy -e'
 # run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
 
+# We don't want to run Git commands through Valgrind, so we filter out the
+# --valgrind option here and handle it ourselves.  We copy the arguments
+# assuming that none contain a newline, although other whitespace is
+# preserved.
+LF='
+'
+test_argv=
+
+while test $# != 0
+do
+       case "$1" in
+       --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
+               cgit_valgrind=t
+               test_argv="$test_argv${LF}--verbose"
+               ;;
+       *)
+               test_argv="$test_argv$LF$1"
+               ;;
+       esac
+       shift
+done
+
+OLDIFS=$IFS
+IFS=$LF
+set -- $test_argv
+IFS=$OLDIFS
+
 : ${TEST_DIRECTORY=$(pwd)/../git/t}
 : ${TEST_OUTPUT_DIRECTORY=$(pwd)}
 TEST_NO_CREATE_REPO=YesPlease
 . "$TEST_DIRECTORY"/test-lib.sh
 
 # Prepend the directory containing cgit to PATH.
-PATH="$(pwd)/../..:$PATH"
+if test -n "$cgit_valgrind"
+then
+       GIT_VALGRIND="$TEST_DIRECTORY/valgrind"
+       CGIT_VALGRIND=$(cd ../valgrind && pwd)
+       PATH="$CGIT_VALGRIND/bin:$PATH"
+       export GIT_VALGRIND CGIT_VALGRIND
+else
+       PATH="$(pwd)/../..:$PATH"
+fi
 
 mkrepo() {
        name=$1