p7519-fsmonitor.sh [plain text]
#!/bin/sh
test_description="Test core.fsmonitor"
. ./perf-lib.sh
test_perf_large_repo
test_checkout_worktree
test_lazy_prereq UNTRACKED_CACHE '
{ git update-index --test-untracked-cache; ret=$?; } &&
test $ret -ne 1
'
test_lazy_prereq WATCHMAN '
command -v watchman
'
if test_have_prereq WATCHMAN
then
case "$(uname -s)" in
MSYS_NT*)
GIT_WORK_TREE="$(cygpath -aw "$PWD" | sed 's,\\,/,g')"
;;
*)
GIT_WORK_TREE="$PWD"
;;
esac
fi
if test -n "$GIT_PERF_7519_DROP_CACHE"
then
if test "$GIT_PERF_REPEAT_COUNT" -ne 1
then
echo "warning: Setting GIT_PERF_REPEAT_COUNT=1" >&2
GIT_PERF_REPEAT_COUNT=1
fi
fi
test_expect_success "setup for fsmonitor" '
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
then
git config core.untrackedCache "$GIT_PERF_7519_UNTRACKED_CACHE"
else
if test_have_prereq UNTRACKED_CACHE
then
git config core.untrackedCache true
else
git config core.untrackedCache false
fi
fi &&
if test -n "$GIT_PERF_7519_SPLIT_INDEX"
then
git config core.splitIndex "$GIT_PERF_7519_SPLIT_INDEX"
fi &&
if test -n "$GIT_PERF_7519_FSMONITOR"
then
INTEGRATION_SCRIPT="$GIT_PERF_7519_FSMONITOR"
else
mkdir .git/hooks &&
if test_have_prereq WATCHMAN
then
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-watchman" &&
cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT" &&
watchman watch "$GIT_WORK_TREE" &&
watchman watch-list | grep -q -F "$GIT_WORK_TREE"
else
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-empty" &&
write_script "$INTEGRATION_SCRIPT"<<-\EOF
EOF
fi
fi &&
git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
git update-index --fsmonitor
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
git status
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
git status -uno
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
git status -uall
'
test_expect_success "setup without fsmonitor" '
unset INTEGRATION_SCRIPT &&
git config --unset core.fsmonitor &&
git update-index --no-fsmonitor
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
git status
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
git status -uno
'
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
test-tool drop-caches
fi
test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
git status -uall
'
if test_have_prereq WATCHMAN
then
watchman watch-del "$GIT_WORK_TREE" >/dev/null 2>&1 &&
watchman shutdown-server >/dev/null 2>&1
fi
test_done