@@ -22,7 +22,9 @@ test_description="Test core.fsmonitor"
22
22
#
23
23
# GIT_PERF_7519_UNTRACKED_CACHE: used to configure core.untrackedCache
24
24
# GIT_PERF_7519_SPLIT_INDEX: used to configure core.splitIndex
25
- # GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor
25
+ # GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor. May be an
26
+ # absolute path to an integration. May be a space delimited list of
27
+ # absolute paths to integrations.
26
28
#
27
29
# The big win for using fsmonitor is the elimination of the need to scan the
28
30
# working directory looking for changed and untracked files. If the file
68
70
fi
69
71
fi
70
72
71
- test_expect_success " setup for fsmonitor " '
73
+ test_expect_success " one time repo setup " '
72
74
# set untrackedCache depending on the environment
73
75
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
74
76
then
@@ -88,24 +90,36 @@ test_expect_success "setup for fsmonitor" '
88
90
git config core.splitIndex "$GIT_PERF_7519_SPLIT_INDEX"
89
91
fi &&
90
92
93
+ mkdir 1_file 10_files 100_files 1000_files 10000_files &&
94
+ for i in $(test_seq 1 10); do touch 10_files/$i; done &&
95
+ for i in $(test_seq 1 100); do touch 100_files/$i; done &&
96
+ for i in $(test_seq 1 1000); do touch 1000_files/$i; done &&
97
+ for i in $(test_seq 1 10000); do touch 10000_files/$i; done &&
98
+ git add 1_file 10_files 100_files 1000_files 10000_files &&
99
+ git commit -qm "Add files" &&
100
+
101
+ # If Watchman exists, watch the work tree and attempt a query.
102
+ if test_have_prereq WATCHMAN; then
103
+ watchman watch "$GIT_WORK_TREE" &&
104
+ watchman watch-list | grep -q -F "$GIT_WORK_TREE"
105
+ fi
106
+ '
107
+
108
+ setup_for_fsmonitor () {
91
109
# set INTEGRATION_SCRIPT depending on the environment
92
- if test -n "$GIT_PERF_7519_FSMONITOR "
110
+ if test -n " $INTEGRATION_PATH "
93
111
then
94
- INTEGRATION_SCRIPT="$GIT_PERF_7519_FSMONITOR "
112
+ INTEGRATION_SCRIPT=" $INTEGRATION_PATH "
95
113
else
96
114
#
97
115
# Choose integration script based on existence of Watchman.
98
- # If Watchman exists, watch the work tree and attempt a query.
99
- # If everything succeeds, use Watchman integration script,
100
- # else fall back to an empty integration script.
116
+ # Fall back to an empty integration script.
101
117
#
102
118
mkdir .git/hooks &&
103
119
if test_have_prereq WATCHMAN
104
120
then
105
121
INTEGRATION_SCRIPT=" .git/hooks/fsmonitor-watchman" &&
106
- cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT" &&
107
- watchman watch "$GIT_WORK_TREE" &&
108
- watchman watch-list | grep -q -F "$GIT_WORK_TREE"
122
+ cp " $TEST_DIRECTORY /../templates/hooks--fsmonitor-watchman.sample" " $INTEGRATION_SCRIPT "
109
123
else
110
124
INTEGRATION_SCRIPT=" .git/hooks/fsmonitor-empty" &&
111
125
write_script " $INTEGRATION_SCRIPT " << -\EOF
@@ -114,16 +128,10 @@ test_expect_success "setup for fsmonitor" '
114
128
fi &&
115
129
116
130
git config core.fsmonitor " $INTEGRATION_SCRIPT " &&
117
- git update-index --fsmonitor &&
118
- mkdir 1_file 10_files 100_files 1000_files 10000_files &&
119
- for i in $(test_seq 1 10); do touch 10_files/$i; done &&
120
- for i in $(test_seq 1 100); do touch 100_files/$i; done &&
121
- for i in $(test_seq 1 1000); do touch 1000_files/$i; done &&
122
- for i in $(test_seq 1 10000); do touch 10000_files/$i; done &&
123
- git add 1_file 10_files 100_files 1000_files 10000_files &&
124
- git commit -m "Add files" &&
125
- git status # Warm caches
126
- '
131
+ git update-index --fsmonitor 2> error &&
132
+ cat error &&
133
+ [ ! -s error ] # ensure no silent error
134
+ }
127
135
128
136
test_perf_w_drop_caches () {
129
137
if test -n " $GIT_PERF_7519_DROP_CACHE " ; then
@@ -134,48 +142,72 @@ test_perf_w_drop_caches () {
134
142
}
135
143
136
144
test_fsmonitor_suite () {
137
- test_perf_w_drop_caches " status (fsmonitor=$INTEGRATION_SCRIPT )" '
145
+ if test -n " $INTEGRATION_SCRIPT " ; then
146
+ DESC=" fsmonitor=$( basename $INTEGRATION_SCRIPT ) "
147
+ else
148
+ DESC=" fsmonitor=disabled"
149
+ fi
150
+
151
+ test_expect_success " test_initialization" '
152
+ git reset --hard &&
153
+ git status # Warm caches
154
+ '
155
+
156
+ test_perf_w_drop_caches " status ($DESC )" '
138
157
git status
139
158
'
140
159
141
- test_perf_w_drop_caches " status -uno (fsmonitor= $INTEGRATION_SCRIPT )" '
160
+ test_perf_w_drop_caches " status -uno ($DESC )" '
142
161
git status -uno
143
162
'
144
163
145
- test_perf_w_drop_caches " status -uall (fsmonitor= $INTEGRATION_SCRIPT )" '
164
+ test_perf_w_drop_caches " status -uall ($DESC )" '
146
165
git status -uall
147
166
'
148
167
149
- test_perf_w_drop_caches " diff (fsmonitor=$INTEGRATION_SCRIPT )" '
168
+ test_perf_w_drop_caches " status (dirty) ($DESC )" '
169
+ git ls-files | head -100000 | xargs -d "\n" touch -h &&
170
+ git status
171
+ '
172
+
173
+ test_perf_w_drop_caches " diff ($DESC )" '
150
174
git diff
151
175
'
152
176
153
- test_perf_w_drop_caches " diff -- 0_files (fsmonitor= $INTEGRATION_SCRIPT )" '
177
+ test_perf_w_drop_caches " diff -- 0_files ($DESC )" '
154
178
git diff -- 1_file
155
179
'
156
180
157
- test_perf_w_drop_caches " diff -- 10_files (fsmonitor= $INTEGRATION_SCRIPT )" '
181
+ test_perf_w_drop_caches " diff -- 10_files ($DESC )" '
158
182
git diff -- 10_files
159
183
'
160
184
161
- test_perf_w_drop_caches " diff -- 100_files (fsmonitor= $INTEGRATION_SCRIPT )" '
185
+ test_perf_w_drop_caches " diff -- 100_files ($DESC )" '
162
186
git diff -- 100_files
163
187
'
164
188
165
- test_perf_w_drop_caches " diff -- 1000_files (fsmonitor= $INTEGRATION_SCRIPT )" '
189
+ test_perf_w_drop_caches " diff -- 1000_files ($DESC )" '
166
190
git diff -- 1000_files
167
191
'
168
192
169
- test_perf_w_drop_caches " diff -- 10000_files (fsmonitor= $INTEGRATION_SCRIPT )" '
193
+ test_perf_w_drop_caches " diff -- 10000_files ($DESC )" '
170
194
git diff -- 10000_files
171
195
'
172
196
173
- test_perf_w_drop_caches " add (fsmonitor= $INTEGRATION_SCRIPT )" '
197
+ test_perf_w_drop_caches " add ($DESC )" '
174
198
git add --all
175
199
'
176
200
}
177
201
178
- test_fsmonitor_suite
202
+ if test -n " $GIT_PERF_7519_FSMONITOR " ; then
203
+ for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR ; do
204
+ test_expect_success " setup for fsmonitor $INTEGRATION_PATH " ' setup_for_fsmonitor'
205
+ test_fsmonitor_suite
206
+ done
207
+ else
208
+ test_expect_success " setup for fsmonitor" ' setup_for_fsmonitor'
209
+ test_fsmonitor_suite
210
+ fi
179
211
180
212
test_expect_success " setup without fsmonitor" '
181
213
unset INTEGRATION_SCRIPT &&
0 commit comments