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