]>
Commit | Line | Data |
---|---|---|
c74c7203 | 1 | # Test framework for git. See t/README for usage. |
e1970ce4 JH |
2 | # |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
64b90323 MS |
5 | # This program is free software: you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 2 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
d05b08cd | 16 | # along with this program. If not, see https://www.gnu.org/licenses/ . |
e1970ce4 | 17 | |
3c8f12c9 JH |
18 | # Test the binaries we have just built. The tests are kept in |
19 | # t/ subdirectory and are run in 'trash directory' subdirectory. | |
20 | if test -z "$TEST_DIRECTORY" | |
21 | then | |
85176d72 FC |
22 | # ensure that TEST_DIRECTORY is an absolute path so that it |
23 | # is valid even if the current working directory is changed | |
9dbf20e7 ÆAB |
24 | TEST_DIRECTORY=$(pwd) |
25 | else | |
26 | # The TEST_DIRECTORY will always be the path to the "t" | |
27 | # directory in the git.git checkout. This is overridden by | |
28 | # e.g. t/lib-subtest.sh, but only because its $(pwd) is | |
29 | # different. Those tests still set "$TEST_DIRECTORY" to the | |
30 | # same path. | |
31 | # | |
32 | # See use of "$GIT_BUILD_DIR" and "$TEST_DIRECTORY" below for | |
33 | # hard assumptions about "$GIT_BUILD_DIR/t" existing and being | |
34 | # the "$TEST_DIRECTORY", and e.g. "$TEST_DIRECTORY/helper" | |
35 | # needing to exist. | |
85176d72 | 36 | TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1 |
3c8f12c9 | 37 | fi |
5ee89278 | 38 | GIT_BUILD_DIR="${GIT_BUILD_DIR:-${TEST_DIRECTORY%/t}}" |
b9638d72 | 39 | if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR" |
9dbf20e7 ÆAB |
40 | then |
41 | echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2 | |
42 | exit 1 | |
43 | fi | |
ee9e66e4 JS |
44 | if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR" |
45 | then | |
46 | GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1 | |
47 | # On Windows, we must convert Windows paths lest they contain a colon | |
48 | case "$(uname -s)" in | |
49 | *MINGW*) | |
50 | GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")" | |
51 | ;; | |
52 | esac | |
53 | fi | |
3c8f12c9 | 54 | |
66c1a568 ÆAB |
55 | # Prepend a string to a VAR using an arbitrary ":" delimiter, not |
56 | # adding the delimiter if VAR or VALUE is empty. I.e. a generalized: | |
57 | # | |
58 | # VAR=$1${VAR:+${1:+$2}$VAR} | |
59 | # | |
60 | # Usage (using ":" as the $2 delimiter): | |
61 | # | |
62 | # prepend_var VAR : VALUE | |
63 | prepend_var () { | |
361fa321 | 64 | eval "$1=\"$3\${$1:+${3:+$2}\$$1}\"" |
66c1a568 ÆAB |
65 | } |
66 | ||
67 | # If [AL]SAN is in effect we want to abort so that we notice | |
68 | # problems. The GIT_SAN_OPTIONS variable can be used to set common | |
69 | # defaults shared between [AL]SAN_OPTIONS. | |
70 | prepend_var GIT_SAN_OPTIONS : abort_on_error=1 | |
361fa321 | 71 | prepend_var GIT_SAN_OPTIONS : strip_path_prefix="$GIT_BUILD_DIR/" |
66c1a568 | 72 | |
d0cc5796 JK |
73 | # If we were built with ASAN, it may complain about leaks |
74 | # of program-lifetime variables. Disable it by default to lower | |
75 | # the noise level. This needs to happen at the start of the script, | |
76 | # before we even do our "did we build git yet" check (since we don't | |
77 | # want that one to complain to stderr). | |
66c1a568 ÆAB |
78 | prepend_var ASAN_OPTIONS : $GIT_SAN_OPTIONS |
79 | prepend_var ASAN_OPTIONS : detect_leaks=0 | |
d0cc5796 JK |
80 | export ASAN_OPTIONS |
81 | ||
66c1a568 | 82 | prepend_var LSAN_OPTIONS : $GIT_SAN_OPTIONS |
5fa0c4dd | 83 | prepend_var LSAN_OPTIONS : exitcode=0 |
71f26798 | 84 | prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0 |
85b81b35 JK |
85 | export LSAN_OPTIONS |
86 | ||
252d6937 JK |
87 | prepend_var UBSAN_OPTIONS : $GIT_SAN_OPTIONS |
88 | export UBSAN_OPTIONS | |
89 | ||
4638e880 PS |
90 | # The TEST_OUTPUT_DIRECTORY will be overwritten via GIT-BUILD-OPTIONS. So in |
91 | # case the caller has manually set up this variable via the environment we must | |
92 | # make sure to not overwrite that value, and thus we save it into | |
93 | # TEST_OUTPUT_DIRECTORY_OVERRIDE here. | |
94 | if test -n "$TEST_OUTPUT_DIRECTORY" && test -z "$TEST_OUTPUT_DIRECTORY_OVERRIDE" | |
95 | then | |
96 | TEST_OUTPUT_DIRECTORY_OVERRIDE=$TEST_OUTPUT_DIRECTORY | |
97 | fi | |
98 | ||
8abfdf44 JS |
99 | if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS |
100 | then | |
101 | echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).' | |
102 | exit 1 | |
103 | fi | |
104 | . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS | |
105 | export PERL_PATH SHELL_PATH | |
106 | ||
4638e880 PS |
107 | if test -z "$TEST_OUTPUT_DIRECTORY" |
108 | then | |
109 | # Similarly, override this to store the test-results subdir | |
110 | # elsewhere | |
111 | TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY | |
112 | fi | |
113 | ||
ade15525 PS |
114 | # In t0000, we need to override test directories of nested testcases. In case |
115 | # the developer has TEST_OUTPUT_DIRECTORY part of his build options, then we'd | |
116 | # reset this value to instead contain what the developer has specified. We thus | |
117 | # have this knob to allow overriding the directory. | |
118 | if test -n "${TEST_OUTPUT_DIRECTORY_OVERRIDE}" | |
119 | then | |
120 | TEST_OUTPUT_DIRECTORY="${TEST_OUTPUT_DIRECTORY_OVERRIDE}" | |
121 | fi | |
122 | ||
b02e7d5d JS |
123 | # Disallow the use of abbreviated options in the test suite by default |
124 | if test -z "${GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS}" | |
125 | then | |
126 | GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true | |
127 | export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS | |
128 | fi | |
129 | ||
97c8aac9 ÆAB |
130 | # Explicitly set the default branch name for testing, to avoid the |
131 | # transitory "git init" warning under --verbose. | |
132 | : ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master} | |
133 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
134 | ||
2006f0ad RR |
135 | ################################################################ |
136 | # It appears that people try to run tests without building... | |
8abfdf44 | 137 | "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null |
2006f0ad RR |
138 | if test $? != 1 |
139 | then | |
ed306e4e JS |
140 | if test -n "$GIT_TEST_INSTALLED" |
141 | then | |
142 | echo >&2 "error: there is no working Git at '$GIT_TEST_INSTALLED'" | |
143 | else | |
144 | echo >&2 'error: you do not seem to have built git yet.' | |
145 | fi | |
2006f0ad RR |
146 | exit 1 |
147 | fi | |
148 | ||
8cf58006 | 149 | store_arg_to= |
78dc0887 MT |
150 | opt_required_arg= |
151 | # $1: option string | |
152 | # $2: name of the var where the arg will be stored | |
153 | mark_option_requires_arg () { | |
154 | if test -n "$opt_required_arg" | |
8cf58006 | 155 | then |
78dc0887 MT |
156 | echo "error: options that require args cannot be bundled" \ |
157 | "together: '$opt_required_arg' and '$1'" >&2 | |
158 | exit 1 | |
8cf58006 | 159 | fi |
78dc0887 MT |
160 | opt_required_arg=$1 |
161 | store_arg_to=$2 | |
162 | } | |
163 | ||
78d5e4cf JS |
164 | # These functions can be overridden e.g. to output JUnit XML |
165 | start_test_output () { :; } | |
166 | start_test_case_output () { :; } | |
167 | finalize_test_case_output () { :; } | |
168 | finalize_test_output () { :; } | |
169 | ||
78dc0887 MT |
170 | parse_option () { |
171 | local opt="$1" | |
8cf58006 SG |
172 | |
173 | case "$opt" in | |
174 | -d|--d|--de|--deb|--debu|--debug) | |
175 | debug=t ;; | |
176 | -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) | |
177 | immediate=t ;; | |
178 | -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests) | |
179 | GIT_TEST_LONG=t; export GIT_TEST_LONG ;; | |
180 | -r) | |
78dc0887 | 181 | mark_option_requires_arg "$opt" run_list |
8cf58006 SG |
182 | ;; |
183 | --run=*) | |
184 | run_list=${opt#--*=} ;; | |
185 | -h|--h|--he|--hel|--help) | |
186 | help=t ;; | |
187 | -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) | |
188 | verbose=t ;; | |
189 | --verbose-only=*) | |
190 | verbose_only=${opt#--*=} | |
191 | ;; | |
192 | -q|--q|--qu|--qui|--quie|--quiet) | |
193 | # Ignore --quiet under a TAP::Harness. Saying how many tests | |
194 | # passed without the ok/not ok details is always an error. | |
195 | test -z "$HARNESS_ACTIVE" && quiet=t ;; | |
196 | --with-dashes) | |
197 | with_dashes=t ;; | |
dd167a30 JS |
198 | --no-bin-wrappers) |
199 | no_bin_wrappers=t ;; | |
8cf58006 SG |
200 | --no-color) |
201 | color= ;; | |
202 | --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) | |
203 | valgrind=memcheck | |
204 | tee=t | |
205 | ;; | |
206 | --valgrind=*) | |
207 | valgrind=${opt#--*=} | |
208 | tee=t | |
209 | ;; | |
210 | --valgrind-only=*) | |
211 | valgrind_only=${opt#--*=} | |
212 | tee=t | |
213 | ;; | |
214 | --tee) | |
215 | tee=t ;; | |
216 | --root=*) | |
217 | root=${opt#--*=} ;; | |
218 | --chain-lint) | |
219 | GIT_TEST_CHAIN_LINT=1 ;; | |
220 | --no-chain-lint) | |
221 | GIT_TEST_CHAIN_LINT=0 ;; | |
222 | -x) | |
223 | trace=t ;; | |
224 | -V|--verbose-log) | |
225 | verbose_log=t | |
226 | tee=t | |
227 | ;; | |
22231908 | 228 | --write-junit-xml) |
78d5e4cf | 229 | . "$TEST_DIRECTORY/test-lib-junit.sh" |
22231908 | 230 | ;; |
0f5ae593 JS |
231 | --github-workflow-markup) |
232 | . "$TEST_DIRECTORY/test-lib-github-workflow-markup.sh" | |
22231908 | 233 | ;; |
fb7d1e3a SG |
234 | --stress) |
235 | stress=t ;; | |
236 | --stress=*) | |
f5457371 JS |
237 | echo "error: --stress does not accept an argument: '$opt'" >&2 |
238 | echo "did you mean --stress-jobs=${opt#*=} or --stress-limit=${opt#*=}?" >&2 | |
239 | exit 1 | |
240 | ;; | |
241 | --stress-jobs=*) | |
242 | stress=t; | |
134768cf SG |
243 | stress_jobs=${opt#--*=} |
244 | case "$stress_jobs" in | |
7d661e5e | 245 | *[!0-9]*|0*|"") |
f5457371 | 246 | echo "error: --stress-jobs=<N> requires the number of jobs to run" >&2 |
fb7d1e3a SG |
247 | exit 1 |
248 | ;; | |
249 | *) # Good. | |
250 | ;; | |
251 | esac | |
252 | ;; | |
76e27fbf | 253 | --stress-limit=*) |
de69e6f6 | 254 | stress=t; |
76e27fbf SG |
255 | stress_limit=${opt#--*=} |
256 | case "$stress_limit" in | |
7d661e5e | 257 | *[!0-9]*|0*|"") |
76e27fbf SG |
258 | echo "error: --stress-limit=<N> requires the number of repetitions" >&2 |
259 | exit 1 | |
260 | ;; | |
261 | *) # Good. | |
262 | ;; | |
263 | esac | |
264 | ;; | |
46fb057a ÆAB |
265 | --invert-exit-code) |
266 | invert_exit_code=t | |
267 | ;; | |
8cf58006 SG |
268 | *) |
269 | echo "error: unknown test option '$opt'" >&2; exit 1 ;; | |
270 | esac | |
78dc0887 MT |
271 | } |
272 | ||
273 | # Parse options while taking care to leave $@ intact, so we will still | |
274 | # have all the original command line options when executing the test | |
275 | # script again for '--tee' and '--verbose-log' later. | |
276 | for opt | |
277 | do | |
278 | if test -n "$store_arg_to" | |
279 | then | |
280 | eval $store_arg_to=\$opt | |
281 | store_arg_to= | |
282 | opt_required_arg= | |
283 | continue | |
284 | fi | |
8cf58006 | 285 | |
78dc0887 MT |
286 | case "$opt" in |
287 | --*|-?) | |
288 | parse_option "$opt" ;; | |
289 | -?*) | |
290 | # bundled short options must be fed separately to parse_option | |
291 | opt=${opt#-} | |
292 | while test -n "$opt" | |
293 | do | |
294 | extra=${opt#?} | |
295 | this=${opt%$extra} | |
296 | opt=$extra | |
297 | parse_option "-$this" | |
298 | done | |
299 | ;; | |
300 | *) | |
301 | echo "error: unknown test option '$opt'" >&2; exit 1 ;; | |
302 | esac | |
8cf58006 SG |
303 | done |
304 | if test -n "$store_arg_to" | |
305 | then | |
78dc0887 | 306 | echo "error: $opt_required_arg requires an argument" >&2 |
8cf58006 SG |
307 | exit 1 |
308 | fi | |
309 | ||
310 | if test -n "$valgrind_only" | |
311 | then | |
312 | test -z "$valgrind" && valgrind=memcheck | |
313 | test -z "$verbose" && verbose_only="$valgrind_only" | |
314 | elif test -n "$valgrind" | |
315 | then | |
316 | test -z "$verbose_log" && verbose=t | |
317 | fi | |
318 | ||
fb7d1e3a SG |
319 | if test -n "$stress" |
320 | then | |
321 | verbose=t | |
322 | trace=t | |
323 | immediate=t | |
324 | fi | |
325 | ||
326 | TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}" | |
62c379b8 | 327 | TEST_NAME="$(basename "$0" .sh)" |
ffe1afe6 SG |
328 | TEST_NUMBER="${TEST_NAME%%-*}" |
329 | TEST_NUMBER="${TEST_NUMBER#t}" | |
62c379b8 | 330 | TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results" |
fb7d1e3a | 331 | TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX" |
366bd129 ÆAB |
332 | TEST_RESULTS_SAN_FILE_PFX=trace |
333 | TEST_RESULTS_SAN_DIR_SFX=leak | |
334 | TEST_RESULTS_SAN_FILE= | |
d601aee6 | 335 | TEST_RESULTS_SAN_DIR="$TEST_RESULTS_BASE.$TEST_RESULTS_SAN_DIR_SFX" |
fb7d1e3a | 336 | TRASH_DIRECTORY="trash directory.$TEST_NAME$TEST_STRESS_JOB_SFX" |
61f292db SG |
337 | test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY" |
338 | case "$TRASH_DIRECTORY" in | |
339 | /*) ;; # absolute path is good | |
340 | *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;; | |
341 | esac | |
62c379b8 | 342 | |
fb7d1e3a SG |
343 | # If --stress was passed, run this test repeatedly in several parallel loops. |
344 | if test "$GIT_TEST_STRESS_STARTED" = "done" | |
345 | then | |
346 | : # Don't stress test again. | |
347 | elif test -n "$stress" | |
348 | then | |
134768cf | 349 | if test -n "$stress_jobs" |
fb7d1e3a | 350 | then |
134768cf | 351 | job_count=$stress_jobs |
fb7d1e3a SG |
352 | elif test -n "$GIT_TEST_STRESS_LOAD" |
353 | then | |
354 | job_count="$GIT_TEST_STRESS_LOAD" | |
355 | elif job_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null) && | |
356 | test -n "$job_count" | |
357 | then | |
358 | job_count=$((2 * $job_count)) | |
359 | else | |
360 | job_count=8 | |
361 | fi | |
362 | ||
363 | mkdir -p "$TEST_RESULTS_DIR" | |
364 | stressfail="$TEST_RESULTS_BASE.stress-failed" | |
365 | rm -f "$stressfail" | |
366 | ||
367 | stress_exit=0 | |
368 | trap ' | |
369 | kill $job_pids 2>/dev/null | |
370 | wait | |
371 | stress_exit=1 | |
372 | ' TERM INT HUP | |
373 | ||
374 | job_pids= | |
375 | job_nr=0 | |
376 | while test $job_nr -lt "$job_count" | |
377 | do | |
378 | ( | |
379 | GIT_TEST_STRESS_STARTED=done | |
380 | GIT_TEST_STRESS_JOB_NR=$job_nr | |
381 | export GIT_TEST_STRESS_STARTED GIT_TEST_STRESS_JOB_NR | |
382 | ||
383 | trap ' | |
384 | kill $test_pid 2>/dev/null | |
385 | wait | |
386 | exit 1 | |
387 | ' TERM INT | |
388 | ||
76e27fbf SG |
389 | cnt=1 |
390 | while ! test -e "$stressfail" && | |
391 | { test -z "$stress_limit" || | |
392 | test $cnt -le $stress_limit ; } | |
fb7d1e3a SG |
393 | do |
394 | $TEST_SHELL_PATH "$0" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 & | |
395 | test_pid=$! | |
396 | ||
397 | if wait $test_pid | |
398 | then | |
399 | printf "OK %2d.%d\n" $GIT_TEST_STRESS_JOB_NR $cnt | |
400 | else | |
401 | echo $GIT_TEST_STRESS_JOB_NR >>"$stressfail" | |
402 | printf "FAIL %2d.%d\n" $GIT_TEST_STRESS_JOB_NR $cnt | |
403 | fi | |
404 | cnt=$(($cnt + 1)) | |
405 | done | |
406 | ) & | |
407 | job_pids="$job_pids $!" | |
408 | job_nr=$(($job_nr + 1)) | |
409 | done | |
410 | ||
411 | wait | |
412 | ||
413 | if test -f "$stressfail" | |
414 | then | |
76e27fbf | 415 | stress_exit=1 |
fb7d1e3a SG |
416 | echo "Log(s) of failed test run(s):" |
417 | for failed_job_nr in $(sort -n "$stressfail") | |
418 | do | |
419 | echo "Contents of '$TEST_RESULTS_BASE.stress-$failed_job_nr.out':" | |
420 | cat "$TEST_RESULTS_BASE.stress-$failed_job_nr.out" | |
421 | done | |
422 | rm -rf "$TRASH_DIRECTORY.stress-failed" | |
423 | # Move the last one. | |
424 | mv "$TRASH_DIRECTORY.stress-$failed_job_nr" "$TRASH_DIRECTORY.stress-failed" | |
425 | fi | |
426 | ||
427 | exit $stress_exit | |
428 | fi | |
429 | ||
4cde519f RR |
430 | # if --tee was passed, write the output not only to the terminal, but |
431 | # additionally to the file test-results/$BASENAME.out, too. | |
8cf58006 SG |
432 | if test "$GIT_TEST_TEE_STARTED" = "done" |
433 | then | |
434 | : # do not redirect again | |
435 | elif test -n "$tee" | |
436 | then | |
62c379b8 | 437 | mkdir -p "$TEST_RESULTS_DIR" |
452320f1 JK |
438 | |
439 | # Make this filename available to the sub-process in case it is using | |
440 | # --verbose-log. | |
62c379b8 | 441 | GIT_TEST_TEE_OUTPUT_FILE=$TEST_RESULTS_BASE.out |
452320f1 JK |
442 | export GIT_TEST_TEE_OUTPUT_FILE |
443 | ||
444 | # Truncate before calling "tee -a" to get rid of the results | |
445 | # from any previous runs. | |
446 | >"$GIT_TEST_TEE_OUTPUT_FILE" | |
447 | ||
3f824e91 | 448 | (GIT_TEST_TEE_STARTED=done ${TEST_SHELL_PATH} "$0" "$@" 2>&1; |
62c379b8 SG |
449 | echo $? >"$TEST_RESULTS_BASE.exit") | tee -a "$GIT_TEST_TEE_OUTPUT_FILE" |
450 | test "$(cat "$TEST_RESULTS_BASE.exit")" = 0 | |
4cde519f | 451 | exit |
8cf58006 SG |
452 | fi |
453 | ||
454 | if test -n "$trace" && test -n "$test_untraceable" | |
455 | then | |
456 | # '-x' tracing requested, but this test script can't be reliably | |
457 | # traced, unless it is run with a Bash version supporting | |
458 | # BASH_XTRACEFD (introduced in Bash v4.1). | |
459 | # | |
460 | # Perform this version check _after_ the test script was | |
461 | # potentially re-executed with $TEST_SHELL_PATH for '--tee' or | |
462 | # '--verbose-log', so the right shell is checked and the | |
463 | # warning is issued only once. | |
464 | if test -n "$BASH_VERSION" && eval ' | |
465 | test ${BASH_VERSINFO[0]} -gt 4 || { | |
466 | test ${BASH_VERSINFO[0]} -eq 4 && | |
467 | test ${BASH_VERSINFO[1]} -ge 1 | |
468 | } | |
469 | ' | |
470 | then | |
471 | : Executed by a Bash version supporting BASH_XTRACEFD. Good. | |
472 | else | |
d4ea24b8 | 473 | echo >&2 "# warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD" |
8cf58006 SG |
474 | trace= |
475 | fi | |
476 | fi | |
477 | if test -n "$trace" && test -z "$verbose_log" | |
478 | then | |
479 | verbose=t | |
480 | fi | |
4cde519f | 481 | |
390b44eb FC |
482 | # Since bash 5.0, checkwinsize is enabled by default which does |
483 | # update the COLUMNS variable every time a non-builtin command | |
484 | # completes, even for non-interactive shells. | |
485 | # Disable that since we are aiming for repeatability. | |
486 | test -n "$BASH_VERSION" && shopt -u checkwinsize 2>/dev/null | |
487 | ||
e1970ce4 | 488 | # For repeatability, reset the environment to known value. |
d5c1b7c2 | 489 | # TERM is sanitized below, after saving color control sequences. |
e1970ce4 | 490 | LANG=C |
899460f3 | 491 | LC_ALL=C |
d9bdd39e | 492 | PAGER=cat |
e1970ce4 | 493 | TZ=UTC |
c49a177b ÆAB |
494 | COLUMNS=80 |
495 | export LANG LC_ALL PAGER TZ COLUMNS | |
8ff99e74 | 496 | EDITOR=: |
6cdccfce | 497 | |
661bfd13 SL |
498 | # A call to "unset" with no arguments causes at least Solaris 10 |
499 | # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets | |
500 | # deriving from the command substitution clustered with the other | |
501 | # ones. | |
7792d326 PS |
502 | unset VISUAL EMAIL LANGUAGE $(env | sed -n \ |
503 | -e '/^GIT_TRACE/d' \ | |
504 | -e '/^GIT_DEBUG/d' \ | |
505 | -e '/^GIT_TEST/d' \ | |
506 | -e '/^GIT_.*_TEST/d' \ | |
507 | -e '/^GIT_PROVE/d' \ | |
508 | -e '/^GIT_VALGRIND/d' \ | |
509 | -e '/^GIT_UNZIP/d' \ | |
510 | -e '/^GIT_PERF_/d' \ | |
511 | -e '/^GIT_CURL_VERBOSE/d' \ | |
512 | -e '/^GIT_TRACE_CURL/d' \ | |
513 | -e '/^GIT_BUILD_DIR/d' \ | |
514 | -e 's/^\(GIT_[^=]*\)=.*/\1/p' | |
515 | ) | |
7976e901 | 516 | unset XDG_CACHE_HOME |
5adf84eb | 517 | unset XDG_CONFIG_HOME |
8bade1e1 | 518 | unset GITPERLLIB |
944d808e JS |
519 | unset GIT_TRACE2_PARENT_NAME |
520 | unset GIT_TRACE2_PARENT_SID | |
d8b8217c PB |
521 | TEST_AUTHOR_LOCALNAME=author |
522 | TEST_AUTHOR_DOMAIN=example.com | |
523 | GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN} | |
29e55cd5 | 524 | GIT_AUTHOR_NAME='A U Thor' |
f2e3937d | 525 | GIT_AUTHOR_DATE='1112354055 +0200' |
d8b8217c PB |
526 | TEST_COMMITTER_LOCALNAME=committer |
527 | TEST_COMMITTER_DOMAIN=example.com | |
528 | GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN} | |
29e55cd5 | 529 | GIT_COMMITTER_NAME='C O Mitter' |
f2e3937d | 530 | GIT_COMMITTER_DATE='1112354055 +0200' |
8d0fc48f | 531 | GIT_MERGE_VERBOSITY=5 |
f8246281 JH |
532 | GIT_MERGE_AUTOEDIT=no |
533 | export GIT_MERGE_VERBOSITY GIT_MERGE_AUTOEDIT | |
29e55cd5 JH |
534 | export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME |
535 | export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME | |
f2e3937d | 536 | export GIT_COMMITTER_DATE GIT_AUTHOR_DATE |
d33738d7 | 537 | export EDITOR |
e1970ce4 | 538 | |
02a32dbf | 539 | GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}" |
540 | export GIT_DEFAULT_HASH | |
58aaf591 PS |
541 | GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}" |
542 | export GIT_DEFAULT_REF_FORMAT | |
02a32dbf | 543 | |
124647c4 KB |
544 | # Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output |
545 | GIT_TRACE_BARE=1 | |
546 | export GIT_TRACE_BARE | |
547 | ||
b8de3d6e DS |
548 | # Some tests scan the GIT_TRACE2_EVENT feed for events, but the |
549 | # default depth is 2, which frequently causes issues when the | |
550 | # events are wrapped in new regions. Set it to a sufficiently | |
551 | # large depth to avoid custom changes in the test suite. | |
552 | GIT_TRACE2_EVENT_NESTING=100 | |
553 | export GIT_TRACE2_EVENT_NESTING | |
554 | ||
1f357b04 BP |
555 | # Use specific version of the index file format |
556 | if test -n "${GIT_TEST_INDEX_VERSION:+isset}" | |
5d9fc888 | 557 | then |
1f357b04 | 558 | GIT_INDEX_VERSION="$GIT_TEST_INDEX_VERSION" |
5d9fc888 TG |
559 | export GIT_INDEX_VERSION |
560 | fi | |
561 | ||
5338ed2b JK |
562 | if test -n "$GIT_TEST_PERL_FATAL_WARNINGS" |
563 | then | |
564 | GIT_PERL_FATAL_WARNINGS=1 | |
565 | export GIT_PERL_FATAL_WARNINGS | |
566 | fi | |
567 | ||
412e4cae EW |
568 | case $GIT_TEST_FSYNC in |
569 | '') | |
570 | GIT_TEST_FSYNC=0 | |
571 | export GIT_TEST_FSYNC | |
572 | ;; | |
573 | esac | |
574 | ||
886a3907 JH |
575 | # Protect ourselves from common misconfiguration to export |
576 | # CDPATH into the environment | |
577 | unset CDPATH | |
578 | ||
5565f47c | 579 | unset GREP_OPTIONS |
ac001282 | 580 | unset UNZIP |
5565f47c | 581 | |
3d5c0cc9 | 582 | case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in |
1c0cc756 | 583 | 1|2|true) |
025232e8 | 584 | GIT_TRACE=4 |
1c0cc756 | 585 | ;; |
6ce4e61f CC |
586 | esac |
587 | ||
3f4ab627 JH |
588 | # Line feed |
589 | LF=' | |
590 | ' | |
591 | ||
bd482d6e DL |
592 | # Single quote |
593 | SQ=\' | |
594 | ||
a42643aa JK |
595 | # UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores |
596 | # when case-folding filenames | |
597 | u200c=$(printf '\342\200\214') | |
598 | ||
70507911 | 599 | export _x05 _x35 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX |
342e9ef2 | 600 | |
d5c1b7c2 | 601 | test "x$TERM" != "xdumb" && ( |
ca92a660 RH |
602 | test -t 1 && |
603 | tput bold >/dev/null 2>&1 && | |
604 | tput setaf 1 >/dev/null 2>&1 && | |
605 | tput sgr0 >/dev/null 2>&1 | |
606 | ) && | |
607 | color=t | |
e1970ce4 | 608 | |
ca92a660 RH |
609 | if test -n "$color" |
610 | then | |
d5c1b7c2 RH |
611 | # Save the color control sequences now rather than run tput |
612 | # each time say_color() is called. This is done for two | |
613 | # reasons: | |
614 | # * TERM will be changed to dumb | |
615 | # * HOME will be changed to a temporary directory and tput | |
616 | # might need to read ~/.terminfo from the original HOME | |
617 | # directory to get the control sequences | |
618 | # Note: This approach assumes the control sequences don't end | |
619 | # in a newline for any terminal of interest (command | |
620 | # substitutions strip trailing newlines). Given that most | |
621 | # (all?) terminals in common use are related to ECMA-48, this | |
622 | # shouldn't be a problem. | |
623 | say_color_error=$(tput bold; tput setaf 1) # bold red | |
624 | say_color_skip=$(tput setaf 4) # blue | |
625 | say_color_warn=$(tput setaf 3) # brown/yellow | |
626 | say_color_pass=$(tput setaf 2) # green | |
627 | say_color_info=$(tput setaf 6) # cyan | |
628 | say_color_reset=$(tput sgr0) | |
629 | say_color_="" # no formatting for normal text | |
ca92a660 | 630 | say_color () { |
d5c1b7c2 RH |
631 | test -z "$1" && test -n "$quiet" && return |
632 | eval "say_color_color=\$say_color_$1" | |
ca92a660 | 633 | shift |
d5c1b7c2 | 634 | printf "%s\\n" "$say_color_color$*$say_color_reset" |
ca92a660 RH |
635 | } |
636 | else | |
637 | say_color() { | |
638 | test -z "$1" && test -n "$quiet" && return | |
639 | shift | |
640 | printf "%s\n" "$*" | |
641 | } | |
642 | fi | |
643 | ||
add5240f | 644 | USER_TERM="$TERM" |
d5c1b7c2 | 645 | TERM=dumb |
add5240f | 646 | export TERM USER_TERM |
d5c1b7c2 | 647 | |
a6714088 FS |
648 | # What is written by tests to stdout and stderr is sent to different places |
649 | # depending on the test mode (e.g. /dev/null in non-verbose mode, piped to tee | |
650 | # with --tee option, etc.). We save the original stdin to FD #6 and stdout and | |
651 | # stderr to #5 and #7, so that the test framework can use them (e.g. for | |
652 | # printing errors within the test framework) independently of the test mode. | |
653 | exec 5>&1 | |
654 | exec 6<&0 | |
655 | exec 7>&2 | |
656 | ||
8583bf75 | 657 | _error_exit () { |
78d5e4cf | 658 | finalize_test_output |
6e7b5aaf | 659 | GIT_EXIT_OK=t |
55db1df0 PH |
660 | exit 1 |
661 | } | |
662 | ||
8583bf75 ÆAB |
663 | error () { |
664 | say_color error "error: $*" | |
665 | _error_exit | |
666 | } | |
667 | ||
165293af SG |
668 | BUG () { |
669 | error >&7 "bug in the test script: $*" | |
670 | } | |
671 | ||
234383cd ÆAB |
672 | BAIL_OUT () { |
673 | test $# -ne 1 && BUG "1 param" | |
674 | ||
675 | # Do not change "Bail out! " string. It's part of TAP syntax: | |
676 | # https://testanything.org/tap-specification.html | |
677 | local bail_out="Bail out! " | |
678 | local message="$1" | |
679 | ||
a6714088 | 680 | say_color >&5 error $bail_out "$message" |
234383cd ÆAB |
681 | _error_exit |
682 | } | |
683 | ||
55db1df0 PH |
684 | say () { |
685 | say_color info "$*" | |
686 | } | |
687 | ||
614fe015 JK |
688 | if test -n "$HARNESS_ACTIVE" |
689 | then | |
690 | if test "$verbose" = t || test -n "$verbose_only" | |
691 | then | |
234383cd | 692 | BAIL_OUT 'verbose mode forbidden under TAP harness; try --verbose-log' |
614fe015 JK |
693 | fi |
694 | fi | |
695 | ||
570f3226 MB |
696 | test "${test_description}" != "" || |
697 | error "Test script did not set test_description." | |
698 | ||
699 | if test "$help" = "t" | |
700 | then | |
cb1aefda | 701 | printf '%s\n' "$test_description" |
570f3226 MB |
702 | exit 0 |
703 | fi | |
704 | ||
452320f1 JK |
705 | if test "$verbose_log" = "t" |
706 | then | |
707 | exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3 | |
708 | elif test "$verbose" = "t" | |
e1970ce4 | 709 | then |
d411d3d8 | 710 | exec 4>&2 3>&2 |
e1970ce4 JH |
711 | else |
712 | exec 4>/dev/null 3>/dev/null | |
713 | fi | |
714 | ||
d88785e4 JK |
715 | # Send any "-x" output directly to stderr to avoid polluting tests |
716 | # which capture stderr. We can do this unconditionally since it | |
717 | # has no effect if tracing isn't turned on. | |
718 | # | |
719 | # Note that this sets up the trace fd as soon as we assign the variable, so it | |
720 | # must come after the creation of descriptor 4 above. Likewise, we must never | |
721 | # unset this, as it has the side effect of closing descriptor 4, which we | |
722 | # use to show verbose tests to the user. | |
723 | # | |
724 | # Note also that we don't need or want to export it. The tracing is local to | |
725 | # this shell, and we would not want to influence any shells we exec. | |
726 | BASH_XTRACEFD=4 | |
727 | ||
e1970ce4 JH |
728 | test_failure=0 |
729 | test_count=0 | |
41ac414e JH |
730 | test_fixed=0 |
731 | test_broken=0 | |
2d84e9fb | 732 | test_success=0 |
e1970ce4 | 733 | |
49da4040 FS |
734 | test_missing_prereq= |
735 | ||
d998bd4a ÆAB |
736 | test_external_has_tap=0 |
737 | ||
faa4bc35 | 738 | die () { |
6e7b5aaf | 739 | code=$? |
900721e1 JS |
740 | # This is responsible for running the atexit commands even when a |
741 | # test script run with '--immediate' fails, or when the user hits | |
742 | # ctrl-C, i.e. when 'test_done' is not invoked at all. | |
743 | test_atexit_handler || code=$? | |
6e7b5aaf CB |
744 | if test -n "$GIT_EXIT_OK" |
745 | then | |
746 | exit $code | |
747 | else | |
748 | echo >&5 "FATAL: Unexpected exit with code $code" | |
749 | exit 1 | |
750 | fi | |
faa4bc35 CB |
751 | } |
752 | ||
6e7b5aaf | 753 | GIT_EXIT_OK= |
35641310 | 754 | trap 'die' EXIT |
c5c39f4e SG |
755 | # Disable '-x' tracing, because with some shells, notably dash, it |
756 | # prevents running the cleanup commands when a test script run with | |
757 | # '--verbose-log -x' is interrupted. | |
758 | trap '{ code=$?; set +x; } 2>/dev/null; exit $code' INT TERM HUP | |
41184273 | 759 | |
12a29b1a TR |
760 | # The user-facing functions are loaded from a separate file so that |
761 | # test_perf subshells can have them too | |
3c8f12c9 | 762 | . "$TEST_DIRECTORY/test-lib-functions.sh" |
05236a5e | 763 | |
886856ab | 764 | # You are not expected to call test_ok_ and test_failure_ directly, use |
3fa36666 | 765 | # the test_expect_* functions instead. |
886856ab JH |
766 | |
767 | test_ok_ () { | |
d5d9de1b | 768 | test_success=$(($test_success + 1)) |
633fe50a | 769 | say_color "" "ok $test_count - $@" |
3069f2a6 | 770 | finalize_test_case_output ok "$@" |
e1970ce4 JH |
771 | } |
772 | ||
46fb057a ÆAB |
773 | _invert_exit_code_failure_end_blurb () { |
774 | say_color warn "# faked up failures as TODO & now exiting with 0 due to --invert-exit-code" | |
775 | } | |
776 | ||
886856ab | 777 | test_failure_ () { |
3069f2a6 | 778 | failure_label=$1 |
d5d9de1b | 779 | test_failure=$(($test_failure + 1)) |
46fb057a ÆAB |
780 | local pfx="" |
781 | if test -n "$invert_exit_code" # && test -n "$HARNESS_ACTIVE" | |
782 | then | |
783 | pfx="# TODO induced breakage (--invert-exit-code):" | |
784 | fi | |
785 | say_color error "not ok $test_count - ${pfx:+$pfx }$1" | |
bf0dd8a8 | 786 | shift |
cb1aefda | 787 | printf '%s\n' "$*" | sed -e 's/^/# /' |
bbfbcd25 ÆAB |
788 | if test -n "$immediate" |
789 | then | |
790 | say_color error "1..$test_count" | |
46fb057a ÆAB |
791 | if test -n "$invert_exit_code" |
792 | then | |
793 | finalize_test_output | |
794 | _invert_exit_code_failure_end_blurb | |
795 | GIT_EXIT_OK=t | |
796 | exit 0 | |
797 | fi | |
5fabf6e5 | 798 | check_test_results_san_file_ "$test_failure" |
bbfbcd25 ÆAB |
799 | _error_exit |
800 | fi | |
3069f2a6 | 801 | finalize_test_case_output failure "$failure_label" "$@" |
886856ab JH |
802 | } |
803 | ||
41ac414e | 804 | test_known_broken_ok_ () { |
41ac414e | 805 | test_fixed=$(($test_fixed+1)) |
6d00680d ÆAB |
806 | say_color error "ok $test_count - $1 # TODO known breakage vanished" |
807 | finalize_test_case_output fixed "$1" | |
41ac414e JH |
808 | } |
809 | ||
810 | test_known_broken_failure_ () { | |
41ac414e | 811 | test_broken=$(($test_broken+1)) |
6d00680d ÆAB |
812 | say_color warn "not ok $test_count - $1 # TODO known breakage" |
813 | finalize_test_case_output broken "$1" | |
41ac414e | 814 | } |
886856ab JH |
815 | |
816 | test_debug () { | |
8e832ebc | 817 | test "$debug" = "" || eval "$1" |
e1970ce4 JH |
818 | } |
819 | ||
e6a6ddc9 TR |
820 | match_pattern_list () { |
821 | arg="$1" | |
822 | shift | |
823 | test -z "$*" && return 1 | |
560bf518 JK |
824 | # We need to use "$*" to get field-splitting, but we want to |
825 | # disable globbing, since we are matching against an arbitrary | |
826 | # $arg, not what's in the filesystem. Using "set -f" accomplishes | |
827 | # that, but we must do it in a subshell to avoid impacting the | |
828 | # rest of the script. The exit value of the subshell becomes | |
829 | # the function's return value. | |
830 | ( | |
831 | set -f | |
832 | for pattern_ in $* | |
833 | do | |
834 | case "$arg" in | |
835 | $pattern_) | |
836 | exit 0 | |
837 | ;; | |
838 | esac | |
839 | done | |
840 | exit 1 | |
841 | ) | |
e6a6ddc9 TR |
842 | } |
843 | ||
0445e6f0 | 844 | match_test_selector_list () { |
f21ac368 EN |
845 | operation="$1" |
846 | shift | |
0445e6f0 IB |
847 | title="$1" |
848 | shift | |
849 | arg="$1" | |
850 | shift | |
851 | test -z "$1" && return 0 | |
852 | ||
f21ac368 | 853 | # Commas are accepted as separators. |
0445e6f0 | 854 | OLDIFS=$IFS |
f21ac368 | 855 | IFS=',' |
0445e6f0 IB |
856 | set -- $1 |
857 | IFS=$OLDIFS | |
858 | ||
859 | # If the first selector is negative we include by default. | |
860 | include= | |
861 | case "$1" in | |
862 | !*) include=t ;; | |
863 | esac | |
864 | ||
865 | for selector | |
866 | do | |
867 | orig_selector=$selector | |
868 | ||
869 | positive=t | |
870 | case "$selector" in | |
871 | !*) | |
872 | positive= | |
873 | selector=${selector##?} | |
874 | ;; | |
875 | esac | |
876 | ||
877 | test -z "$selector" && continue | |
878 | ||
879 | case "$selector" in | |
880 | *-*) | |
881 | if expr "z${selector%%-*}" : "z[0-9]*[^0-9]" >/dev/null | |
882 | then | |
f21ac368 | 883 | echo "error: $operation: invalid non-numeric in range" \ |
0445e6f0 IB |
884 | "start: '$orig_selector'" >&2 |
885 | exit 1 | |
886 | fi | |
887 | if expr "z${selector#*-}" : "z[0-9]*[^0-9]" >/dev/null | |
888 | then | |
f21ac368 | 889 | echo "error: $operation: invalid non-numeric in range" \ |
0445e6f0 IB |
890 | "end: '$orig_selector'" >&2 |
891 | exit 1 | |
892 | fi | |
893 | ;; | |
894 | *) | |
895 | if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null | |
896 | then | |
f21ac368 EN |
897 | case "$title" in *${selector}*) |
898 | include=$positive | |
899 | ;; | |
900 | esac | |
901 | continue | |
0445e6f0 IB |
902 | fi |
903 | esac | |
904 | ||
905 | # Short cut for "obvious" cases | |
906 | test -z "$include" && test -z "$positive" && continue | |
907 | test -n "$include" && test -n "$positive" && continue | |
908 | ||
909 | case "$selector" in | |
910 | -*) | |
911 | if test $arg -le ${selector#-} | |
912 | then | |
913 | include=$positive | |
914 | fi | |
915 | ;; | |
916 | *-) | |
917 | if test $arg -ge ${selector%-} | |
918 | then | |
919 | include=$positive | |
920 | fi | |
921 | ;; | |
922 | *-*) | |
923 | if test ${selector%%-*} -le $arg \ | |
924 | && test $arg -le ${selector#*-} | |
925 | then | |
926 | include=$positive | |
927 | fi | |
928 | ;; | |
929 | *) | |
930 | if test $arg -eq $selector | |
931 | then | |
932 | include=$positive | |
933 | fi | |
934 | ;; | |
935 | esac | |
936 | done | |
937 | ||
938 | test -n "$include" | |
939 | } | |
940 | ||
ff09af3f TR |
941 | maybe_teardown_verbose () { |
942 | test -z "$verbose_only" && return | |
943 | exec 4>/dev/null 3>/dev/null | |
944 | verbose= | |
945 | } | |
946 | ||
947 | last_verbose=t | |
948 | maybe_setup_verbose () { | |
949 | test -z "$verbose_only" && return | |
560bf518 | 950 | if match_pattern_list $test_count "$verbose_only" |
ff09af3f | 951 | then |
d411d3d8 | 952 | exec 4>&2 3>&2 |
ff09af3f TR |
953 | # Emit a delimiting blank line when going from |
954 | # non-verbose to verbose. Within verbose mode the | |
955 | # delimiter is printed by test_expect_*. The choice | |
956 | # of the initial $last_verbose is such that before | |
957 | # test 1, we do not print it. | |
958 | test -z "$last_verbose" && echo >&3 "" | |
959 | verbose=t | |
960 | else | |
961 | exec 4>/dev/null 3>/dev/null | |
962 | verbose= | |
963 | fi | |
964 | last_verbose=$verbose | |
965 | } | |
966 | ||
5dfc368f TR |
967 | maybe_teardown_valgrind () { |
968 | test -z "$GIT_VALGRIND" && return | |
969 | GIT_VALGRIND_ENABLED= | |
970 | } | |
971 | ||
972 | maybe_setup_valgrind () { | |
973 | test -z "$GIT_VALGRIND" && return | |
26a07309 | 974 | if test -z "$valgrind_only" |
5dfc368f TR |
975 | then |
976 | GIT_VALGRIND_ENABLED=t | |
977 | return | |
978 | fi | |
979 | GIT_VALGRIND_ENABLED= | |
560bf518 | 980 | if match_pattern_list $test_count "$valgrind_only" |
5dfc368f TR |
981 | then |
982 | GIT_VALGRIND_ENABLED=t | |
983 | fi | |
984 | } | |
985 | ||
477dcadd | 986 | trace_level_=0 |
9b5fe78b | 987 | want_trace () { |
f5ba2de6 JK |
988 | test "$trace" = t && { |
989 | test "$verbose" = t || test "$verbose_log" = t | |
990 | } | |
9b5fe78b JK |
991 | } |
992 | ||
a136f6d8 JK |
993 | # This is a separate function because some tests use |
994 | # "return" to end a test_expect_success block early | |
995 | # (and we want to make sure we run any cleanup like | |
996 | # "set +x"). | |
997 | test_eval_inner_ () { | |
cc48ddd9 | 998 | eval "$*" |
a136f6d8 JK |
999 | } |
1000 | ||
a7c58f28 | 1001 | test_eval_ () { |
90c8a1db JK |
1002 | # If "-x" tracing is in effect, then we want to avoid polluting stderr |
1003 | # with non-test commands. But once in "set -x" mode, we cannot prevent | |
a136f6d8 JK |
1004 | # the shell from printing the "set +x" to turn it off (nor the saving |
1005 | # of $? before that). But we can make sure that the output goes to | |
1006 | # /dev/null. | |
1007 | # | |
90c8a1db JK |
1008 | # There are a few subtleties here: |
1009 | # | |
1010 | # - we have to redirect descriptor 4 in addition to 2, to cover | |
1011 | # BASH_XTRACEFD | |
1012 | # | |
1013 | # - the actual eval has to come before the redirection block (since | |
1014 | # it needs to see descriptor 4 to set up its stderr) | |
1015 | # | |
1016 | # - likewise, any error message we print must be outside the block to | |
1017 | # access descriptor 4 | |
1018 | # | |
1019 | # - checking $? has to come immediately after the eval, but it must | |
1020 | # be _inside_ the block to avoid polluting the "set -x" output | |
1021 | # | |
1022 | ||
cc48ddd9 JK |
1023 | # Do not add anything extra (including LF) after '$*' |
1024 | test_eval_inner_ </dev/null >&3 2>&4 " | |
1025 | want_trace && trace_level_=$(($trace_level_+1)) && set -x | |
1026 | $*" | |
a136f6d8 | 1027 | { |
a136f6d8 | 1028 | test_eval_ret_=$? |
9b5fe78b | 1029 | if want_trace |
a136f6d8 | 1030 | then |
477dcadd JS |
1031 | test 1 = $trace_level_ && set +x |
1032 | trace_level_=$(($trace_level_-1)) | |
a136f6d8 | 1033 | fi |
90c8a1db JK |
1034 | } 2>/dev/null 4>&2 |
1035 | ||
1036 | if test "$test_eval_ret_" != 0 && want_trace | |
1037 | then | |
1038 | say_color error >&4 "error: last command exited with \$?=$test_eval_ret_" | |
1039 | fi | |
a136f6d8 | 1040 | return $test_eval_ret_ |
a7c58f28 JN |
1041 | } |
1042 | ||
1686de55 JK |
1043 | fail_117 () { |
1044 | return 117 | |
1045 | } | |
1046 | ||
4d9d62fa | 1047 | test_run_ () { |
b6b0afdc | 1048 | test_cleanup=: |
b586744a | 1049 | expecting_failure=$2 |
bb79af9d | 1050 | |
92b269f5 | 1051 | if test "${GIT_TEST_CHAIN_LINT:-1}" != 0; then |
bb79af9d JK |
1052 | # 117 is magic because it is unlikely to match the exit |
1053 | # code of other programs | |
cc48ddd9 | 1054 | test_eval_inner_ "fail_117 && $1" </dev/null >&3 2>&4 |
750b2604 | 1055 | if test $? != 117 |
99a64e4b | 1056 | then |
750b2604 | 1057 | BUG "broken &&-chain: $1" |
bb79af9d JK |
1058 | fi |
1059 | fi | |
1060 | ||
a57397b0 | 1061 | setup_malloc_check |
a7c58f28 | 1062 | test_eval_ "$1" |
b6b0afdc | 1063 | eval_ret=$? |
a57397b0 | 1064 | teardown_malloc_check |
b586744a | 1065 | |
a136f6d8 JK |
1066 | if test -z "$immediate" || test $eval_ret = 0 || |
1067 | test -n "$expecting_failure" && test "$test_cleanup" != ":" | |
b586744a | 1068 | then |
1b3185fc | 1069 | setup_malloc_check |
a7c58f28 | 1070 | test_eval_ "$test_cleanup" |
1b3185fc | 1071 | teardown_malloc_check |
b586744a | 1072 | fi |
1c0cc756 RJ |
1073 | if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE" |
1074 | then | |
57e1538a ÆAB |
1075 | echo "" |
1076 | fi | |
aa0bcf96 | 1077 | return "$eval_ret" |
4d9d62fa PR |
1078 | } |
1079 | ||
ae75342c | 1080 | test_start_ () { |
8586f98b | 1081 | test_count=$(($test_count+1)) |
ff09af3f | 1082 | maybe_setup_verbose |
5dfc368f | 1083 | maybe_setup_valgrind |
0f5ae593 | 1084 | start_test_case_output "$@" |
ae75342c TR |
1085 | } |
1086 | ||
1087 | test_finish_ () { | |
1088 | echo >&3 "" | |
5dfc368f | 1089 | maybe_teardown_valgrind |
ff09af3f | 1090 | maybe_teardown_verbose |
af9912ef JS |
1091 | if test -n "$GIT_TEST_TEE_OFFSET" |
1092 | then | |
1093 | GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \ | |
1094 | "$GIT_TEST_TEE_OUTPUT_FILE") | |
1095 | fi | |
ae75342c TR |
1096 | } |
1097 | ||
1098 | test_skip () { | |
04ece593 | 1099 | to_skip= |
ef2ac68d | 1100 | skipped_reason= |
560bf518 | 1101 | if match_pattern_list $this_test.$test_count "$GIT_SKIP_TESTS" |
e6a6ddc9 TR |
1102 | then |
1103 | to_skip=t | |
ef2ac68d | 1104 | skipped_reason="GIT_SKIP_TESTS" |
e6a6ddc9 | 1105 | fi |
e0316695 | 1106 | if test -z "$to_skip" && test -n "$run_list" && |
f21ac368 | 1107 | ! match_test_selector_list '--run' "$1" $test_count "$run_list" |
e0316695 SG |
1108 | then |
1109 | to_skip=t | |
1110 | skipped_reason="--run" | |
1111 | fi | |
05236a5e JN |
1112 | if test -z "$to_skip" && test -n "$test_prereq" && |
1113 | ! test_have_prereq "$test_prereq" | |
a7bb3940 JS |
1114 | then |
1115 | to_skip=t | |
ef2ac68d | 1116 | |
07431fc8 | 1117 | of_prereq= |
05236a5e | 1118 | if test "$missing_prereq" != "$test_prereq" |
07431fc8 | 1119 | then |
05236a5e | 1120 | of_prereq=" of $test_prereq" |
07431fc8 | 1121 | fi |
ef2ac68d | 1122 | skipped_reason="missing $missing_prereq${of_prereq}" |
49da4040 FS |
1123 | |
1124 | # Keep a list of all the missing prereq for result aggregation | |
1125 | if test -z "$missing_prereq" | |
1126 | then | |
1127 | test_missing_prereq=$missing_prereq | |
1128 | else | |
1129 | test_missing_prereq="$test_missing_prereq,$missing_prereq" | |
1130 | fi | |
ef2ac68d | 1131 | fi |
07431fc8 | 1132 | |
ef2ac68d IB |
1133 | case "$to_skip" in |
1134 | t) | |
22231908 | 1135 | |
ef2ac68d | 1136 | say_color skip "ok $test_count # skip $1 ($skipped_reason)" |
04ece593 | 1137 | : true |
3069f2a6 | 1138 | finalize_test_case_output skip "$@" |
04ece593 JH |
1139 | ;; |
1140 | *) | |
1141 | false | |
1142 | ;; | |
1143 | esac | |
1144 | } | |
1145 | ||
342e9ef2 TR |
1146 | # stub; perf-lib overrides it |
1147 | test_at_end_hook_ () { | |
1148 | : | |
1149 | } | |
1150 | ||
900721e1 JS |
1151 | test_atexit_cleanup=: |
1152 | test_atexit_handler () { | |
1153 | # In a succeeding test script 'test_atexit_handler' is invoked | |
1154 | # twice: first from 'test_done', then from 'die' in the trap on | |
1155 | # EXIT. | |
1156 | # This condition and resetting 'test_atexit_cleanup' below makes | |
1157 | # sure that the registered cleanup commands are run only once. | |
1158 | test : != "$test_atexit_cleanup" || return 0 | |
1159 | ||
1160 | setup_malloc_check | |
1161 | test_eval_ "$test_atexit_cleanup" | |
1162 | test_atexit_cleanup=: | |
1163 | teardown_malloc_check | |
1164 | } | |
1165 | ||
8d24d56c JK |
1166 | check_test_results_san_file_has_entries_ () { |
1167 | test -z "$TEST_RESULTS_SAN_FILE" && return 1 | |
373a4326 | 1168 | |
164a2516 JK |
1169 | # Lines marked with DEDUP_TOKEN show unique leaks. We only care that we |
1170 | # found at least one. | |
1171 | # | |
1172 | # But also suppress any false positives caused by bugs or races in the | |
1173 | # sanitizer itself. | |
b9a9df93 | 1174 | grep -s ^DEDUP_TOKEN "$TEST_RESULTS_SAN_FILE".* | |
b119a687 | 1175 | grep -qv sanitizer::GetThreadStackTopAndBottom |
cf146433 JK |
1176 | } |
1177 | ||
faececa5 | 1178 | check_test_results_san_file_ () { |
8d24d56c | 1179 | if ! check_test_results_san_file_has_entries_ |
faececa5 ÆAB |
1180 | then |
1181 | return | |
1182 | fi && | |
faececa5 ÆAB |
1183 | say_color error "$(cat "$TEST_RESULTS_SAN_FILE".*)" && |
1184 | ||
1fc7ddf3 | 1185 | if test "$test_failure" = 0 |
47c6d4da | 1186 | then |
8c1d6691 | 1187 | say "Our logs revealed a memory leak, exit non-zero!" && |
faececa5 | 1188 | invert_exit_code=t |
47c6d4da | 1189 | else |
8c1d6691 | 1190 | say "Our logs revealed a memory leak..." |
faececa5 ÆAB |
1191 | fi |
1192 | } | |
1193 | ||
e1970ce4 | 1194 | test_done () { |
900721e1 JS |
1195 | # Run the atexit commands _before_ the trash directory is |
1196 | # removed, so the commands can access pidfiles and socket files. | |
1197 | test_atexit_handler | |
1198 | ||
78d5e4cf | 1199 | finalize_test_output |
22231908 | 1200 | |
1c0cc756 RJ |
1201 | if test -z "$HARNESS_ACTIVE" |
1202 | then | |
62c379b8 | 1203 | mkdir -p "$TEST_RESULTS_DIR" |
8ef1abe5 | 1204 | |
62c379b8 | 1205 | cat >"$TEST_RESULTS_BASE.counts" <<-EOF |
c54e6be7 ML |
1206 | total $test_count |
1207 | success $test_success | |
1208 | fixed $test_fixed | |
1209 | broken $test_broken | |
1210 | failed $test_failure | |
49da4040 | 1211 | missing_prereq $test_missing_prereq |
c54e6be7 ML |
1212 | |
1213 | EOF | |
8ef1abe5 | 1214 | fi |
41ac414e JH |
1215 | |
1216 | if test "$test_fixed" != 0 | |
1217 | then | |
633fe50a | 1218 | say_color error "# $test_fixed known breakage(s) vanished; please update test(s)" |
41ac414e JH |
1219 | fi |
1220 | if test "$test_broken" != 0 | |
1221 | then | |
633fe50a | 1222 | say_color warn "# still have $test_broken known breakage(s)" |
b73d9a23 AS |
1223 | fi |
1224 | if test "$test_broken" != 0 || test "$test_fixed" != 0 | |
1225 | then | |
1226 | test_remaining=$(( $test_count - $test_broken - $test_fixed )) | |
1227 | msg="remaining $test_remaining test(s)" | |
11d54b8b | 1228 | else |
b73d9a23 | 1229 | test_remaining=$test_count |
11d54b8b | 1230 | msg="$test_count test(s)" |
41ac414e | 1231 | fi |
e1970ce4 | 1232 | case "$test_failure" in |
10b94e28 | 1233 | 0) |
5beca49a | 1234 | if test $test_remaining -gt 0 |
1c0cc756 | 1235 | then |
5beca49a | 1236 | say_color pass "# passed all $msg" |
d998bd4a | 1237 | fi |
abc5d372 | 1238 | |
5beca49a ÆAB |
1239 | # Maybe print SKIP message |
1240 | test -z "$skip_all" || skip_all="# SKIP $skip_all" | |
1241 | case "$test_count" in | |
1242 | 0) | |
1243 | say "1..$test_count${skip_all:+ $skip_all}" | |
1244 | ;; | |
1245 | *) | |
1246 | test -z "$skip_all" || | |
1247 | say_color warn "$skip_all" | |
1248 | say "1..$test_count" | |
1249 | ;; | |
1250 | esac | |
1251 | ||
46fb057a ÆAB |
1252 | if test -n "$stress" && test -n "$invert_exit_code" |
1253 | then | |
1254 | # We're about to move our "$TRASH_DIRECTORY" | |
1255 | # to "$TRASH_DIRECTORY.stress-failed" if | |
1256 | # --stress is combined with | |
1257 | # --invert-exit-code. | |
1258 | say "with --stress and --invert-exit-code we're not removing '$TRASH_DIRECTORY'" | |
1259 | elif test -z "$debug" && test -n "$remove_trash" | |
4d0912a2 | 1260 | then |
06478dab | 1261 | test -d "$TRASH_DIRECTORY" || |
4d0912a2 | 1262 | error "Tests passed but trash directory already removed before test cleanup; aborting" |
abc5d372 | 1263 | |
06478dab | 1264 | cd "$TRASH_DIRECTORY/.." && |
046e90d1 JS |
1265 | rm -fr "$TRASH_DIRECTORY" || { |
1266 | # try again in a bit | |
1267 | sleep 5; | |
1268 | rm -fr "$TRASH_DIRECTORY" | |
1269 | } || | |
4d0912a2 | 1270 | error "Tests passed but test cleanup failed; aborting" |
4d0912a2 | 1271 | fi |
46fb057a | 1272 | |
faececa5 ÆAB |
1273 | check_test_results_san_file_ "$test_failure" |
1274 | ||
5e0752b0 PS |
1275 | if test "$test_fixed" != 0 |
1276 | then | |
1277 | if test -z "$invert_exit_code" | |
1278 | then | |
1279 | GIT_EXIT_OK=t | |
1280 | exit 1 | |
1281 | fi | |
1282 | elif test -z "$skip_all" && test -n "$invert_exit_code" | |
46fb057a ÆAB |
1283 | then |
1284 | say_color warn "# faking up non-zero exit with --invert-exit-code" | |
1285 | GIT_EXIT_OK=t | |
1286 | exit 1 | |
1287 | fi | |
1288 | ||
342e9ef2 TR |
1289 | test_at_end_hook_ |
1290 | ||
25c2351d | 1291 | GIT_EXIT_OK=t |
e1970ce4 JH |
1292 | exit 0 ;; |
1293 | ||
1294 | *) | |
5beca49a ÆAB |
1295 | say_color error "# failed $test_failure among $msg" |
1296 | say "1..$test_count" | |
5099b99d | 1297 | |
faececa5 ÆAB |
1298 | check_test_results_san_file_ "$test_failure" |
1299 | ||
46fb057a ÆAB |
1300 | if test -n "$invert_exit_code" |
1301 | then | |
1302 | _invert_exit_code_failure_end_blurb | |
1303 | GIT_EXIT_OK=t | |
1304 | exit 0 | |
1305 | fi | |
1306 | ||
25c2351d | 1307 | GIT_EXIT_OK=t |
e1970ce4 JH |
1308 | exit 1 ;; |
1309 | ||
1310 | esac | |
1311 | } | |
1312 | ||
e4597aae | 1313 | if test -n "$valgrind" |
4e1be63c | 1314 | then |
4e1be63c JS |
1315 | make_symlink () { |
1316 | test -h "$2" && | |
1317 | test "$1" = "$(readlink "$2")" || { | |
1318 | # be super paranoid | |
1319 | if mkdir "$2".lock | |
1320 | then | |
1321 | rm -f "$2" && | |
1322 | ln -s "$1" "$2" && | |
1323 | rm -r "$2".lock | |
1324 | else | |
1325 | while test -d "$2".lock | |
1326 | do | |
1327 | say "Waiting for lock on $2." | |
1328 | sleep 1 | |
1329 | done | |
1330 | fi | |
1331 | } | |
1332 | } | |
1333 | ||
1334 | make_valgrind_symlink () { | |
36bfb0e5 | 1335 | # handle only executables, unless they are shell libraries that |
11d62145 | 1336 | # need to be in the exec-path. |
36bfb0e5 | 1337 | test -x "$1" || |
2a59a6ef | 1338 | test "# " = "$(test_copy_bytes 2 <"$1")" || |
36bfb0e5 | 1339 | return; |
4e1be63c JS |
1340 | |
1341 | base=$(basename "$1") | |
28fab7b2 RS |
1342 | case "$base" in |
1343 | test-*) | |
1344 | symlink_target="$GIT_BUILD_DIR/t/helper/$base" | |
1345 | ;; | |
1346 | *) | |
1347 | symlink_target="$GIT_BUILD_DIR/$base" | |
1348 | ;; | |
1349 | esac | |
4e1be63c JS |
1350 | # do not override scripts |
1351 | if test -x "$symlink_target" && | |
1352 | test ! -d "$symlink_target" && | |
2a59a6ef | 1353 | test "#!" != "$(test_copy_bytes 2 <"$symlink_target")" |
4e1be63c JS |
1354 | then |
1355 | symlink_target=../valgrind.sh | |
1356 | fi | |
efd92ffd JS |
1357 | case "$base" in |
1358 | *.sh|*.perl) | |
1359 | symlink_target=../unprocessed-script | |
1360 | esac | |
4e1be63c JS |
1361 | # create the link, or replace it if it is out of date |
1362 | make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit | |
1363 | } | |
1364 | ||
26a07309 TR |
1365 | # override all git executables in TEST_DIRECTORY/.. |
1366 | GIT_VALGRIND=$TEST_DIRECTORY/valgrind | |
1367 | mkdir -p "$GIT_VALGRIND"/bin | |
503e2241 | 1368 | for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/t/helper/test-* |
26a07309 TR |
1369 | do |
1370 | make_valgrind_symlink $file | |
1371 | done | |
1372 | # special-case the mergetools loadables | |
1373 | make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools" | |
1374 | OLDIFS=$IFS | |
1375 | IFS=: | |
1376 | for path in $PATH | |
1377 | do | |
1378 | ls "$path"/git-* 2> /dev/null | | |
1379 | while read file | |
ad0e6233 | 1380 | do |
26a07309 | 1381 | make_valgrind_symlink "$file" |
ad0e6233 | 1382 | done |
26a07309 TR |
1383 | done |
1384 | IFS=$OLDIFS | |
4e1be63c JS |
1385 | PATH=$GIT_VALGRIND/bin:$PATH |
1386 | GIT_EXEC_PATH=$GIT_VALGRIND/bin | |
1387 | export GIT_VALGRIND | |
952af351 TR |
1388 | GIT_VALGRIND_MODE="$valgrind" |
1389 | export GIT_VALGRIND_MODE | |
5dfc368f | 1390 | GIT_VALGRIND_ENABLED=t |
26a07309 | 1391 | test -n "$valgrind_only" && GIT_VALGRIND_ENABLED= |
5dfc368f | 1392 | export GIT_VALGRIND_ENABLED |
1c0cc756 RJ |
1393 | elif test -n "$GIT_TEST_INSTALLED" |
1394 | then | |
e4597aae MO |
1395 | GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || |
1396 | error "Cannot run git from $GIT_TEST_INSTALLED." | |
16df35cb | 1397 | PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH |
e4597aae MO |
1398 | GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH} |
1399 | else # normal case, use ../bin-wrappers only unless $with_dashes: | |
dd167a30 | 1400 | if test -n "$no_bin_wrappers" |
1c0cc756 | 1401 | then |
dd167a30 JS |
1402 | with_dashes=t |
1403 | else | |
1404 | git_bin_dir="$GIT_BUILD_DIR/bin-wrappers" | |
1405 | if ! test -x "$git_bin_dir/git" | |
1c0cc756 | 1406 | then |
dd167a30 JS |
1407 | if test -z "$with_dashes" |
1408 | then | |
1409 | say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH" | |
1410 | fi | |
1411 | with_dashes=t | |
e4597aae | 1412 | fi |
dd167a30 | 1413 | PATH="$git_bin_dir:$PATH" |
e4597aae | 1414 | fi |
6cec5c68 | 1415 | GIT_EXEC_PATH=$GIT_BUILD_DIR |
1c0cc756 RJ |
1416 | if test -n "$with_dashes" |
1417 | then | |
ca7312d3 | 1418 | PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH" |
e4597aae | 1419 | fi |
4e1be63c | 1420 | fi |
7e0730c8 | 1421 | GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR" |
8bfa6bd6 | 1422 | GIT_CONFIG_NOSYSTEM=1 |
3c995beb | 1423 | GIT_ATTR_NOSYSTEM=1 |
614c3d8f SG |
1424 | GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/.." |
1425 | export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM GIT_CEILING_DIRECTORIES | |
49ccb087 | 1426 | |
72ad6dc3 JK |
1427 | # Add libc MALLOC and MALLOC_PERTURB test only if we are not executing |
1428 | # the test with valgrind and have not compiled with conflict SANITIZE | |
1429 | # options. | |
1430 | if test -n "$valgrind" || | |
1431 | test -n "$SANITIZE_ADDRESS" || | |
1432 | test -n "$SANITIZE_LEAK" || | |
1433 | test -n "$TEST_NO_MALLOC_CHECK" | |
1434 | then | |
1435 | setup_malloc_check () { | |
1436 | : nothing | |
1437 | } | |
1438 | teardown_malloc_check () { | |
1439 | : nothing | |
1440 | } | |
1441 | else | |
1442 | _USE_GLIBC_TUNABLES= | |
1443 | _USE_GLIBC_PRELOAD=libc_malloc_debug.so.0 | |
1444 | if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) && | |
1445 | _GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} && | |
1446 | expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null && | |
1447 | stderr=$(LD_PRELOAD=$_USE_GLIBC_PRELOAD git version 2>&1 >/dev/null) && | |
1448 | test -z "$stderr" | |
1449 | then | |
1450 | _USE_GLIBC_TUNABLES=YesPlease | |
1451 | fi | |
1452 | setup_malloc_check () { | |
1453 | local g | |
1454 | local t | |
1455 | MALLOC_CHECK_=3 MALLOC_PERTURB_=165 | |
1456 | export MALLOC_CHECK_ MALLOC_PERTURB_ | |
1457 | if test -n "$_USE_GLIBC_TUNABLES" | |
1458 | then | |
1459 | g= | |
1460 | LD_PRELOAD=$_USE_GLIBC_PRELOAD | |
1461 | for t in \ | |
1462 | glibc.malloc.check=1 \ | |
1463 | glibc.malloc.perturb=165 | |
1464 | do | |
1465 | g="${g#:}:$t" | |
1466 | done | |
1467 | GLIBC_TUNABLES=$g | |
1468 | export LD_PRELOAD GLIBC_TUNABLES | |
1469 | fi | |
1470 | } | |
1471 | teardown_malloc_check () { | |
1472 | unset MALLOC_CHECK_ MALLOC_PERTURB_ | |
1473 | unset LD_PRELOAD GLIBC_TUNABLES | |
1474 | } | |
1475 | fi | |
1476 | ||
5e87eae9 JH |
1477 | if test -z "$GIT_TEST_CMP" |
1478 | then | |
1479 | if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT" | |
1480 | then | |
1481 | GIT_TEST_CMP="$DIFF -c" | |
1482 | else | |
1483 | GIT_TEST_CMP="$DIFF -u" | |
1484 | fi | |
1485 | fi | |
1486 | ||
7e0730c8 | 1487 | GITPERLLIB="$GIT_TEST_GITPERLLIB" |
6fcca938 | 1488 | export GITPERLLIB |
7e0730c8 | 1489 | test -d "$GIT_TEMPLATE_DIR" || { |
25c2351d | 1490 | BAIL_OUT "You haven't built things yet, have you?" |
eea42069 | 1491 | } |
e1970ce4 | 1492 | |
d609615f | 1493 | if ! test -x "$GIT_BUILD_DIR"/t/helper/test-tool$X |
1c0cc756 | 1494 | then |
25c2351d | 1495 | BAIL_OUT 'You need to build test-tool; Run "make t/helper/test-tool" in the source (toplevel) directory' |
56cf9806 EW |
1496 | fi |
1497 | ||
edc23840 ÆAB |
1498 | # Are we running this test at all? |
1499 | remove_trash= | |
1500 | this_test=${0##*/} | |
1501 | this_test=${this_test%%-*} | |
560bf518 | 1502 | if match_pattern_list "$this_test" "$GIT_SKIP_TESTS" |
edc23840 ÆAB |
1503 | then |
1504 | say_color info >&3 "skipping test $this_test altogether" | |
1505 | skip_all="skip all tests in $this_test" | |
1506 | test_done | |
1507 | fi | |
1508 | ||
956d2e46 ÆAB |
1509 | if test -n "$SANITIZE_LEAK" |
1510 | then | |
95c679ad | 1511 | rm -rf "$TEST_RESULTS_SAN_DIR" |
8c1d6691 | 1512 | if ! mkdir -p "$TEST_RESULTS_SAN_DIR" |
366bd129 | 1513 | then |
8c1d6691 RJ |
1514 | BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR" |
1515 | fi && | |
1516 | TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX" | |
366bd129 | 1517 | |
8c1d6691 RJ |
1518 | # Don't litter *.leak dirs if there was nothing to report |
1519 | test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :" | |
1520 | ||
1521 | prepend_var LSAN_OPTIONS : dedup_token_length=9999 | |
1522 | prepend_var LSAN_OPTIONS : log_exe_name=1 | |
ed7634eb | 1523 | prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'" |
8c1d6691 | 1524 | export LSAN_OPTIONS |
956d2e46 ÆAB |
1525 | fi |
1526 | ||
8afecde5 PS |
1527 | if test -z "$PERL_PATH" |
1528 | then | |
1529 | case "${GIT_TEST_CHAIN_LINT:-unset}" in | |
1530 | unset) | |
1531 | GIT_TEST_CHAIN_LINT=0 | |
1532 | ;; | |
1533 | 0) | |
1534 | # The user has explicitly disabled the chain linter, so we | |
1535 | # don't have anything to worry about. | |
1536 | ;; | |
1537 | *) | |
1538 | BAIL_OUT 'You need Perl for the chain linter' | |
1539 | ;; | |
1540 | esac | |
1541 | fi | |
1542 | ||
7b6555ab JK |
1543 | if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 && |
1544 | test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0 | |
23a14f30 ES |
1545 | then |
1546 | "$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" || | |
a13ff419 | 1547 | BUG "lint error (see 'LINT' annotations above)" |
23a14f30 ES |
1548 | fi |
1549 | ||
edc23840 | 1550 | # Last-minute variable setup |
add5240f | 1551 | USER_HOME="$HOME" |
edc23840 ÆAB |
1552 | HOME="$TRASH_DIRECTORY" |
1553 | GNUPGHOME="$HOME/gnupg-home-not-used" | |
add5240f | 1554 | export HOME GNUPGHOME USER_HOME |
edc23840 | 1555 | |
5d22e189 ÆAB |
1556 | # "rm -rf" existing trash directory, even if a previous run left it |
1557 | # with bad permissions. | |
1558 | remove_trash_directory () { | |
1559 | dir="$1" | |
1560 | if ! rm -rf "$dir" 2>/dev/null | |
1561 | then | |
1562 | chmod -R u+rwx "$dir" | |
1563 | rm -rf "$dir" | |
1564 | fi | |
1565 | ! test -d "$dir" | |
1566 | } | |
1567 | ||
e1970ce4 | 1568 | # Test repository |
5d22e189 | 1569 | remove_trash_directory "$TRASH_DIRECTORY" || { |
25c2351d | 1570 | BAIL_OUT 'cannot prepare test area' |
8d14ac94 JH |
1571 | } |
1572 | ||
edc23840 | 1573 | remove_trash=t |
1c0cc756 RJ |
1574 | if test -z "$TEST_NO_CREATE_REPO" |
1575 | then | |
e942292a ÆAB |
1576 | git init \ |
1577 | ${TEST_CREATE_REPO_NO_TEMPLATE:+--template=} \ | |
1578 | "$TRASH_DIRECTORY" >&3 2>&4 || | |
f0d4d398 | 1579 | error "cannot run git init" |
342e9ef2 | 1580 | else |
38b074de | 1581 | mkdir -p "$TRASH_DIRECTORY" |
342e9ef2 | 1582 | fi |
22231908 | 1583 | |
1bd9c648 LW |
1584 | # Use -P to resolve symlinks in our working directory so that the cwd |
1585 | # in subprocesses like git equals our $PWD (for pathname comparisons). | |
25c2351d | 1586 | cd -P "$TRASH_DIRECTORY" || BAIL_OUT "cannot cd -P to \"$TRASH_DIRECTORY\"" |
2d207ed1 MM |
1587 | TRASH_DIRECTORY=$(pwd) |
1588 | HOME="$TRASH_DIRECTORY" | |
04ece593 | 1589 | |
78d5e4cf | 1590 | start_test_output "$0" |
22231908 | 1591 | |
192b5175 | 1592 | # Convenience |
70507911 | 1593 | # A regexp to match 5 and 35 hexdigits |
192b5175 | 1594 | _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' |
1595 | _x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05" | |
192b5175 | 1596 | |
1597 | test_oid_init | |
1598 | ||
1599 | ZERO_OID=$(test_oid zero) | |
1600 | OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g') | |
a1142963 | 1601 | OIDPATH_REGEX=$(test_oid_to_path $ZERO_OID | sed -e 's/0/[0-9a-f]/g') |
192b5175 | 1602 | EMPTY_TREE=$(test_oid empty_tree) |
1603 | EMPTY_BLOB=$(test_oid empty_blob) | |
192b5175 | 1604 | |
11f470ae JH |
1605 | # Provide an implementation of the 'yes' utility; the upper bound |
1606 | # limit is there to help Windows that cannot stop this loop from | |
1607 | # wasting cycles when the downstream stops reading, so do not be | |
1608 | # tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib: | |
1609 | # limit the output of the yes utility", 2016-02-02) | |
8648732e BC |
1610 | yes () { |
1611 | if test $# = 0 | |
1612 | then | |
1613 | y=y | |
1614 | else | |
1615 | y="$*" | |
1616 | fi | |
1617 | ||
6129c930 JS |
1618 | i=0 |
1619 | while test $i -lt 99 | |
8648732e | 1620 | do |
6129c930 JS |
1621 | echo "$y" |
1622 | i=$(($i+1)) | |
8648732e BC |
1623 | done |
1624 | } | |
1625 | ||
c7400399 ÆAB |
1626 | # The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and |
1627 | # thus needs to be set up really early, and set an internal variable | |
1628 | # for convenience so the hot test_set_prereq() codepath doesn't need | |
4a1baacd | 1629 | # to call "test-tool env-helper" (via test_bool_env). Only do that work |
43a2afee | 1630 | # if needed by seeing if GIT_TEST_FAIL_PREREQS is set at all. |
c7400399 ÆAB |
1631 | GIT_TEST_FAIL_PREREQS_INTERNAL= |
1632 | if test -n "$GIT_TEST_FAIL_PREREQS" | |
1633 | then | |
43a2afee | 1634 | if test_bool_env GIT_TEST_FAIL_PREREQS false |
c7400399 ÆAB |
1635 | then |
1636 | GIT_TEST_FAIL_PREREQS_INTERNAL=true | |
1637 | test_set_prereq FAIL_PREREQS | |
1638 | fi | |
1639 | else | |
1640 | test_lazy_prereq FAIL_PREREQS ' | |
43a2afee | 1641 | test_bool_env GIT_TEST_FAIL_PREREQS false |
c7400399 ÆAB |
1642 | ' |
1643 | fi | |
1644 | ||
7187c7bb | 1645 | # Fix some commands on Windows, and other OS-specific things |
d98b2c5f JS |
1646 | uname_s=$(uname -s) |
1647 | case $uname_s in | |
d3d8c601 PS |
1648 | Darwin) |
1649 | test_set_prereq MACOS | |
2f71f610 RJ |
1650 | test_set_prereq POSIXPERM |
1651 | test_set_prereq BSLASHPSPEC | |
1652 | test_set_prereq EXECKEEPSPID | |
d3d8c601 | 1653 | ;; |
f17e9fbb JS |
1654 | *MINGW*) |
1655 | # Windows has its own (incompatible) sort and find | |
1656 | sort () { | |
1657 | /usr/bin/sort "$@" | |
1658 | } | |
1659 | find () { | |
1660 | /usr/bin/find "$@" | |
1661 | } | |
4114156a JS |
1662 | # git sees Windows-style pwd |
1663 | pwd () { | |
1664 | builtin pwd -W | |
1665 | } | |
ee9fb68c | 1666 | # no POSIX permissions |
6fd1106a | 1667 | # backslashes in pathspec are converted to '/' |
fb9a2bea | 1668 | # exec does not inherit the PID |
a94114ad | 1669 | test_set_prereq MINGW |
5f4e02e5 | 1670 | test_set_prereq NATIVE_CRLF |
a31d0665 | 1671 | test_set_prereq SED_STRIPS_CR |
97669eed | 1672 | test_set_prereq GREP_STRIPS_CR |
bccc37fd | 1673 | test_set_prereq WINDOWS |
a3795bf0 | 1674 | GIT_TEST_CMP="GIT_DIR=/dev/null git diff --no-index --ignore-cr-at-eol --" |
a31d0665 RJ |
1675 | ;; |
1676 | *CYGWIN*) | |
1677 | test_set_prereq POSIXPERM | |
a31d0665 | 1678 | test_set_prereq EXECKEEPSPID |
cfa96496 | 1679 | test_set_prereq CYGWIN |
a31d0665 | 1680 | test_set_prereq SED_STRIPS_CR |
97669eed | 1681 | test_set_prereq GREP_STRIPS_CR |
bccc37fd | 1682 | test_set_prereq WINDOWS |
ee9fb68c JS |
1683 | ;; |
1684 | *) | |
1685 | test_set_prereq POSIXPERM | |
6fd1106a | 1686 | test_set_prereq BSLASHPSPEC |
fb9a2bea | 1687 | test_set_prereq EXECKEEPSPID |
f17e9fbb JS |
1688 | ;; |
1689 | esac | |
704a3143 | 1690 | |
ddcfc7c6 GP |
1691 | # Detect arches where a few things don't work |
1692 | uname_m=$(uname -m) | |
1693 | case $uname_m in | |
1694 | parisc* | hppa*) | |
1695 | test_set_prereq HPPA | |
1696 | ;; | |
1697 | esac | |
1698 | ||
58aaf591 PS |
1699 | case "$GIT_DEFAULT_REF_FORMAT" in |
1700 | files) | |
1701 | test_set_prereq REFFILES;; | |
57db2a09 PS |
1702 | reftable) |
1703 | test_set_prereq REFTABLE;; | |
58aaf591 PS |
1704 | *) |
1705 | echo 2>&1 "error: unknown ref format $GIT_DEFAULT_REF_FORMAT" | |
1706 | exit 1 | |
1707 | ;; | |
1708 | esac | |
c305e667 | 1709 | |
b082687c | 1710 | ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1 |
7596fe95 | 1711 | test -z "$NO_CURL" && test_set_prereq LIBCURL |
cbcc2f79 | 1712 | test -z "$NO_GITWEB" && test_set_prereq GITWEB |
df383b58 | 1713 | test -z "$NO_ICONV" && test_set_prereq ICONV |
1b19ccd2 | 1714 | test -z "$NO_PERL" && test_set_prereq PERL |
68c7d276 | 1715 | test -z "$NO_PTHREADS" && test_set_prereq PTHREADS |
d4e1b47a | 1716 | test -z "$NO_PYTHON" && test_set_prereq PYTHON |
7599730b | 1717 | test -n "$USE_LIBPCRE2" && test_set_prereq PCRE |
ce9a2570 | 1718 | test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2 |
5e9637c6 | 1719 | test -z "$NO_GETTEXT" && test_set_prereq GETTEXT |
2cdc292b | 1720 | test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK |
58407e04 | 1721 | test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND |
23e21a58 | 1722 | test -n "$PERL_PATH" && test_set_prereq PERL_TEST_HELPERS |
1b19ccd2 | 1723 | |
4592e608 NTND |
1724 | if test -z "$GIT_TEST_CHECK_CACHE_TREE" |
1725 | then | |
1726 | GIT_TEST_CHECK_CACHE_TREE=true | |
1727 | export GIT_TEST_CHECK_CACHE_TREE | |
1728 | fi | |
1729 | ||
20073274 AS |
1730 | test_lazy_prereq PIPE ' |
1731 | # test whether the filesystem supports FIFOs | |
7b7bea23 RJ |
1732 | test_have_prereq !MINGW,!CYGWIN && |
1733 | rm -f testfifo && mkfifo testfifo | |
20073274 AS |
1734 | ' |
1735 | ||
04083f27 JH |
1736 | test_lazy_prereq SYMLINKS ' |
1737 | # test whether the filesystem supports symbolic links | |
1738 | ln -s x y && test -h y | |
1739 | ' | |
c91cfd19 | 1740 | |
3e7d4888 TB |
1741 | test_lazy_prereq SYMLINKS_WINDOWS ' |
1742 | # test whether symbolic links are enabled on Windows | |
1743 | test_have_prereq MINGW && | |
1744 | cmd //c "mklink y x" &> /dev/null && test -h y | |
1745 | ' | |
1746 | ||
b018c735 JN |
1747 | test_lazy_prereq FILEMODE ' |
1748 | test "$(git config --bool core.filemode)" = true | |
1749 | ' | |
1750 | ||
ac39aa61 MG |
1751 | test_lazy_prereq CASE_INSENSITIVE_FS ' |
1752 | echo good >CamelCase && | |
1753 | echo bad >camelcase && | |
1754 | test "$(cat CamelCase)" != good | |
1755 | ' | |
1756 | ||
6ec63305 WC |
1757 | test_lazy_prereq FUNNYNAMES ' |
1758 | test_have_prereq !MINGW && | |
1759 | touch -- \ | |
1760 | "FUNNYNAMES tab embedded" \ | |
1761 | "FUNNYNAMES \"quote embedded\"" \ | |
1762 | "FUNNYNAMES newline | |
1763 | embedded" 2>/dev/null && | |
1764 | rm -- \ | |
1765 | "FUNNYNAMES tab embedded" \ | |
1766 | "FUNNYNAMES \"quote embedded\"" \ | |
1767 | "FUNNYNAMES newline | |
1768 | embedded" 2>/dev/null | |
1769 | ' | |
1770 | ||
5b0b5dd4 MG |
1771 | test_lazy_prereq UTF8_NFD_TO_NFC ' |
1772 | # check whether FS converts nfd unicode to nfc | |
1773 | auml=$(printf "\303\244") | |
1774 | aumlcdiar=$(printf "\141\314\210") | |
1775 | >"$auml" && | |
742ae10e | 1776 | test -f "$aumlcdiar" |
5b0b5dd4 MG |
1777 | ' |
1778 | ||
09feffb6 JK |
1779 | test_lazy_prereq AUTOIDENT ' |
1780 | sane_unset GIT_AUTHOR_NAME && | |
1781 | sane_unset GIT_AUTHOR_EMAIL && | |
1782 | git var GIT_AUTHOR_IDENT | |
1783 | ' | |
1784 | ||
6219bb22 JH |
1785 | test_lazy_prereq EXPENSIVE ' |
1786 | test -n "$GIT_TEST_LONG" | |
1787 | ' | |
1788 | ||
5b1fe6eb ÆAB |
1789 | test_lazy_prereq EXPENSIVE_ON_WINDOWS ' |
1790 | test_have_prereq EXPENSIVE || test_have_prereq !MINGW,!CYGWIN | |
1791 | ' | |
1792 | ||
e1ecd9e3 JH |
1793 | test_lazy_prereq USR_BIN_TIME ' |
1794 | test -x /usr/bin/time | |
1795 | ' | |
1796 | ||
1767c517 JK |
1797 | test_lazy_prereq NOT_ROOT ' |
1798 | uid=$(id -u) && | |
1799 | test "$uid" != 0 | |
1800 | ' | |
1801 | ||
63b747ce | 1802 | test_lazy_prereq JGIT ' |
abd0f289 | 1803 | jgit --version |
63b747ce JT |
1804 | ' |
1805 | ||
719c3da2 JH |
1806 | # SANITY is about "can you correctly predict what the filesystem would |
1807 | # do by only looking at the permission bits of the files and | |
1808 | # directories?" A typical example of !SANITY is running the test | |
1809 | # suite as root, where a test may expect "chmod -r file && cat file" | |
1810 | # to fail because file is supposed to be unreadable after a successful | |
1811 | # chmod. In an environment (i.e. combination of what filesystem is | |
1812 | # being used and who is running the tests) that lacks SANITY, you may | |
1813 | # be able to delete or create a file when the containing directory | |
1814 | # doesn't have write permissions, or access a file even if the | |
1815 | # containing directory doesn't have read or execute permissions. | |
1816 | ||
f400e51c TB |
1817 | test_lazy_prereq SANITY ' |
1818 | mkdir SANETESTD.1 SANETESTD.2 && | |
1819 | ||
1820 | chmod +w SANETESTD.1 SANETESTD.2 && | |
1821 | >SANETESTD.1/x 2>SANETESTD.2/x && | |
1822 | chmod -w SANETESTD.1 && | |
719c3da2 | 1823 | chmod -r SANETESTD.1/x && |
f400e51c | 1824 | chmod -rx SANETESTD.2 || |
165293af | 1825 | BUG "cannot prepare SANETESTD" |
f400e51c | 1826 | |
719c3da2 | 1827 | ! test -r SANETESTD.1/x && |
f400e51c TB |
1828 | ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x |
1829 | status=$? | |
1830 | ||
1831 | chmod +rwx SANETESTD.1 SANETESTD.2 && | |
1832 | rm -rf SANETESTD.1 SANETESTD.2 || | |
165293af | 1833 | BUG "cannot clean SANETESTD" |
f400e51c TB |
1834 | return $status |
1835 | ' | |
f838ce58 | 1836 | |
d98b2c5f | 1837 | test FreeBSD != $uname_s || GIT_UNZIP=${GIT_UNZIP:-/usr/local/bin/unzip} |
f838ce58 JK |
1838 | GIT_UNZIP=${GIT_UNZIP:-unzip} |
1839 | test_lazy_prereq UNZIP ' | |
1840 | "$GIT_UNZIP" -v | |
1841 | test $? -ne 127 | |
1842 | ' | |
9a308de3 JK |
1843 | |
1844 | run_with_limited_cmdline () { | |
1845 | (ulimit -s 128 && "$@") | |
1846 | } | |
1847 | ||
21dac1de | 1848 | test_lazy_prereq CMDLINE_LIMIT ' |
ddcfc7c6 | 1849 | test_have_prereq !HPPA,!MINGW,!CYGWIN && |
21dac1de RJ |
1850 | run_with_limited_cmdline true |
1851 | ' | |
6b9c38e1 | 1852 | |
4db464f8 MG |
1853 | run_with_limited_stack () { |
1854 | (ulimit -s 128 && "$@") | |
1855 | } | |
1856 | ||
21dac1de | 1857 | test_lazy_prereq ULIMIT_STACK_SIZE ' |
ddcfc7c6 | 1858 | test_have_prereq !HPPA,!MINGW,!CYGWIN && |
21dac1de RJ |
1859 | run_with_limited_stack true |
1860 | ' | |
4db464f8 | 1861 | |
b30fdb4b TB |
1862 | run_with_limited_open_files () { |
1863 | (ulimit -n 32 && "$@") | |
1864 | } | |
1865 | ||
1866 | test_lazy_prereq ULIMIT_FILE_DESCRIPTORS ' | |
1867 | test_have_prereq !MINGW,!CYGWIN && | |
1868 | run_with_limited_open_files true | |
1869 | ' | |
1870 | ||
6b9c38e1 JK |
1871 | build_option () { |
1872 | git version --build-options | | |
1873 | sed -ne "s/^$1: //p" | |
1874 | } | |
1875 | ||
970fa57f CMAB |
1876 | test_lazy_prereq SIZE_T_IS_64BIT ' |
1877 | test 8 -eq "$(build_option sizeof-size_t)" | |
1878 | ' | |
1879 | ||
6b9c38e1 JK |
1880 | test_lazy_prereq LONG_IS_64BIT ' |
1881 | test 8 -le "$(build_option sizeof-long)" | |
1882 | ' | |
a07fb050 | 1883 | |
a801a7cf NTND |
1884 | test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit' |
1885 | test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit' | |
e9184b07 JK |
1886 | |
1887 | test_lazy_prereq CURL ' | |
1888 | curl --version | |
1889 | ' | |
d16ab634 | 1890 | |
926d18e5 JH |
1891 | test_lazy_prereq WITH_BREAKING_CHANGES ' |
1892 | test -n "$WITH_BREAKING_CHANGES" | |
1893 | ' | |
1894 | ||
c5bc9a7f | 1895 | test_lazy_prereq WITHOUT_BREAKING_CHANGES ' |
926d18e5 JH |
1896 | # Signal that this prereq should not be used. |
1897 | exit 125 | |
c5bc9a7f PS |
1898 | ' |
1899 | ||
d16ab634 | 1900 | # SHA1 is a test if the hash algorithm in use is SHA-1. This is both for tests |
1901 | # which will not work with other hash algorithms and tests that work but don't | |
1902 | # test anything meaningful (e.g. special values which cause short collisions). | |
1903 | test_lazy_prereq SHA1 ' | |
c49fe07c | 1904 | case "$GIT_DEFAULT_HASH" in |
1905 | sha1) true ;; | |
1906 | "") test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ;; | |
1907 | *) false ;; | |
1908 | esac | |
d16ab634 | 1909 | ' |
11aad464 | 1910 | |
bb0372c9 | 1911 | test_lazy_prereq DEFAULT_REPO_FORMAT ' |
d7497a42 | 1912 | test_have_prereq SHA1,REFFILES |
bb0372c9 PS |
1913 | ' |
1914 | ||
2fec604f | 1915 | # Ensure that no test accidentally triggers a Git command |
31345d55 DS |
1916 | # that runs the actual maintenance scheduler, affecting a user's |
1917 | # system permanently. | |
1918 | # Tests that verify the scheduler integration must set this locally | |
2fec604f | 1919 | # to avoid errors. |
31345d55 | 1920 | GIT_TEST_MAINT_SCHEDULER="none:exit 1" |
73cb8777 | 1921 | export GIT_TEST_MAINT_SCHEDULER |
dd77cf61 JH |
1922 | |
1923 | # Does this platform support `git fsmonitor--daemon` | |
1924 | # | |
1925 | test_lazy_prereq FSMONITOR_DAEMON ' | |
1926 | git version --build-options >output && | |
1927 | grep "feature: fsmonitor--daemon" output | |
1928 | ' |