rpatch 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/bin/rpatch +27 -0
- data/lib/rpatch/entry.rb +137 -0
- data/lib/rpatch/error.rb +8 -0
- data/lib/rpatch/hunk.rb +271 -0
- data/lib/rpatch/patch.rb +158 -0
- data/lib/rpatch/runner.rb +44 -0
- data/lib/rpatch/version.rb +3 -0
- data/spec/patch_entry_spec.rb +234 -0
- data/spec/patch_file_regexp_spec.rb +73 -0
- data/spec/patch_file_spec.rb +267 -0
- data/spec/patch_hunk_spec.rb +272 -0
- data/spec/spec_helper.rb +24 -0
- data/t/Makefile +80 -0
- data/t/README +3 -0
- data/t/aggregate-results.sh +46 -0
- data/t/t0000-patch-file.sh +297 -0
- data/t/t0100-patch-directory.sh +203 -0
- data/t/test-lib-functions.sh +722 -0
- data/t/test-lib.sh +623 -0
- metadata +132 -0
data/t/test-lib.sh
ADDED
@@ -0,0 +1,623 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# Copyright (c) 2005 Junio C Hamano
|
4
|
+
#
|
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
|
16
|
+
# along with this program. If not, see http://www.gnu.org/licenses/ .
|
17
|
+
|
18
|
+
# Keep the original TERM for say_color
|
19
|
+
ORIGINAL_TERM=$TERM
|
20
|
+
|
21
|
+
# Test the binaries we have just built. The tests are kept in
|
22
|
+
# t/ subdirectory and are run in 'trash directory' subdirectory.
|
23
|
+
if test -z "$TEST_DIRECTORY"
|
24
|
+
then
|
25
|
+
# We allow tests to override this, in case they want to run tests
|
26
|
+
# outside of t/, e.g. for running tests on the test library
|
27
|
+
# itself.
|
28
|
+
TEST_DIRECTORY=$(pwd)
|
29
|
+
fi
|
30
|
+
if test -z "$TEST_OUTPUT_DIRECTORY"
|
31
|
+
then
|
32
|
+
# Similarly, override this to store the test-results subdir
|
33
|
+
# elsewhere
|
34
|
+
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
|
35
|
+
fi
|
36
|
+
|
37
|
+
################################################################
|
38
|
+
# It appears that people try to run tests without building...
|
39
|
+
"rpatch" -h >/dev/null
|
40
|
+
if test $? != 0
|
41
|
+
then
|
42
|
+
echo >&2 'error: can not find rpatch for test.'
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
|
46
|
+
SHELL_PATH="/bin/sh"
|
47
|
+
RUBY_PATH="$(which ruby)"
|
48
|
+
DIFF='diff'
|
49
|
+
export RUBY_PATH SHELL_PATH
|
50
|
+
|
51
|
+
# if --tee was passed, write the output not only to the terminal, but
|
52
|
+
# additionally to the file test-results/$BASENAME.out, too.
|
53
|
+
case "$GIT_TEST_TEE_STARTED, $* " in
|
54
|
+
done,*)
|
55
|
+
# do not redirect again
|
56
|
+
;;
|
57
|
+
*' --tee '*|*' --va'*)
|
58
|
+
mkdir -p "$TEST_OUTPUT_DIRECTORY/test-results"
|
59
|
+
BASE="$TEST_OUTPUT_DIRECTORY/test-results/$(basename "$0" .sh)"
|
60
|
+
(GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1;
|
61
|
+
echo $? > $BASE.exit) | tee $BASE.out
|
62
|
+
test "$(cat $BASE.exit)" = 0
|
63
|
+
exit
|
64
|
+
;;
|
65
|
+
esac
|
66
|
+
|
67
|
+
# For repeatability, reset the environment to known value.
|
68
|
+
#LANG=C
|
69
|
+
#LC_ALL=C
|
70
|
+
PAGER=cat
|
71
|
+
TZ=UTC
|
72
|
+
TERM=dumb
|
73
|
+
export LANG LC_ALL PAGER TERM TZ
|
74
|
+
|
75
|
+
# Add libc MALLOC and MALLOC_PERTURB test
|
76
|
+
# only if we are not executing the test with valgrind
|
77
|
+
if test -n "$TEST_NO_MALLOC_CHECK"
|
78
|
+
then
|
79
|
+
setup_malloc_check () {
|
80
|
+
: nothing
|
81
|
+
}
|
82
|
+
teardown_malloc_check () {
|
83
|
+
: nothing
|
84
|
+
}
|
85
|
+
else
|
86
|
+
setup_malloc_check () {
|
87
|
+
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
|
88
|
+
export MALLOC_CHECK_ MALLOC_PERTURB_
|
89
|
+
}
|
90
|
+
teardown_malloc_check () {
|
91
|
+
unset MALLOC_CHECK_ MALLOC_PERTURB_
|
92
|
+
}
|
93
|
+
fi
|
94
|
+
|
95
|
+
# Protect ourselves from common misconfiguration to export
|
96
|
+
# CDPATH into the environment
|
97
|
+
unset CDPATH
|
98
|
+
|
99
|
+
unset GREP_OPTIONS
|
100
|
+
unset UNZIP
|
101
|
+
|
102
|
+
# Convenience
|
103
|
+
#
|
104
|
+
# A regexp to match 5 and 40 hexdigits
|
105
|
+
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
|
106
|
+
_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
|
107
|
+
|
108
|
+
# Zero SHA-1
|
109
|
+
_z40=0000000000000000000000000000000000000000
|
110
|
+
|
111
|
+
# Line feed
|
112
|
+
LF='
|
113
|
+
'
|
114
|
+
|
115
|
+
export _x05 _x40 _z40 LF
|
116
|
+
|
117
|
+
# Each test should start with something like this, after copyright notices:
|
118
|
+
#
|
119
|
+
# test_description='Description of this test...
|
120
|
+
# This test checks if command xyzzy does the right thing...
|
121
|
+
# '
|
122
|
+
# . ./test-lib.sh
|
123
|
+
[ "x$ORIGINAL_TERM" != "xdumb" ] && (
|
124
|
+
TERM=$ORIGINAL_TERM &&
|
125
|
+
export TERM &&
|
126
|
+
[ -t 1 ] &&
|
127
|
+
tput bold >/dev/null 2>&1 &&
|
128
|
+
tput setaf 1 >/dev/null 2>&1 &&
|
129
|
+
tput sgr0 >/dev/null 2>&1
|
130
|
+
) &&
|
131
|
+
color=t
|
132
|
+
|
133
|
+
while test "$#" -ne 0
|
134
|
+
do
|
135
|
+
case "$1" in
|
136
|
+
-d|--d|--de|--deb|--debu|--debug)
|
137
|
+
debug=t; shift ;;
|
138
|
+
-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
|
139
|
+
immediate=t; shift ;;
|
140
|
+
-l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)
|
141
|
+
GIT_TEST_LONG=t; export GIT_TEST_LONG; shift ;;
|
142
|
+
-h|--h|--he|--hel|--help)
|
143
|
+
help=t; shift ;;
|
144
|
+
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
|
145
|
+
verbose=t; shift ;;
|
146
|
+
--verbose-only=*)
|
147
|
+
verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
|
148
|
+
shift ;;
|
149
|
+
-q|--q|--qu|--qui|--quie|--quiet)
|
150
|
+
# Ignore --quiet under a TAP::Harness. Saying how many tests
|
151
|
+
# passed without the ok/not ok details is always an error.
|
152
|
+
test -z "$HARNESS_ACTIVE" && quiet=t; shift ;;
|
153
|
+
--no-color)
|
154
|
+
color=; shift ;;
|
155
|
+
--tee)
|
156
|
+
shift ;; # was handled already
|
157
|
+
--root=*)
|
158
|
+
root=$(expr "z$1" : 'z[^=]*=\(.*\)')
|
159
|
+
shift ;;
|
160
|
+
--statusprefix=*)
|
161
|
+
statusprefix=$(expr "z$1" : 'z[^=]*=\(.*\)')
|
162
|
+
shift ;;
|
163
|
+
*)
|
164
|
+
echo "error: unknown test option '$1'" >&2; exit 1 ;;
|
165
|
+
esac
|
166
|
+
done
|
167
|
+
|
168
|
+
if test -n "$color"
|
169
|
+
then
|
170
|
+
say_color () {
|
171
|
+
(
|
172
|
+
TERM=$ORIGINAL_TERM
|
173
|
+
export TERM
|
174
|
+
case "$1" in
|
175
|
+
error)
|
176
|
+
tput bold; tput setaf 1;; # bold red
|
177
|
+
skip)
|
178
|
+
tput setaf 4;; # blue
|
179
|
+
warn)
|
180
|
+
tput setaf 3;; # brown/yellow
|
181
|
+
pass)
|
182
|
+
tput setaf 2;; # green
|
183
|
+
info)
|
184
|
+
tput setaf 6;; # cyan
|
185
|
+
*)
|
186
|
+
test -n "$quiet" && return;;
|
187
|
+
esac
|
188
|
+
shift
|
189
|
+
printf "%s" "$*"
|
190
|
+
tput sgr0
|
191
|
+
echo
|
192
|
+
)
|
193
|
+
}
|
194
|
+
else
|
195
|
+
say_color() {
|
196
|
+
test -z "$1" && test -n "$quiet" && return
|
197
|
+
shift
|
198
|
+
printf "%s\n" "$*"
|
199
|
+
}
|
200
|
+
fi
|
201
|
+
|
202
|
+
error () {
|
203
|
+
say_color error "error: $*"
|
204
|
+
GIT_EXIT_OK=t
|
205
|
+
exit 1
|
206
|
+
}
|
207
|
+
|
208
|
+
say () {
|
209
|
+
say_color info "$*"
|
210
|
+
}
|
211
|
+
|
212
|
+
## TODO: ##test "${test_description}" != "" ||
|
213
|
+
## TODO: ##error "Test script did not set test_description."
|
214
|
+
|
215
|
+
if test "$help" = "t"
|
216
|
+
then
|
217
|
+
echo "$test_description"
|
218
|
+
exit 0
|
219
|
+
fi
|
220
|
+
|
221
|
+
exec 5>&1
|
222
|
+
exec 6<&0
|
223
|
+
if test "$verbose" = "t"
|
224
|
+
then
|
225
|
+
exec 4>&2 3>&1
|
226
|
+
else
|
227
|
+
exec 4>/dev/null 3>/dev/null
|
228
|
+
fi
|
229
|
+
|
230
|
+
test_failure=0
|
231
|
+
test_count=0
|
232
|
+
test_fixed=0
|
233
|
+
test_broken=0
|
234
|
+
test_success=0
|
235
|
+
|
236
|
+
test_external_has_tap=0
|
237
|
+
|
238
|
+
die () {
|
239
|
+
code=$?
|
240
|
+
if test -n "$GIT_EXIT_OK"
|
241
|
+
then
|
242
|
+
exit $code
|
243
|
+
else
|
244
|
+
echo >&5 "FATAL: Unexpected exit with code $code"
|
245
|
+
exit 1
|
246
|
+
fi
|
247
|
+
}
|
248
|
+
|
249
|
+
GIT_EXIT_OK=
|
250
|
+
trap 'die' EXIT
|
251
|
+
|
252
|
+
# The user-facing functions are loaded from a separate file so that
|
253
|
+
# test_perf subshells can have them too
|
254
|
+
. "$TEST_DIRECTORY/test-lib-functions.sh"
|
255
|
+
|
256
|
+
# You are not expected to call test_ok_ and test_failure_ directly, use
|
257
|
+
# the text_expect_* functions instead.
|
258
|
+
|
259
|
+
test_ok_ () {
|
260
|
+
test_success=$(($test_success + 1))
|
261
|
+
say_color "" "${statusprefix}ok $test_count - $@"
|
262
|
+
}
|
263
|
+
|
264
|
+
test_failure_ () {
|
265
|
+
test_failure=$(($test_failure + 1))
|
266
|
+
say_color error "${statusprefix}not ok $test_count - $1"
|
267
|
+
shift
|
268
|
+
echo "$@" | sed -e 's/^/# /'
|
269
|
+
test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
|
270
|
+
}
|
271
|
+
|
272
|
+
test_known_broken_ok_ () {
|
273
|
+
test_fixed=$(($test_fixed+1))
|
274
|
+
say_color error "${statusprefix}ok $test_count - $@ # TODO known breakage vanished"
|
275
|
+
}
|
276
|
+
|
277
|
+
test_known_broken_failure_ () {
|
278
|
+
test_broken=$(($test_broken+1))
|
279
|
+
say_color warn "${statusprefix}not ok $test_count - $@ # TODO known breakage"
|
280
|
+
}
|
281
|
+
|
282
|
+
test_debug () {
|
283
|
+
test "$debug" = "" || eval "$1"
|
284
|
+
}
|
285
|
+
|
286
|
+
match_pattern_list () {
|
287
|
+
arg="$1"
|
288
|
+
shift
|
289
|
+
test -z "$*" && return 1
|
290
|
+
for pattern_
|
291
|
+
do
|
292
|
+
case "$arg" in
|
293
|
+
$pattern_)
|
294
|
+
return 0
|
295
|
+
esac
|
296
|
+
done
|
297
|
+
return 1
|
298
|
+
}
|
299
|
+
|
300
|
+
maybe_teardown_verbose () {
|
301
|
+
test -z "$verbose_only" && return
|
302
|
+
exec 4>/dev/null 3>/dev/null
|
303
|
+
verbose=
|
304
|
+
}
|
305
|
+
|
306
|
+
last_verbose=t
|
307
|
+
maybe_setup_verbose () {
|
308
|
+
test -z "$verbose_only" && return
|
309
|
+
if match_pattern_list $test_count $verbose_only
|
310
|
+
then
|
311
|
+
exec 4>&2 3>&1
|
312
|
+
# Emit a delimiting blank line when going from
|
313
|
+
# non-verbose to verbose. Within verbose mode the
|
314
|
+
# delimiter is printed by test_expect_*. The choice
|
315
|
+
# of the initial $last_verbose is such that before
|
316
|
+
# test 1, we do not print it.
|
317
|
+
test -z "$last_verbose" && echo >&3 ""
|
318
|
+
verbose=t
|
319
|
+
else
|
320
|
+
exec 4>/dev/null 3>/dev/null
|
321
|
+
verbose=
|
322
|
+
fi
|
323
|
+
last_verbose=$verbose
|
324
|
+
}
|
325
|
+
|
326
|
+
test_eval_ () {
|
327
|
+
# This is a separate function because some tests use
|
328
|
+
# "return" to end a test_expect_success block early.
|
329
|
+
eval </dev/null >&3 2>&4 "$*"
|
330
|
+
}
|
331
|
+
|
332
|
+
test_run_ () {
|
333
|
+
test_cleanup=:
|
334
|
+
expecting_failure=$2
|
335
|
+
setup_malloc_check
|
336
|
+
test_eval_ "$1"
|
337
|
+
eval_ret=$?
|
338
|
+
teardown_malloc_check
|
339
|
+
|
340
|
+
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
|
341
|
+
then
|
342
|
+
setup_malloc_check
|
343
|
+
test_eval_ "$test_cleanup"
|
344
|
+
teardown_malloc_check
|
345
|
+
fi
|
346
|
+
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
|
347
|
+
then
|
348
|
+
echo ""
|
349
|
+
fi
|
350
|
+
return "$eval_ret"
|
351
|
+
}
|
352
|
+
|
353
|
+
test_start_ () {
|
354
|
+
test_count=$(($test_count+1))
|
355
|
+
maybe_setup_verbose
|
356
|
+
}
|
357
|
+
|
358
|
+
test_finish_ () {
|
359
|
+
echo >&3 ""
|
360
|
+
maybe_teardown_verbose
|
361
|
+
}
|
362
|
+
|
363
|
+
test_skip () {
|
364
|
+
to_skip=
|
365
|
+
if match_pattern_list $this_test.$test_count $GIT_SKIP_TESTS
|
366
|
+
then
|
367
|
+
to_skip=t
|
368
|
+
fi
|
369
|
+
if test -z "$to_skip" && test -n "$test_prereq" &&
|
370
|
+
! test_have_prereq "$test_prereq"
|
371
|
+
then
|
372
|
+
to_skip=t
|
373
|
+
fi
|
374
|
+
case "$to_skip" in
|
375
|
+
t)
|
376
|
+
of_prereq=
|
377
|
+
if test "$missing_prereq" != "$test_prereq"
|
378
|
+
then
|
379
|
+
of_prereq=" of $test_prereq"
|
380
|
+
fi
|
381
|
+
|
382
|
+
say_color skip >&3 "${statusprefix}skipping test: $@"
|
383
|
+
say_color skip "${statusprefix}ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
|
384
|
+
: true
|
385
|
+
;;
|
386
|
+
*)
|
387
|
+
false
|
388
|
+
;;
|
389
|
+
esac
|
390
|
+
}
|
391
|
+
|
392
|
+
# stub; perf-lib overrides it
|
393
|
+
test_at_end_hook_ () {
|
394
|
+
:
|
395
|
+
}
|
396
|
+
|
397
|
+
test_done () {
|
398
|
+
GIT_EXIT_OK=t
|
399
|
+
|
400
|
+
# Note: t0000 relies on $HARNESS_ACTIVE disabling the .counts
|
401
|
+
# output file
|
402
|
+
if test -z "$HARNESS_ACTIVE"
|
403
|
+
then
|
404
|
+
test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
|
405
|
+
mkdir -p "$test_results_dir"
|
406
|
+
base=${0##*/}
|
407
|
+
test_results_path="$test_results_dir/${base%.sh}-$$.counts"
|
408
|
+
|
409
|
+
cat >>"$test_results_path" <<-EOF
|
410
|
+
total $test_count
|
411
|
+
success $test_success
|
412
|
+
fixed $test_fixed
|
413
|
+
broken $test_broken
|
414
|
+
failed $test_failure
|
415
|
+
|
416
|
+
EOF
|
417
|
+
fi
|
418
|
+
|
419
|
+
if test "$test_fixed" != 0
|
420
|
+
then
|
421
|
+
say_color error "${statusprefix}# $test_fixed known breakage(s) vanished; please update test(s)"
|
422
|
+
fi
|
423
|
+
if test "$test_broken" != 0
|
424
|
+
then
|
425
|
+
say_color warn "${statusprefix}# still have $test_broken known breakage(s)"
|
426
|
+
fi
|
427
|
+
if test "$test_broken" != 0 || test "$test_fixed" != 0
|
428
|
+
then
|
429
|
+
test_remaining=$(( $test_count - $test_broken - $test_fixed ))
|
430
|
+
msg="remaining $test_remaining test(s)"
|
431
|
+
else
|
432
|
+
test_remaining=$test_count
|
433
|
+
msg="$test_count test(s)"
|
434
|
+
fi
|
435
|
+
case "$test_failure" in
|
436
|
+
0)
|
437
|
+
# Maybe print SKIP message
|
438
|
+
if test -n "$skip_all" && test $test_count -gt 0
|
439
|
+
then
|
440
|
+
error "Can't use skip_all after running some tests"
|
441
|
+
fi
|
442
|
+
[ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
|
443
|
+
|
444
|
+
if test $test_external_has_tap -eq 0
|
445
|
+
then
|
446
|
+
if test $test_remaining -gt 0
|
447
|
+
then
|
448
|
+
say_color pass "${statusprefix}# passed all $msg"
|
449
|
+
fi
|
450
|
+
say "${statusprefix}1..$test_count$skip_all"
|
451
|
+
fi
|
452
|
+
|
453
|
+
test -d "$remove_trash" &&
|
454
|
+
cd "$(dirname "$remove_trash")" &&
|
455
|
+
rm -rf "$(basename "$remove_trash")"
|
456
|
+
|
457
|
+
test_at_end_hook_
|
458
|
+
|
459
|
+
exit 0 ;;
|
460
|
+
|
461
|
+
*)
|
462
|
+
if test $test_external_has_tap -eq 0
|
463
|
+
then
|
464
|
+
say_color error "${statusprefix}# failed $test_failure among $msg"
|
465
|
+
say "${statusprefix}1..$test_count"
|
466
|
+
fi
|
467
|
+
|
468
|
+
exit 1 ;;
|
469
|
+
|
470
|
+
esac
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
# Set up a directory that we can put in PATH which redirects all gistore
|
475
|
+
# calls.
|
476
|
+
if test -n "$GIT_TEST_INSTALLED"
|
477
|
+
then
|
478
|
+
PATH=$GIT_TEST_INSTALLED:$PATH
|
479
|
+
else
|
480
|
+
PATH="$PATH"
|
481
|
+
fi
|
482
|
+
export PATH
|
483
|
+
|
484
|
+
# GIT_TEST_CMP is used in function test_cmp
|
485
|
+
if test -z "$GIT_TEST_CMP"
|
486
|
+
then
|
487
|
+
if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"
|
488
|
+
then
|
489
|
+
GIT_TEST_CMP="$DIFF -c"
|
490
|
+
else
|
491
|
+
GIT_TEST_CMP="$DIFF -u"
|
492
|
+
fi
|
493
|
+
fi
|
494
|
+
|
495
|
+
# Test repository
|
496
|
+
TRASH_DIRECTORY="trash directory.$(basename "$0" .sh)"
|
497
|
+
test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
|
498
|
+
case "$TRASH_DIRECTORY" in
|
499
|
+
/*) ;; # absolute path is good
|
500
|
+
*) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
|
501
|
+
esac
|
502
|
+
test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
|
503
|
+
rm -fr "$TRASH_DIRECTORY" || {
|
504
|
+
GIT_EXIT_OK=t
|
505
|
+
echo >&5 "FATAL: Cannot prepare test area"
|
506
|
+
exit 1
|
507
|
+
}
|
508
|
+
|
509
|
+
HOME="$TRASH_DIRECTORY"
|
510
|
+
export HOME
|
511
|
+
mkdir -p "$TRASH_DIRECTORY"
|
512
|
+
|
513
|
+
# Use -P to resolve symlinks in our working directory so that the cwd
|
514
|
+
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
515
|
+
cd -P "$TRASH_DIRECTORY" || exit 1
|
516
|
+
|
517
|
+
this_test=${0##*/}
|
518
|
+
this_test=${this_test%%-*}
|
519
|
+
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
|
520
|
+
then
|
521
|
+
say_color info >&3 "skipping test $this_test altogether"
|
522
|
+
skip_all="skip all tests in $this_test"
|
523
|
+
test_done
|
524
|
+
fi
|
525
|
+
|
526
|
+
# Provide an implementation of the 'yes' utility
|
527
|
+
yes () {
|
528
|
+
if test $# = 0
|
529
|
+
then
|
530
|
+
y=y
|
531
|
+
else
|
532
|
+
y="$*"
|
533
|
+
fi
|
534
|
+
|
535
|
+
while echo "$y"
|
536
|
+
do
|
537
|
+
:
|
538
|
+
done
|
539
|
+
}
|
540
|
+
|
541
|
+
( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
|
542
|
+
test -z "$NO_PERL" && test_set_prereq PERL
|
543
|
+
test -z "$NO_PYTHON" && test_set_prereq PYTHON
|
544
|
+
test -n "$USE_LIBPCRE" && test_set_prereq LIBPCRE
|
545
|
+
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
|
546
|
+
|
547
|
+
# Use this instead of test_cmp to compare files that contain expected and
|
548
|
+
# actual output from git commands that can be translated. When running
|
549
|
+
# under GETTEXT_POISON this pretends that the command produced expected
|
550
|
+
# results.
|
551
|
+
test_i18ncmp () {
|
552
|
+
test -n "$GETTEXT_POISON" || test_cmp "$@"
|
553
|
+
}
|
554
|
+
|
555
|
+
# Use this instead of "grep expected-string actual" to see if the
|
556
|
+
# output from a git command that can be translated either contains an
|
557
|
+
# expected string, or does not contain an unwanted one. When running
|
558
|
+
# under GETTEXT_POISON this pretends that the command produced expected
|
559
|
+
# results.
|
560
|
+
test_i18ngrep () {
|
561
|
+
if test -n "$GETTEXT_POISON"
|
562
|
+
then
|
563
|
+
: # pretend success
|
564
|
+
elif test "x!" = "x$1"
|
565
|
+
then
|
566
|
+
shift
|
567
|
+
! grep "$@"
|
568
|
+
else
|
569
|
+
grep "$@"
|
570
|
+
fi
|
571
|
+
}
|
572
|
+
|
573
|
+
test_lazy_prereq PIPE '
|
574
|
+
# test whether the filesystem supports FIFOs
|
575
|
+
case $(uname -s) in
|
576
|
+
CYGWIN*)
|
577
|
+
false
|
578
|
+
;;
|
579
|
+
*)
|
580
|
+
rm -f testfifo && mkfifo testfifo
|
581
|
+
;;
|
582
|
+
esac
|
583
|
+
'
|
584
|
+
|
585
|
+
test_lazy_prereq SYMLINKS '
|
586
|
+
# test whether the filesystem supports symbolic links
|
587
|
+
ln -s x y && test -h y
|
588
|
+
'
|
589
|
+
|
590
|
+
test_lazy_prereq CASE_INSENSITIVE_FS '
|
591
|
+
echo good >CamelCase &&
|
592
|
+
echo bad >camelcase &&
|
593
|
+
test "$(cat CamelCase)" != good
|
594
|
+
'
|
595
|
+
|
596
|
+
test_lazy_prereq UTF8_NFD_TO_NFC '
|
597
|
+
# check whether FS converts nfd unicode to nfc
|
598
|
+
auml=$(printf "\303\244")
|
599
|
+
aumlcdiar=$(printf "\141\314\210")
|
600
|
+
>"$auml" &&
|
601
|
+
case "$(echo *)" in
|
602
|
+
"$aumlcdiar")
|
603
|
+
true ;;
|
604
|
+
*)
|
605
|
+
false ;;
|
606
|
+
esac
|
607
|
+
'
|
608
|
+
|
609
|
+
test_lazy_prereq AUTOIDENT '
|
610
|
+
sane_unset GIT_AUTHOR_NAME &&
|
611
|
+
sane_unset GIT_AUTHOR_EMAIL &&
|
612
|
+
git var GIT_AUTHOR_IDENT
|
613
|
+
'
|
614
|
+
|
615
|
+
# When the tests are run as root, permission tests will report that
|
616
|
+
# things are writable when they shouldn't be.
|
617
|
+
test -w / || test_set_prereq SANITY
|
618
|
+
|
619
|
+
GIT_UNZIP=${GIT_UNZIP:-unzip}
|
620
|
+
test_lazy_prereq UNZIP '
|
621
|
+
"$GIT_UNZIP" -v
|
622
|
+
test $? -ne 127
|
623
|
+
'
|