Skip to content

Commit

Permalink
Merge branch 'ds/fsmonitor-testing' into jch
Browse files Browse the repository at this point in the history
Updates around testing fsmoitor integration.

* ds/fsmonitor-testing:
  test-lib: clear watchman watches at test completion
  t7519: disable external GIT_TEST_FSMONITOR variable
  t7063: disable fsmonitor with status cache
  tests: disable fsmonitor in submodule tests
  t3600-rm.sh: disable fsmonitor when deleting populated submodule
  t3030-merge-recursive.sh: disable fsmonitor when tweaking GIT_WORK_TREE
  fsmonitor: disable fsmonitor with worktrees
  t1510-repo-setup.sh: disable fsmonitor if no .git dir
  t1301-shared-repo.sh: disable FSMONITOR
  fsmonitor: do not output to stderr for tests
  fsmonitor: disable in a bare repo
  • Loading branch information
gitster committed Dec 2, 2019
2 parents 405c03e + 06930c4 commit 26b6379
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,11 @@ int git_config_get_max_percent_split_change(void)

int git_config_get_fsmonitor(void)
{
if (!the_repository->worktree) {
core_fsmonitor = 0;
return 0;
}

if (git_config_get_pathname("core.fsmonitor", &core_fsmonitor))
core_fsmonitor = getenv("GIT_TEST_FSMONITOR");

Expand Down
1 change: 1 addition & 0 deletions t/t1301-shared-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
'

test_expect_success POSIXPERM 'forced modes' '
GIT_TEST_FSMONITOR="" &&
mkdir -p templates/hooks &&
echo update-server-info >templates/hooks/post-update &&
chmod +x templates/hooks/post-update &&
Expand Down
1 change: 1 addition & 0 deletions t/t1510-repo-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ test_expect_success '#29: setup' '
setup_repo 29 non-existent gitfile true &&
mkdir -p 29/sub/sub 29/wt/sub &&
(
GIT_TEST_FSMONITOR="" &&
cd 29 &&
GIT_WORK_TREE="$here/29" &&
export GIT_WORK_TREE &&
Expand Down
2 changes: 2 additions & 0 deletions t/t2400-worktree-add.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

GIT_TEST_FSMONITOR=""

test_description='test git worktree add'

. ./test-lib.sh
Expand Down
2 changes: 2 additions & 0 deletions t/t3030-merge-recursive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ test_expect_success 'reset and bind merge' '

test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
(
GIT_TEST_FSMONITOR="" &&
GIT_WORK_TREE="$PWD/ours-has-rename-work" &&
export GIT_WORK_TREE &&
GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
Expand All @@ -573,6 +574,7 @@ test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '

test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
(
GIT_TEST_FSMONITOR="" &&
GIT_WORK_TREE="$PWD/theirs-has-rename-work" &&
export GIT_WORK_TREE &&
GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&
Expand Down
1 change: 1 addition & 0 deletions t/t3600-rm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
'

test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
GIT_TEST_FSMONITOR="" &&
git reset --hard &&
git submodule update &&
git -C submod checkout HEAD^ &&
Expand Down
3 changes: 3 additions & 0 deletions t/t4060-diff-submodule-option-diff-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ This test tries to verify the sanity of --submodule=diff option of git diff.
# Tested non-UTF-8 encoding
test_encoding="ISO8859-1"

# fsmonitor does not work well with submodules
GIT_TEST_FSMONITOR=""

# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
Expand Down
2 changes: 2 additions & 0 deletions t/t5526-fetch-submodules.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
# Copyright (c) 2010, Jens Lehmann

GIT_TEST_FSMONITOR=""

test_description='Recursive "git fetch" for submodules'

. ./test-lib.sh
Expand Down
3 changes: 3 additions & 0 deletions t/t7063-status-untracked-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test_description='test untracked cache'

. ./test-lib.sh

# fsmonitor changes the expected behvaior of GIT_TRACE_UNTRACKED_STATS
GIT_TEST_FSMONITOR=""

# On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
# is updated lazily after contents in the directory changes, which
# forces the untracked cache code to take the slow path. A test
Expand Down
3 changes: 3 additions & 0 deletions t/t7402-submodule-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ test_description='Test rebasing, stashing, etc. with submodules'

. ./test-lib.sh

# fsmonitor does not work well with submodules
GIT_TEST_FSMONITOR=""

test_expect_success setup '
echo file > file &&
Expand Down
2 changes: 2 additions & 0 deletions t/t7406-submodule-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ submodule and "git submodule update --rebase/--merge" does not detach the HEAD.

. ./test-lib.sh

# fsmonitor does not work well with submodules
GIT_TEST_FSMONITOR=""

compare_head()
{
Expand Down
3 changes: 3 additions & 0 deletions t/t7506-status-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test_description='git status for submodule'

. ./test-lib.sh

# fsmonitor does not work well with submodules
GIT_TEST_FSMONITOR=""

test_create_repo_with_commit () {
test_create_repo "$1" &&
(
Expand Down
3 changes: 3 additions & 0 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,9 @@ test_expect_success 'status refreshes the index' '
test_cmp expect output
'

# fsmonitor does not work well with submodules
GIT_TEST_FSMONITOR=""

test_expect_success 'setup status submodule summary' '
test_create_repo sm && (
cd sm &&
Expand Down
3 changes: 3 additions & 0 deletions t/t7519-status-fsmonitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ test_description='git status with file system watcher'
# "git update-index --fsmonitor" can be used to get the extension written
# before testing the results.

# Disable an external value, as we will set it directly as needed.
GIT_TEST_FSMONITOR=""

clean_repo () {
git reset --hard HEAD &&
git clean -fd
Expand Down
1 change: 0 additions & 1 deletion t/t7519/fsmonitor-watchman
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ sub launch_watchman {
my $o = $json_pkg->new->utf8->decode($response);

if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
$retry--;
qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
Expand Down
15 changes: 15 additions & 0 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1516,3 +1516,18 @@ test_set_port () {
port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
eval $var=$port
}

test_clear_watchman () {
if test $GIT_TEST_FSMONITOR -ne ""
then
watchman watch-list |
grep "$TRASH_DIRECTORY" |
sed "s/\t\"//g" |
sed "s/\",//g" >repo-list

for repo in $(cat repo-list)
do
watchman watch-del "$repo"
done
fi
}
2 changes: 2 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,8 @@ test_atexit_handler () {
# sure that the registered cleanup commands are run only once.
test : != "$test_atexit_cleanup" || return 0

test_clear_watchman

setup_malloc_check
test_eval_ "$test_atexit_cleanup"
test_atexit_cleanup=:
Expand Down

0 comments on commit 26b6379

Please sign in to comment.