Skip to content

Commit e5da6c2

Browse files
committed
Merge branch 'ds/fsmonitor-testing' into jch
Updates around testing fsmoitor integration. cf. <[email protected]> * 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 t3030-merge-recursive.sh: disable fsmonitor when tweaking GIT_WORK_TREE t1301-shared-repo.sh: disable FSMONITOR fsmonitor: do not output to stderr for tests fsmonitor: disable in a bare repo
2 parents 3d90b0c + fac4909 commit e5da6c2

18 files changed

+54
-1
lines changed

config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,11 @@ int git_config_get_max_percent_split_change(void)
23172317

23182318
int git_config_get_fsmonitor(void)
23192319
{
2320+
if (!the_repository->worktree) {
2321+
core_fsmonitor = 0;
2322+
return 0;
2323+
}
2324+
23202325
if (git_config_get_pathname("core.fsmonitor", &core_fsmonitor))
23212326
core_fsmonitor = getenv("GIT_TEST_FSMONITOR");
23222327

t/t1301-shared-repo.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
128128
'
129129

130130
test_expect_success POSIXPERM 'forced modes' '
131+
GIT_TEST_FSMONITOR="" &&
131132
mkdir -p templates/hooks &&
132133
echo update-server-info >templates/hooks/post-update &&
133134
chmod +x templates/hooks/post-update &&

t/t1510-repo-setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ test_expect_success '#29: setup' '
775775
setup_repo 29 non-existent gitfile true &&
776776
mkdir -p 29/sub/sub 29/wt/sub &&
777777
(
778+
GIT_TEST_FSMONITOR="" &&
778779
cd 29 &&
779780
GIT_WORK_TREE="$here/29" &&
780781
export GIT_WORK_TREE &&

t/t2400-worktree-add.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
GIT_TEST_FSMONITOR=""
4+
35
test_description='test git worktree add'
46

57
. ./test-lib.sh

t/t3030-merge-recursive.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ test_expect_success 'reset and bind merge' '
548548

549549
test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
550550
(
551+
GIT_TEST_FSMONITOR="" &&
551552
GIT_WORK_TREE="$PWD/ours-has-rename-work" &&
552553
export GIT_WORK_TREE &&
553554
GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
@@ -573,6 +574,7 @@ test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
573574

574575
test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
575576
(
577+
GIT_TEST_FSMONITOR="" &&
576578
GIT_WORK_TREE="$PWD/theirs-has-rename-work" &&
577579
export GIT_WORK_TREE &&
578580
GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
743743
'
744744

745745
test_expect_success 'submodule rebase setup' '
746+
GIT_TEST_FSMONITOR="" &&
746747
git checkout A &&
747748
mkdir sub &&
748749
(

t/t3600-rm.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
360360
'
361361

362362
test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
363+
GIT_TEST_FSMONITOR="" &&
363364
git reset --hard &&
364365
git submodule update &&
365366
git -C submod checkout HEAD^ &&

t/t4060-diff-submodule-option-diff-format.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ This test tries to verify the sanity of --submodule=diff option of git diff.
1515
# Tested non-UTF-8 encoding
1616
test_encoding="ISO8859-1"
1717

18+
# fsmonitor does not work well with submodules
19+
GIT_TEST_FSMONITOR=""
20+
1821
# String "added" in German (translated with Google Translate), encoded in UTF-8,
1922
# used in sample commit log messages in add_file() function below.
2023
added=$(printf "hinzugef\303\274gt")

t/t5526-fetch-submodules.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22
# Copyright (c) 2010, Jens Lehmann
33

4+
GIT_TEST_FSMONITOR=""
5+
46
test_description='Recursive "git fetch" for submodules'
57

68
. ./test-lib.sh

t/t7063-status-untracked-cache.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ test_description='test untracked cache'
44

55
. ./test-lib.sh
66

7+
# fsmonitor changes the expected behvaior of GIT_TRACE_UNTRACKED_STATS
8+
GIT_TEST_FSMONITOR=""
9+
710
# On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
811
# is updated lazily after contents in the directory changes, which
912
# forces the untracked cache code to take the slow path. A test

t/t7402-submodule-rebase.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ test_description='Test rebasing, stashing, etc. with submodules'
77

88
. ./test-lib.sh
99

10+
# fsmonitor does not work well with submodules
11+
GIT_TEST_FSMONITOR=""
12+
1013
test_expect_success setup '
1114
1215
echo file > file &&

t/t7406-submodule-update.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
1111

1212
. ./test-lib.sh
1313

14+
# fsmonitor does not work well with submodules
15+
GIT_TEST_FSMONITOR=""
1416

1517
compare_head()
1618
{

t/t7506-status-submodule.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ test_description='git status for submodule'
44

55
. ./test-lib.sh
66

7+
# fsmonitor does not work well with submodules
8+
GIT_TEST_FSMONITOR=""
9+
710
test_create_repo_with_commit () {
811
test_create_repo "$1" &&
912
(

t/t7508-status.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,9 @@ test_expect_success 'status refreshes the index' '
846846
test_cmp expect output
847847
'
848848

849+
# fsmonitor does not work well with submodules
850+
GIT_TEST_FSMONITOR=""
851+
849852
test_expect_success 'setup status submodule summary' '
850853
test_create_repo sm && (
851854
cd sm &&

t/t7519-status-fsmonitor.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ test_description='git status with file system watcher'
88
# "git update-index --fsmonitor" can be used to get the extension written
99
# before testing the results.
1010

11+
# Disable an external value, as we will set it directly as needed.
12+
GIT_TEST_FSMONITOR=""
13+
1114
clean_repo () {
1215
git reset --hard HEAD &&
1316
git clean -fd

t/t7519/fsmonitor-watchman

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ sub launch_watchman {
9494
my $o = $json_pkg->new->utf8->decode($response);
9595

9696
if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
97-
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
9897
$retry--;
9998
qx/watchman watch "$git_work_tree"/;
10099
die "Failed to make watchman watch '$git_work_tree'.\n" .

t/test-lib-functions.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,3 +1516,18 @@ test_set_port () {
15161516
port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
15171517
eval $var=$port
15181518
}
1519+
1520+
test_clear_watchman () {
1521+
if test -n "$GIT_TEST_FSMONITOR"
1522+
then
1523+
watchman watch-list |
1524+
grep "$TRASH_DIRECTORY" |
1525+
sed "s/\",//g" |
1526+
sed "s/\"//g" >repo-list
1527+
1528+
while read repo
1529+
do
1530+
watchman watch-del "$repo"
1531+
done <repo-list
1532+
fi
1533+
}

t/test-lib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,10 @@ test_atexit_handler () {
11101110
test_done () {
11111111
GIT_EXIT_OK=t
11121112

1113+
# If watchman is being used with GIT_TEST_FSMONITOR, then
1114+
# clear all watches on directories inside the TRASH_DIRECTORY.
1115+
test_clear_watchman
1116+
11131117
# Run the atexit commands _before_ the trash directory is
11141118
# removed, so the commands can access pidfiles and socket files.
11151119
test_atexit_handler

0 commit comments

Comments
 (0)