forked from microsoft/git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t7527-internal-fsmonitor.sh
executable file
·85 lines (76 loc) · 2 KB
/
t7527-internal-fsmonitor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
test_description='internal file system watcher'
. ./test-lib.sh
git fsmonitor--daemon --is-supported || {
skip_all="The internal FSMonitor is not supported on this platform"
test_done
}
# Tell the fsmonitor--daemon to stop, even if `--stop` failed
test_atexit '
git fsmonitor--daemon --stop ||
test -n "$debug" ||
rm -r .git
'
test_expect_success 'can start and stop the daemon' '
test_when_finished \
"test_might_fail git -C test fsmonitor--daemon --stop" &&
git init test &&
(
cd test &&
: start the daemon implicitly by querying it &&
GIT_TRACE2_EVENT="$PWD/../.git/trace" \
git fsmonitor--daemon --query 1 0 >actual &&
grep "fsmonitor.*serve" ../.git/trace &&
git fsmonitor--daemon --is-running &&
nul_to_q <actual >actual.filtered &&
printf /Q >expect &&
test_cmp expect actual.filtered
) &&
sleep 0 &&
rm -rf test/.git &&
test_must_fail git -C test fsmonitor--daemon --is-running
'
test_expect_success 'setup' '
: >tracked &&
: >modified &&
mkdir dir1 &&
: >dir1/tracked &&
: >dir1/modified &&
mkdir dir2 &&
: >dir2/tracked &&
: >dir2/modified &&
git -c core.fsmonitor= add . &&
test_tick &&
git -c core.fsmonitor= commit -m initial &&
git config core.fsmonitor :internal: &&
git update-index --fsmonitor &&
cat >.gitignore <<-\EOF &&
.gitignore
expect*
actual*
EOF
>.git/trace &&
echo 1 >modified &&
echo 2 >dir1/modified &&
echo 3 >dir2/modified &&
>dir1/untracked &&
git fsmonitor--daemon --stop &&
test_must_fail git fsmonitor--daemon --is-running
'
test_expect_success 'internal fsmonitor works' '
GIT_INDEX=.git/fresh-index git read-tree master &&
GIT_INDEX=.git/fresh-index git -c core.fsmonitor= status >expect &&
GIT_TRACE2_EVENT="$PWD/.git/trace" git status >actual &&
test_cmp expect actual &&
! grep yep .git/trace &&
>yep &&
grep yep .git/trace
'
test_expect_success 'can stop internal fsmonitor' '
if git fsmonitor--daemon --is-running
then
git fsmonitor--daemon --stop
fi &&
test_must_fail git fsmonitor--daemon --is-running
'
test_done