Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / c2 / ac31fc3eddcb2d79a54da989a0d8173356b70b
1 Return-Path: <sojkam1@fel.cvut.cz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id DA99B431FC1\r
6         for <notmuch@notmuchmail.org>; Wed,  9 Jun 2010 23:49:13 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 1tZOu9XUoNtJ for <notmuch@notmuchmail.org>;\r
16         Wed,  9 Jun 2010 23:48:51 -0700 (PDT)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id B5C964196F2\r
19         for <notmuch@notmuchmail.org>; Wed,  9 Jun 2010 23:48:35 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 1341A19F33E1;\r
22         Thu, 10 Jun 2010 08:48:35 +0200 (CEST)\r
23 X-Virus-Scanned: IMAP AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id yG24X6-oD+hX; Thu, 10 Jun 2010 08:48:31 +0200 (CEST)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id E111B19F35C9;\r
30         Thu, 10 Jun 2010 08:48:31 +0200 (CEST)\r
31 Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30])\r
32         (Authenticated sender: sojkam1)\r
33         by imap.feld.cvut.cz (Postfix) with ESMTPSA id C374B15C062;\r
34         Thu, 10 Jun 2010 08:48:31 +0200 (CEST)\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
36         (envelope-from <sojkam1@fel.cvut.cz>)\r
37         id 1OMbZ1-0000JU-6J; Thu, 10 Jun 2010 08:48:31 +0200\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v3 1/5] Copy test framework from Git\r
41 Date: Thu, 10 Jun 2010 08:48:00 +0200\r
42 Message-Id: <1276152484-1164-2-git-send-email-sojkam1@fel.cvut.cz>\r
43 X-Mailer: git-send-email 1.7.1.3.g75e44\r
44 In-Reply-To: <1276152484-1164-1-git-send-email-sojkam1@fel.cvut.cz>\r
45 References: <1276152484-1164-1-git-send-email-sojkam1@fel.cvut.cz>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Thu, 10 Jun 2010 06:49:14 -0000\r
59 \r
60 Git uses a simple and yet powerful test framework, written in shell.\r
61 The framework is easy to use for both users and developers so I think\r
62 it would help if it is used in notmuch as well.\r
63 \r
64 This is a copy of Git's test framework from commit\r
65 b6b0afdc30e066788592ca07c9a6c6936c68cc11 in git repository.\r
66 \r
67 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
68 ---\r
69  test/Makefile             |   48 +++\r
70  test/README               |  297 ++++++++++++++++\r
71  test/aggregate-results.sh |   34 ++\r
72  test/t0000-basic.sh       |  389 +++++++++++++++++++++\r
73  test/test-lib.sh          |  832 +++++++++++++++++++++++++++++++++++++++++++++\r
74  5 files changed, 1600 insertions(+), 0 deletions(-)\r
75  create mode 100644 test/Makefile\r
76  create mode 100644 test/README\r
77  create mode 100755 test/aggregate-results.sh\r
78  create mode 100755 test/t0000-basic.sh\r
79  create mode 100644 test/test-lib.sh\r
80 \r
81 diff --git a/test/Makefile b/test/Makefile\r
82 new file mode 100644\r
83 index 0000000..25c559b\r
84 --- /dev/null\r
85 +++ b/test/Makefile\r
86 @@ -0,0 +1,48 @@\r
87 +# Run tests\r
88 +#\r
89 +# Copyright (c) 2005 Junio C Hamano\r
90 +#\r
91 +\r
92 +-include ../config.mak\r
93 +\r
94 +#GIT_TEST_OPTS=--verbose --debug\r
95 +SHELL_PATH ?= $(SHELL)\r
96 +TAR ?= $(TAR)\r
97 +RM ?= rm -f\r
98 +\r
99 +# Shell quote;\r
100 +SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))\r
101 +\r
102 +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\r
103 +TSVN = $(wildcard t91[0-9][0-9]-*.sh)\r
104 +\r
105 +all: pre-clean\r
106 +       $(MAKE) aggregate-results-and-cleanup\r
107 +\r
108 +$(T):\r
109 +       @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\r
110 +\r
111 +pre-clean:\r
112 +       $(RM) -r test-results\r
113 +\r
114 +clean:\r
115 +       $(RM) -r 'trash directory'.* test-results\r
116 +       $(RM) t????/cvsroot/CVSROOT/?*\r
117 +       $(RM) -r valgrind/bin\r
118 +\r
119 +aggregate-results-and-cleanup: $(T)\r
120 +       $(MAKE) aggregate-results\r
121 +       $(MAKE) clean\r
122 +\r
123 +aggregate-results:\r
124 +       '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-*\r
125 +\r
126 +# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL\r
127 +full-svn-test:\r
128 +       $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C\r
129 +       $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8\r
130 +\r
131 +valgrind:\r
132 +       GIT_TEST_OPTS=--valgrind $(MAKE)\r
133 +\r
134 +.PHONY: pre-clean $(T) aggregate-results clean valgrind\r
135 diff --git a/test/README b/test/README\r
136 new file mode 100644\r
137 index 0000000..dcd3ebb\r
138 --- /dev/null\r
139 +++ b/test/README\r
140 @@ -0,0 +1,297 @@\r
141 +Core GIT Tests\r
142 +==============\r
143 +\r
144 +This directory holds many test scripts for core GIT tools.  The\r
145 +first part of this short document describes how to run the tests\r
146 +and read their output.\r
147 +\r
148 +When fixing the tools or adding enhancements, you are strongly\r
149 +encouraged to add tests in this directory to cover what you are\r
150 +trying to fix or enhance.  The later part of this short document\r
151 +describes how your test scripts should be organized.\r
152 +\r
153 +\r
154 +Running Tests\r
155 +-------------\r
156 +\r
157 +The easiest way to run tests is to say "make".  This runs all\r
158 +the tests.\r
159 +\r
160 +    *** t0000-basic.sh ***\r
161 +    *   ok 1: .git/objects should be empty after git-init in an empty repo.\r
162 +    *   ok 2: .git/objects should have 256 subdirectories.\r
163 +    *   ok 3: git-update-index without --add should fail adding.\r
164 +    ...\r
165 +    *   ok 23: no diff after checkout and git-update-index --refresh.\r
166 +    * passed all 23 test(s)\r
167 +    *** t0100-environment-names.sh ***\r
168 +    *   ok 1: using old names should issue warnings.\r
169 +    *   ok 2: using old names but having new names should not issue warnings.\r
170 +    ...\r
171 +\r
172 +Or you can run each test individually from command line, like\r
173 +this:\r
174 +\r
175 +    $ sh ./t3001-ls-files-killed.sh\r
176 +    *   ok 1: git-update-index --add to add various paths.\r
177 +    *   ok 2: git-ls-files -k to show killed files.\r
178 +    *   ok 3: validate git-ls-files -k output.\r
179 +    * passed all 3 test(s)\r
180 +\r
181 +You can pass --verbose (or -v), --debug (or -d), and --immediate\r
182 +(or -i) command line argument to the test, or by setting GIT_TEST_OPTS\r
183 +appropriately before running "make".\r
184 +\r
185 +--verbose::\r
186 +       This makes the test more verbose.  Specifically, the\r
187 +       command being run and their output if any are also\r
188 +       output.\r
189 +\r
190 +--debug::\r
191 +       This may help the person who is developing a new test.\r
192 +       It causes the command defined with test_debug to run.\r
193 +\r
194 +--immediate::\r
195 +       This causes the test to immediately exit upon the first\r
196 +       failed test.\r
197 +\r
198 +--long-tests::\r
199 +       This causes additional long-running tests to be run (where\r
200 +       available), for more exhaustive testing.\r
201 +\r
202 +--valgrind::\r
203 +       Execute all Git binaries with valgrind and exit with status\r
204 +       126 on errors (just like regular tests, this will only stop\r
205 +       the test script when running under -i).  Valgrind errors\r
206 +       go to stderr, so you might want to pass the -v option, too.\r
207 +\r
208 +       Since it makes no sense to run the tests with --valgrind and\r
209 +       not see any output, this option implies --verbose.  For\r
210 +       convenience, it also implies --tee.\r
211 +\r
212 +--tee::\r
213 +       In addition to printing the test output to the terminal,\r
214 +       write it to files named 't/test-results/$TEST_NAME.out'.\r
215 +       As the names depend on the tests' file names, it is safe to\r
216 +       run the tests with this option in parallel.\r
217 +\r
218 +--with-dashes::\r
219 +       By default tests are run without dashed forms of\r
220 +       commands (like git-commit) in the PATH (it only uses\r
221 +       wrappers from ../bin-wrappers).  Use this option to include\r
222 +       the build directory (..) in the PATH, which contains all\r
223 +       the dashed forms of commands.  This option is currently\r
224 +       implied by other options like --valgrind and\r
225 +       GIT_TEST_INSTALLED.\r
226 +\r
227 +You can also set the GIT_TEST_INSTALLED environment variable to\r
228 +the bindir of an existing git installation to test that installation.\r
229 +You still need to have built this git sandbox, from which various\r
230 +test-* support programs, templates, and perl libraries are used.\r
231 +If your installed git is incomplete, it will silently test parts of\r
232 +your built version instead.\r
233 +\r
234 +When using GIT_TEST_INSTALLED, you can also set GIT_TEST_EXEC_PATH to\r
235 +override the location of the dashed-form subcommands (what\r
236 +GIT_EXEC_PATH would be used for during normal operation).\r
237 +GIT_TEST_EXEC_PATH defaults to `$GIT_TEST_INSTALLED/git --exec-path`.\r
238 +\r
239 +\r
240 +Skipping Tests\r
241 +--------------\r
242 +\r
243 +In some environments, certain tests have no way of succeeding\r
244 +due to platform limitation, such as lack of 'unzip' program, or\r
245 +filesystem that do not allow arbitrary sequence of non-NUL bytes\r
246 +as pathnames.\r
247 +\r
248 +You should be able to say something like\r
249 +\r
250 +    $ GIT_SKIP_TESTS=t9200.8 sh ./t9200-git-cvsexport-commit.sh\r
251 +\r
252 +and even:\r
253 +\r
254 +    $ GIT_SKIP_TESTS='t[0-4]??? t91?? t9200.8' make\r
255 +\r
256 +to omit such tests.  The value of the environment variable is a\r
257 +SP separated list of patterns that tells which tests to skip,\r
258 +and either can match the "t[0-9]{4}" part to skip the whole\r
259 +test, or t[0-9]{4} followed by ".$number" to say which\r
260 +particular test to skip.\r
261 +\r
262 +Note that some tests in the existing test suite rely on previous\r
263 +test item, so you cannot arbitrarily disable one and expect the\r
264 +remainder of test to check what the test originally was intended\r
265 +to check.\r
266 +\r
267 +\r
268 +Naming Tests\r
269 +------------\r
270 +\r
271 +The test files are named as:\r
272 +\r
273 +       tNNNN-commandname-details.sh\r
274 +\r
275 +where N is a decimal digit.\r
276 +\r
277 +First digit tells the family:\r
278 +\r
279 +       0 - the absolute basics and global stuff\r
280 +       1 - the basic commands concerning database\r
281 +       2 - the basic commands concerning the working tree\r
282 +       3 - the other basic commands (e.g. ls-files)\r
283 +       4 - the diff commands\r
284 +       5 - the pull and exporting commands\r
285 +       6 - the revision tree commands (even e.g. merge-base)\r
286 +       7 - the porcelainish commands concerning the working tree\r
287 +       8 - the porcelainish commands concerning forensics\r
288 +       9 - the git tools\r
289 +\r
290 +Second digit tells the particular command we are testing.\r
291 +\r
292 +Third digit (optionally) tells the particular switch or group of switches\r
293 +we are testing.\r
294 +\r
295 +If you create files under t/ directory (i.e. here) that is not\r
296 +the top-level test script, never name the file to match the above\r
297 +pattern.  The Makefile here considers all such files as the\r
298 +top-level test script and tries to run all of them.  A care is\r
299 +especially needed if you are creating a common test library\r
300 +file, similar to test-lib.sh, because such a library file may\r
301 +not be suitable for standalone execution.\r
302 +\r
303 +\r
304 +Writing Tests\r
305 +-------------\r
306 +\r
307 +The test script is written as a shell script.  It should start\r
308 +with the standard "#!/bin/sh" with copyright notices, and an\r
309 +assignment to variable 'test_description', like this:\r
310 +\r
311 +       #!/bin/sh\r
312 +       #\r
313 +       # Copyright (c) 2005 Junio C Hamano\r
314 +       #\r
315 +\r
316 +       test_description='xxx test (option --frotz)\r
317 +\r
318 +       This test registers the following structure in the cache\r
319 +       and tries to run git-ls-files with option --frotz.'\r
320 +\r
321 +\r
322 +Source 'test-lib.sh'\r
323 +--------------------\r
324 +\r
325 +After assigning test_description, the test script should source\r
326 +test-lib.sh like this:\r
327 +\r
328 +       . ./test-lib.sh\r
329 +\r
330 +This test harness library does the following things:\r
331 +\r
332 + - If the script is invoked with command line argument --help\r
333 +   (or -h), it shows the test_description and exits.\r
334 +\r
335 + - Creates an empty test directory with an empty .git/objects\r
336 +   database and chdir(2) into it.  This directory is 't/trash directory'\r
337 +   if you must know, but I do not think you care.\r
338 +\r
339 + - Defines standard test helper functions for your scripts to\r
340 +   use.  These functions are designed to make all scripts behave\r
341 +   consistently when command line arguments --verbose (or -v),\r
342 +   --debug (or -d), and --immediate (or -i) is given.\r
343 +\r
344 +\r
345 +End with test_done\r
346 +------------------\r
347 +\r
348 +Your script will be a sequence of tests, using helper functions\r
349 +from the test harness library.  At the end of the script, call\r
350 +'test_done'.\r
351 +\r
352 +\r
353 +Test harness library\r
354 +--------------------\r
355 +\r
356 +There are a handful helper functions defined in the test harness\r
357 +library for your script to use.\r
358 +\r
359 + - test_expect_success <message> <script>\r
360 +\r
361 +   This takes two strings as parameter, and evaluates the\r
362 +   <script>.  If it yields success, test is considered\r
363 +   successful.  <message> should state what it is testing.\r
364 +\r
365 +   Example:\r
366 +\r
367 +       test_expect_success \\r
368 +           'git-write-tree should be able to write an empty tree.' \\r
369 +           'tree=$(git-write-tree)'\r
370 +\r
371 + - test_expect_failure <message> <script>\r
372 +\r
373 +   This is NOT the opposite of test_expect_success, but is used\r
374 +   to mark a test that demonstrates a known breakage.  Unlike\r
375 +   the usual test_expect_success tests, which say "ok" on\r
376 +   success and "FAIL" on failure, this will say "FIXED" on\r
377 +   success and "still broken" on failure.  Failures from these\r
378 +   tests won't cause -i (immediate) to stop.\r
379 +\r
380 + - test_debug <script>\r
381 +\r
382 +   This takes a single argument, <script>, and evaluates it only\r
383 +   when the test script is started with --debug command line\r
384 +   argument.  This is primarily meant for use during the\r
385 +   development of a new test script.\r
386 +\r
387 + - test_done\r
388 +\r
389 +   Your test script must have test_done at the end.  Its purpose\r
390 +   is to summarize successes and failures in the test script and\r
391 +   exit with an appropriate error code.\r
392 +\r
393 + - test_tick\r
394 +\r
395 +   Make commit and tag names consistent by setting the author and\r
396 +   committer times to defined stated.  Subsequent calls will\r
397 +   advance the times by a fixed amount.\r
398 +\r
399 + - test_commit <message> [<filename> [<contents>]]\r
400 +\r
401 +   Creates a commit with the given message, committing the given\r
402 +   file with the given contents (default for both is to reuse the\r
403 +   message string), and adds a tag (again reusing the message\r
404 +   string as name).  Calls test_tick to make the SHA-1s\r
405 +   reproducible.\r
406 +\r
407 + - test_merge <message> <commit-or-tag>\r
408 +\r
409 +   Merges the given rev using the given message.  Like test_commit,\r
410 +   creates a tag and calls test_tick before committing.\r
411 +\r
412 +Tips for Writing Tests\r
413 +----------------------\r
414 +\r
415 +As with any programming projects, existing programs are the best\r
416 +source of the information.  However, do _not_ emulate\r
417 +t0000-basic.sh when writing your tests.  The test is special in\r
418 +that it tries to validate the very core of GIT.  For example, it\r
419 +knows that there will be 256 subdirectories under .git/objects/,\r
420 +and it knows that the object ID of an empty tree is a certain\r
421 +40-byte string.  This is deliberately done so in t0000-basic.sh\r
422 +because the things the very basic core test tries to achieve is\r
423 +to serve as a basis for people who are changing the GIT internal\r
424 +drastically.  For these people, after making certain changes,\r
425 +not seeing failures from the basic test _is_ a failure.  And\r
426 +such drastic changes to the core GIT that even changes these\r
427 +otherwise supposedly stable object IDs should be accompanied by\r
428 +an update to t0000-basic.sh.\r
429 +\r
430 +However, other tests that simply rely on basic parts of the core\r
431 +GIT working properly should not have that level of intimate\r
432 +knowledge of the core GIT internals.  If all the test scripts\r
433 +hardcoded the object IDs like t0000-basic.sh does, that defeats\r
434 +the purpose of t0000-basic.sh, which is to isolate that level of\r
435 +validation in one place.  Your test also ends up needing\r
436 +updating when such a change to the internal happens, so do _not_\r
437 +do it and leave the low level of validation to t0000-basic.sh.\r
438 diff --git a/test/aggregate-results.sh b/test/aggregate-results.sh\r
439 new file mode 100755\r
440 index 0000000..d5bab75\r
441 --- /dev/null\r
442 +++ b/test/aggregate-results.sh\r
443 @@ -0,0 +1,34 @@\r
444 +#!/bin/sh\r
445 +\r
446 +fixed=0\r
447 +success=0\r
448 +failed=0\r
449 +broken=0\r
450 +total=0\r
451 +\r
452 +for file\r
453 +do\r
454 +       while read type value\r
455 +       do\r
456 +               case $type in\r
457 +               '')\r
458 +                       continue ;;\r
459 +               fixed)\r
460 +                       fixed=$(($fixed + $value)) ;;\r
461 +               success)\r
462 +                       success=$(($success + $value)) ;;\r
463 +               failed)\r
464 +                       failed=$(($failed + $value)) ;;\r
465 +               broken)\r
466 +                       broken=$(($broken + $value)) ;;\r
467 +               total)\r
468 +                       total=$(($total + $value)) ;;\r
469 +               esac\r
470 +       done <"$file"\r
471 +done\r
472 +\r
473 +printf "%-8s%d\n" fixed $fixed\r
474 +printf "%-8s%d\n" success $success\r
475 +printf "%-8s%d\n" failed $failed\r
476 +printf "%-8s%d\n" broken $broken\r
477 +printf "%-8s%d\n" total $total\r
478 diff --git a/test/t0000-basic.sh b/test/t0000-basic.sh\r
479 new file mode 100755\r
480 index 0000000..3ec9cbe\r
481 --- /dev/null\r
482 +++ b/test/t0000-basic.sh\r
483 @@ -0,0 +1,389 @@\r
484 +#!/bin/sh\r
485 +#\r
486 +# Copyright (c) 2005 Junio C Hamano\r
487 +#\r
488 +\r
489 +test_description='Test the very basics part #1.\r
490 +\r
491 +The rest of the test suite does not check the basic operation of git\r
492 +plumbing commands to work very carefully.  Their job is to concentrate\r
493 +on tricky features that caused bugs in the past to detect regression.\r
494 +\r
495 +This test runs very basic features, like registering things in cache,\r
496 +writing tree, etc.\r
497 +\r
498 +Note that this test *deliberately* hard-codes many expected object\r
499 +IDs.  When object ID computation changes, like in the previous case of\r
500 +swapping compression and hashing order, the person who is making the\r
501 +modification *should* take notice and update the test vectors here.\r
502 +'\r
503 +\r
504 +################################################################\r
505 +# It appears that people try to run tests without building...\r
506 +\r
507 +../git >/dev/null\r
508 +if test $? != 1\r
509 +then\r
510 +       echo >&2 'You do not seem to have built git yet.'\r
511 +       exit 1\r
512 +fi\r
513 +\r
514 +. ./test-lib.sh\r
515 +\r
516 +################################################################\r
517 +# git init has been done in an empty repository.\r
518 +# make sure it is empty.\r
519 +\r
520 +find .git/objects -type f -print >should-be-empty\r
521 +test_expect_success \\r
522 +    '.git/objects should be empty after git init in an empty repo.' \\r
523 +    'cmp -s /dev/null should-be-empty'\r
524 +\r
525 +# also it should have 2 subdirectories; no fan-out anymore, pack, and info.\r
526 +# 3 is counting "objects" itself\r
527 +find .git/objects -type d -print >full-of-directories\r
528 +test_expect_success \\r
529 +    '.git/objects should have 3 subdirectories.' \\r
530 +    'test $(wc -l < full-of-directories) = 3'\r
531 +\r
532 +################################################################\r
533 +# Test harness\r
534 +test_expect_success 'success is reported like this' '\r
535 +    :\r
536 +'\r
537 +test_expect_failure 'pretend we have a known breakage' '\r
538 +    false\r
539 +'\r
540 +test_expect_failure 'pretend we have fixed a known breakage' '\r
541 +    :\r
542 +'\r
543 +test_set_prereq HAVEIT\r
544 +haveit=no\r
545 +test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '\r
546 +    test_have_prereq HAVEIT &&\r
547 +    haveit=yes\r
548 +'\r
549 +donthaveit=yes\r
550 +test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' '\r
551 +    donthaveit=no\r
552 +'\r
553 +if test $haveit$donthaveit != yesyes\r
554 +then\r
555 +       say "bug in test framework: prerequisite tags do not work reliably"\r
556 +       exit 1\r
557 +fi\r
558 +\r
559 +clean=no\r
560 +test_expect_success 'tests clean up after themselves' '\r
561 +    test_when_finished clean=yes\r
562 +'\r
563 +\r
564 +cleaner=no\r
565 +test_expect_code 1 'tests clean up even after a failure' '\r
566 +    test_when_finished cleaner=yes &&\r
567 +    (exit 1)\r
568 +'\r
569 +\r
570 +if test $clean$cleaner != yesyes\r
571 +then\r
572 +       say "bug in test framework: cleanup commands do not work reliably"\r
573 +       exit 1\r
574 +fi\r
575 +\r
576 +test_expect_code 2 'failure to clean up causes the test to fail' '\r
577 +    test_when_finished "(exit 2)"\r
578 +'\r
579 +\r
580 +################################################################\r
581 +# Basics of the basics\r
582 +\r
583 +# updating a new file without --add should fail.\r
584 +test_expect_success 'git update-index without --add should fail adding.' '\r
585 +    test_must_fail git update-index should-be-empty\r
586 +'\r
587 +\r
588 +# and with --add it should succeed, even if it is empty (it used to fail).\r
589 +test_expect_success \\r
590 +    'git update-index with --add should succeed.' \\r
591 +    'git update-index --add should-be-empty'\r
592 +\r
593 +test_expect_success \\r
594 +    'writing tree out with git write-tree' \\r
595 +    'tree=$(git write-tree)'\r
596 +\r
597 +# we know the shape and contents of the tree and know the object ID for it.\r
598 +test_expect_success \\r
599 +    'validate object ID of a known tree.' \\r
600 +    'test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a'\r
601 +\r
602 +# Removing paths.\r
603 +rm -f should-be-empty full-of-directories\r
604 +test_expect_success 'git update-index without --remove should fail removing.' '\r
605 +    test_must_fail git update-index should-be-empty\r
606 +'\r
607 +\r
608 +test_expect_success \\r
609 +    'git update-index with --remove should be able to remove.' \\r
610 +    'git update-index --remove should-be-empty'\r
611 +\r
612 +# Empty tree can be written with recent write-tree.\r
613 +test_expect_success \\r
614 +    'git write-tree should be able to write an empty tree.' \\r
615 +    'tree=$(git write-tree)'\r
616 +\r
617 +test_expect_success \\r
618 +    'validate object ID of a known tree.' \\r
619 +    'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'\r
620 +\r
621 +# Various types of objects\r
622 +# Some filesystems do not support symblic links; on such systems\r
623 +# some expected values are different\r
624 +mkdir path2 path3 path3/subp3\r
625 +paths='path0 path2/file2 path3/file3 path3/subp3/file3'\r
626 +for p in $paths\r
627 +do\r
628 +    echo "hello $p" >$p\r
629 +done\r
630 +if test_have_prereq SYMLINKS\r
631 +then\r
632 +       for p in $paths\r
633 +       do\r
634 +               ln -s "hello $p" ${p}sym\r
635 +       done\r
636 +       expectfilter=cat\r
637 +       expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b\r
638 +       expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3\r
639 +       expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2\r
640 +else\r
641 +       expectfilter='grep -v sym'\r
642 +       expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46\r
643 +       expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325\r
644 +       expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f\r
645 +fi\r
646 +\r
647 +test_expect_success \\r
648 +    'adding various types of objects with git update-index --add.' \\r
649 +    'find path* ! -type d -print | xargs git update-index --add'\r
650 +\r
651 +# Show them and see that matches what we expect.\r
652 +test_expect_success \\r
653 +    'showing stage with git ls-files --stage' \\r
654 +    'git ls-files --stage >current'\r
655 +\r
656 +$expectfilter >expected <<\EOF\r
657 +100644 f87290f8eb2cbbea7857214459a0739927eab154 0      path0\r
658 +120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0      path0sym\r
659 +100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0      path2/file2\r
660 +120000 d8ce161addc5173867a3c3c730924388daedbc38 0      path2/file2sym\r
661 +100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0      path3/file3\r
662 +120000 8599103969b43aff7e430efea79ca4636466794f 0      path3/file3sym\r
663 +100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0      path3/subp3/file3\r
664 +120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0      path3/subp3/file3sym\r
665 +EOF\r
666 +test_expect_success \\r
667 +    'validate git ls-files output for a known tree.' \\r
668 +    'test_cmp expected current'\r
669 +\r
670 +test_expect_success \\r
671 +    'writing tree out with git write-tree.' \\r
672 +    'tree=$(git write-tree)'\r
673 +test_expect_success \\r
674 +    'validate object ID for a known tree.' \\r
675 +    'test "$tree" = "$expectedtree"'\r
676 +\r
677 +test_expect_success \\r
678 +    'showing tree with git ls-tree' \\r
679 +    'git ls-tree $tree >current'\r
680 +cat >expected <<\EOF\r
681 +100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
682 +120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
683 +040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2\r
684 +040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3\r
685 +EOF\r
686 +test_expect_success SYMLINKS \\r
687 +    'git ls-tree output for a known tree.' \\r
688 +    'test_cmp expected current'\r
689 +\r
690 +# This changed in ls-tree pathspec change -- recursive does\r
691 +# not show tree nodes anymore.\r
692 +test_expect_success \\r
693 +    'showing tree with git ls-tree -r' \\r
694 +    'git ls-tree -r $tree >current'\r
695 +$expectfilter >expected <<\EOF\r
696 +100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
697 +120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
698 +100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7   path2/file2\r
699 +120000 blob d8ce161addc5173867a3c3c730924388daedbc38   path2/file2sym\r
700 +100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376   path3/file3\r
701 +120000 blob 8599103969b43aff7e430efea79ca4636466794f   path3/file3sym\r
702 +100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f   path3/subp3/file3\r
703 +120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c   path3/subp3/file3sym\r
704 +EOF\r
705 +test_expect_success \\r
706 +    'git ls-tree -r output for a known tree.' \\r
707 +    'test_cmp expected current'\r
708 +\r
709 +# But with -r -t we can have both.\r
710 +test_expect_success \\r
711 +    'showing tree with git ls-tree -r -t' \\r
712 +    'git ls-tree -r -t $tree >current'\r
713 +cat >expected <<\EOF\r
714 +100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
715 +120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
716 +040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2\r
717 +100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7   path2/file2\r
718 +120000 blob d8ce161addc5173867a3c3c730924388daedbc38   path2/file2sym\r
719 +040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3\r
720 +100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376   path3/file3\r
721 +120000 blob 8599103969b43aff7e430efea79ca4636466794f   path3/file3sym\r
722 +040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2   path3/subp3\r
723 +100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f   path3/subp3/file3\r
724 +120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c   path3/subp3/file3sym\r
725 +EOF\r
726 +test_expect_success SYMLINKS \\r
727 +    'git ls-tree -r output for a known tree.' \\r
728 +    'test_cmp expected current'\r
729 +\r
730 +test_expect_success \\r
731 +    'writing partial tree out with git write-tree --prefix.' \\r
732 +    'ptree=$(git write-tree --prefix=path3)'\r
733 +test_expect_success \\r
734 +    'validate object ID for a known tree.' \\r
735 +    'test "$ptree" = "$expectedptree1"'\r
736 +\r
737 +test_expect_success \\r
738 +    'writing partial tree out with git write-tree --prefix.' \\r
739 +    'ptree=$(git write-tree --prefix=path3/subp3)'\r
740 +test_expect_success \\r
741 +    'validate object ID for a known tree.' \\r
742 +    'test "$ptree" = "$expectedptree2"'\r
743 +\r
744 +cat >badobjects <<EOF\r
745 +100644 blob 1000000000000000000000000000000000000000   dir/file1\r
746 +100644 blob 2000000000000000000000000000000000000000   dir/file2\r
747 +100644 blob 3000000000000000000000000000000000000000   dir/file3\r
748 +100644 blob 4000000000000000000000000000000000000000   dir/file4\r
749 +100644 blob 5000000000000000000000000000000000000000   dir/file5\r
750 +EOF\r
751 +\r
752 +rm .git/index\r
753 +test_expect_success \\r
754 +    'put invalid objects into the index.' \\r
755 +    'git update-index --index-info < badobjects'\r
756 +\r
757 +test_expect_success 'writing this tree without --missing-ok.' '\r
758 +    test_must_fail git write-tree\r
759 +'\r
760 +\r
761 +test_expect_success \\r
762 +    'writing this tree with --missing-ok.' \\r
763 +    'git write-tree --missing-ok'\r
764 +\r
765 +\r
766 +################################################################\r
767 +rm .git/index\r
768 +test_expect_success \\r
769 +    'git read-tree followed by write-tree should be idempotent.' \\r
770 +    'git read-tree $tree &&\r
771 +     test -f .git/index &&\r
772 +     newtree=$(git write-tree) &&\r
773 +     test "$newtree" = "$tree"'\r
774 +\r
775 +$expectfilter >expected <<\EOF\r
776 +:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M     path0\r
777 +:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M     path0sym\r
778 +:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M     path2/file2\r
779 +:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M     path2/file2sym\r
780 +:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M     path3/file3\r
781 +:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M     path3/file3sym\r
782 +:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M     path3/subp3/file3\r
783 +:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M     path3/subp3/file3sym\r
784 +EOF\r
785 +test_expect_success \\r
786 +    'validate git diff-files output for a know cache/work tree state.' \\r
787 +    'git diff-files >current && diff >/dev/null -b current expected'\r
788 +\r
789 +test_expect_success \\r
790 +    'git update-index --refresh should succeed.' \\r
791 +    'git update-index --refresh'\r
792 +\r
793 +test_expect_success \\r
794 +    'no diff after checkout and git update-index --refresh.' \\r
795 +    'git diff-files >current && cmp -s current /dev/null'\r
796 +\r
797 +################################################################\r
798 +P=$expectedtree\r
799 +test_expect_success \\r
800 +    'git commit-tree records the correct tree in a commit.' \\r
801 +    'commit0=$(echo NO | git commit-tree $P) &&\r
802 +     tree=$(git show --pretty=raw $commit0 |\r
803 +        sed -n -e "s/^tree //p" -e "/^author /q") &&\r
804 +     test "z$tree" = "z$P"'\r
805 +\r
806 +test_expect_success \\r
807 +    'git commit-tree records the correct parent in a commit.' \\r
808 +    'commit1=$(echo NO | git commit-tree $P -p $commit0) &&\r
809 +     parent=$(git show --pretty=raw $commit1 |\r
810 +        sed -n -e "s/^parent //p" -e "/^author /q") &&\r
811 +     test "z$commit0" = "z$parent"'\r
812 +\r
813 +test_expect_success \\r
814 +    'git commit-tree omits duplicated parent in a commit.' \\r
815 +    'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&\r
816 +     parent=$(git show --pretty=raw $commit2 |\r
817 +        sed -n -e "s/^parent //p" -e "/^author /q" |\r
818 +        sort -u) &&\r
819 +     test "z$commit0" = "z$parent" &&\r
820 +     numparent=$(git show --pretty=raw $commit2 |\r
821 +        sed -n -e "s/^parent //p" -e "/^author /q" |\r
822 +        wc -l) &&\r
823 +     test $numparent = 1'\r
824 +\r
825 +test_expect_success 'update-index D/F conflict' '\r
826 +       mv path0 tmp &&\r
827 +       mv path2 path0 &&\r
828 +       mv tmp path2 &&\r
829 +       git update-index --add --replace path2 path0/file2 &&\r
830 +       numpath0=$(git ls-files path0 | wc -l) &&\r
831 +       test $numpath0 = 1\r
832 +'\r
833 +\r
834 +test_expect_success SYMLINKS 'absolute path works as expected' '\r
835 +       mkdir first &&\r
836 +       ln -s ../.git first/.git &&\r
837 +       mkdir second &&\r
838 +       ln -s ../first second/other &&\r
839 +       mkdir third &&\r
840 +       dir="$(cd .git; pwd -P)" &&\r
841 +       dir2=third/../second/other/.git &&\r
842 +       test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&\r
843 +       file="$dir"/index &&\r
844 +       test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&\r
845 +       basename=blub &&\r
846 +       test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&\r
847 +       ln -s ../first/file .git/syml &&\r
848 +       sym="$(cd first; pwd -P)"/file &&\r
849 +       test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"\r
850 +'\r
851 +\r
852 +test_expect_success 'very long name in the index handled sanely' '\r
853 +\r
854 +       a=a && # 1\r
855 +       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16\r
856 +       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256\r
857 +       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096\r
858 +       a=${a}q &&\r
859 +\r
860 +       >path4 &&\r
861 +       git update-index --add path4 &&\r
862 +       (\r
863 +               git ls-files -s path4 |\r
864 +               sed -e "s/      .*/     /" |\r
865 +               tr -d "\012"\r
866 +               echo "$a"\r
867 +       ) | git update-index --index-info &&\r
868 +       len=$(git ls-files "a*" | wc -c) &&\r
869 +       test $len = 4098\r
870 +'\r
871 +\r
872 +test_done\r
873 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
874 new file mode 100644\r
875 index 0000000..7422bba\r
876 --- /dev/null\r
877 +++ b/test/test-lib.sh\r
878 @@ -0,0 +1,832 @@\r
879 +#!/bin/sh\r
880 +#\r
881 +# Copyright (c) 2005 Junio C Hamano\r
882 +#\r
883 +# This program is free software: you can redistribute it and/or modify\r
884 +# it under the terms of the GNU General Public License as published by\r
885 +# the Free Software Foundation, either version 2 of the License, or\r
886 +# (at your option) any later version.\r
887 +#\r
888 +# This program is distributed in the hope that it will be useful,\r
889 +# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
890 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
891 +# GNU General Public License for more details.\r
892 +#\r
893 +# You should have received a copy of the GNU General Public License\r
894 +# along with this program.  If not, see http://www.gnu.org/licenses/ .\r
895 +\r
896 +# if --tee was passed, write the output not only to the terminal, but\r
897 +# additionally to the file test-results/$BASENAME.out, too.\r
898 +case "$GIT_TEST_TEE_STARTED, $* " in\r
899 +done,*)\r
900 +       # do not redirect again\r
901 +       ;;\r
902 +*' --tee '*|*' --va'*)\r
903 +       mkdir -p test-results\r
904 +       BASE=test-results/$(basename "$0" .sh)\r
905 +       (GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1;\r
906 +        echo $? > $BASE.exit) | tee $BASE.out\r
907 +       test "$(cat $BASE.exit)" = 0\r
908 +       exit\r
909 +       ;;\r
910 +esac\r
911 +\r
912 +# Keep the original TERM for say_color\r
913 +ORIGINAL_TERM=$TERM\r
914 +\r
915 +# For repeatability, reset the environment to known value.\r
916 +LANG=C\r
917 +LC_ALL=C\r
918 +PAGER=cat\r
919 +TZ=UTC\r
920 +TERM=dumb\r
921 +export LANG LC_ALL PAGER TERM TZ\r
922 +EDITOR=:\r
923 +unset VISUAL\r
924 +unset GIT_EDITOR\r
925 +unset AUTHOR_DATE\r
926 +unset AUTHOR_EMAIL\r
927 +unset AUTHOR_NAME\r
928 +unset COMMIT_AUTHOR_EMAIL\r
929 +unset COMMIT_AUTHOR_NAME\r
930 +unset EMAIL\r
931 +unset GIT_ALTERNATE_OBJECT_DIRECTORIES\r
932 +unset GIT_AUTHOR_DATE\r
933 +GIT_AUTHOR_EMAIL=author@example.com\r
934 +GIT_AUTHOR_NAME='A U Thor'\r
935 +unset GIT_COMMITTER_DATE\r
936 +GIT_COMMITTER_EMAIL=committer@example.com\r
937 +GIT_COMMITTER_NAME='C O Mitter'\r
938 +unset GIT_DIFF_OPTS\r
939 +unset GIT_DIR\r
940 +unset GIT_WORK_TREE\r
941 +unset GIT_EXTERNAL_DIFF\r
942 +unset GIT_INDEX_FILE\r
943 +unset GIT_OBJECT_DIRECTORY\r
944 +unset GIT_CEILING_DIRECTORIES\r
945 +unset SHA1_FILE_DIRECTORIES\r
946 +unset SHA1_FILE_DIRECTORY\r
947 +unset GIT_NOTES_REF\r
948 +unset GIT_NOTES_DISPLAY_REF\r
949 +unset GIT_NOTES_REWRITE_REF\r
950 +unset GIT_NOTES_REWRITE_MODE\r
951 +GIT_MERGE_VERBOSITY=5\r
952 +export GIT_MERGE_VERBOSITY\r
953 +export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\r
954 +export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\r
955 +export EDITOR\r
956 +GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\r
957 +\r
958 +# Protect ourselves from common misconfiguration to export\r
959 +# CDPATH into the environment\r
960 +unset CDPATH\r
961 +\r
962 +unset GREP_OPTIONS\r
963 +\r
964 +case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in\r
965 +       1|2|true)\r
966 +               echo "* warning: Some tests will not work if GIT_TRACE" \\r
967 +                       "is set as to trace on STDERR ! *"\r
968 +               echo "* warning: Please set GIT_TRACE to something" \\r
969 +                       "other than 1, 2 or true ! *"\r
970 +               ;;\r
971 +esac\r
972 +\r
973 +# Convenience\r
974 +#\r
975 +# A regexp to match 5 and 40 hexdigits\r
976 +_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\r
977 +_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"\r
978 +\r
979 +# Each test should start with something like this, after copyright notices:\r
980 +#\r
981 +# test_description='Description of this test...\r
982 +# This test checks if command xyzzy does the right thing...\r
983 +# '\r
984 +# . ./test-lib.sh\r
985 +[ "x$ORIGINAL_TERM" != "xdumb" ] && (\r
986 +               TERM=$ORIGINAL_TERM &&\r
987 +               export TERM &&\r
988 +               [ -t 1 ] &&\r
989 +               tput bold >/dev/null 2>&1 &&\r
990 +               tput setaf 1 >/dev/null 2>&1 &&\r
991 +               tput sgr0 >/dev/null 2>&1\r
992 +       ) &&\r
993 +       color=t\r
994 +\r
995 +while test "$#" -ne 0\r
996 +do\r
997 +       case "$1" in\r
998 +       -d|--d|--de|--deb|--debu|--debug)\r
999 +               debug=t; shift ;;\r
1000 +       -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)\r
1001 +               immediate=t; shift ;;\r
1002 +       -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)\r
1003 +               GIT_TEST_LONG=t; export GIT_TEST_LONG; shift ;;\r
1004 +       -h|--h|--he|--hel|--help)\r
1005 +               help=t; shift ;;\r
1006 +       -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)\r
1007 +               verbose=t; shift ;;\r
1008 +       -q|--q|--qu|--qui|--quie|--quiet)\r
1009 +               quiet=t; shift ;;\r
1010 +       --with-dashes)\r
1011 +               with_dashes=t; shift ;;\r
1012 +       --no-color)\r
1013 +               color=; shift ;;\r
1014 +       --no-python)\r
1015 +               # noop now...\r
1016 +               shift ;;\r
1017 +       --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)\r
1018 +               valgrind=t; verbose=t; shift ;;\r
1019 +       --tee)\r
1020 +               shift ;; # was handled already\r
1021 +       --root=*)\r
1022 +               root=$(expr "z$1" : 'z[^=]*=\(.*\)')\r
1023 +               shift ;;\r
1024 +       *)\r
1025 +               echo "error: unknown test option '$1'" >&2; exit 1 ;;\r
1026 +       esac\r
1027 +done\r
1028 +\r
1029 +if test -n "$color"; then\r
1030 +       say_color () {\r
1031 +               (\r
1032 +               TERM=$ORIGINAL_TERM\r
1033 +               export TERM\r
1034 +               case "$1" in\r
1035 +                       error) tput bold; tput setaf 1;; # bold red\r
1036 +                       skip)  tput bold; tput setaf 2;; # bold green\r
1037 +                       pass)  tput setaf 2;;            # green\r
1038 +                       info)  tput setaf 3;;            # brown\r
1039 +                       *) test -n "$quiet" && return;;\r
1040 +               esac\r
1041 +               shift\r
1042 +               printf "* %s" "$*"\r
1043 +               tput sgr0\r
1044 +               echo\r
1045 +               )\r
1046 +       }\r
1047 +else\r
1048 +       say_color() {\r
1049 +               test -z "$1" && test -n "$quiet" && return\r
1050 +               shift\r
1051 +               echo "* $*"\r
1052 +       }\r
1053 +fi\r
1054 +\r
1055 +error () {\r
1056 +       say_color error "error: $*"\r
1057 +       GIT_EXIT_OK=t\r
1058 +       exit 1\r
1059 +}\r
1060 +\r
1061 +say () {\r
1062 +       say_color info "$*"\r
1063 +}\r
1064 +\r
1065 +test "${test_description}" != "" ||\r
1066 +error "Test script did not set test_description."\r
1067 +\r
1068 +if test "$help" = "t"\r
1069 +then\r
1070 +       echo "$test_description"\r
1071 +       exit 0\r
1072 +fi\r
1073 +\r
1074 +exec 5>&1\r
1075 +if test "$verbose" = "t"\r
1076 +then\r
1077 +       exec 4>&2 3>&1\r
1078 +else\r
1079 +       exec 4>/dev/null 3>/dev/null\r
1080 +fi\r
1081 +\r
1082 +test_failure=0\r
1083 +test_count=0\r
1084 +test_fixed=0\r
1085 +test_broken=0\r
1086 +test_success=0\r
1087 +\r
1088 +die () {\r
1089 +       code=$?\r
1090 +       if test -n "$GIT_EXIT_OK"\r
1091 +       then\r
1092 +               exit $code\r
1093 +       else\r
1094 +               echo >&5 "FATAL: Unexpected exit with code $code"\r
1095 +               exit 1\r
1096 +       fi\r
1097 +}\r
1098 +\r
1099 +GIT_EXIT_OK=\r
1100 +trap 'die' EXIT\r
1101 +\r
1102 +# The semantics of the editor variables are that of invoking\r
1103 +# sh -c "$EDITOR \"$@\"" files ...\r
1104 +#\r
1105 +# If our trash directory contains shell metacharacters, they will be\r
1106 +# interpreted if we just set $EDITOR directly, so do a little dance with\r
1107 +# environment variables to work around this.\r
1108 +#\r
1109 +# In particular, quoting isn't enough, as the path may contain the same quote\r
1110 +# that we're using.\r
1111 +test_set_editor () {\r
1112 +       FAKE_EDITOR="$1"\r
1113 +       export FAKE_EDITOR\r
1114 +       EDITOR='"$FAKE_EDITOR"'\r
1115 +       export EDITOR\r
1116 +}\r
1117 +\r
1118 +test_decode_color () {\r
1119 +       sed     -e 's/.\[1m/<WHITE>/g' \\r
1120 +               -e 's/.\[31m/<RED>/g' \\r
1121 +               -e 's/.\[32m/<GREEN>/g' \\r
1122 +               -e 's/.\[33m/<YELLOW>/g' \\r
1123 +               -e 's/.\[34m/<BLUE>/g' \\r
1124 +               -e 's/.\[35m/<MAGENTA>/g' \\r
1125 +               -e 's/.\[36m/<CYAN>/g' \\r
1126 +               -e 's/.\[m/<RESET>/g'\r
1127 +}\r
1128 +\r
1129 +q_to_nul () {\r
1130 +       perl -pe 'y/Q/\000/'\r
1131 +}\r
1132 +\r
1133 +q_to_cr () {\r
1134 +       tr Q '\015'\r
1135 +}\r
1136 +\r
1137 +append_cr () {\r
1138 +       sed -e 's/$/Q/' | tr Q '\015'\r
1139 +}\r
1140 +\r
1141 +remove_cr () {\r
1142 +       tr '\015' Q | sed -e 's/Q$//'\r
1143 +}\r
1144 +\r
1145 +test_tick () {\r
1146 +       if test -z "${test_tick+set}"\r
1147 +       then\r
1148 +               test_tick=1112911993\r
1149 +       else\r
1150 +               test_tick=$(($test_tick + 60))\r
1151 +       fi\r
1152 +       GIT_COMMITTER_DATE="$test_tick -0700"\r
1153 +       GIT_AUTHOR_DATE="$test_tick -0700"\r
1154 +       export GIT_COMMITTER_DATE GIT_AUTHOR_DATE\r
1155 +}\r
1156 +\r
1157 +# Call test_commit with the arguments "<message> [<file> [<contents>]]"\r
1158 +#\r
1159 +# This will commit a file with the given contents and the given commit\r
1160 +# message.  It will also add a tag with <message> as name.\r
1161 +#\r
1162 +# Both <file> and <contents> default to <message>.\r
1163 +\r
1164 +test_commit () {\r
1165 +       file=${2:-"$1.t"}\r
1166 +       echo "${3-$1}" > "$file" &&\r
1167 +       git add "$file" &&\r
1168 +       test_tick &&\r
1169 +       git commit -m "$1" &&\r
1170 +       git tag "$1"\r
1171 +}\r
1172 +\r
1173 +# Call test_merge with the arguments "<message> <commit>", where <commit>\r
1174 +# can be a tag pointing to the commit-to-merge.\r
1175 +\r
1176 +test_merge () {\r
1177 +       test_tick &&\r
1178 +       git merge -m "$1" "$2" &&\r
1179 +       git tag "$1"\r
1180 +}\r
1181 +\r
1182 +# This function helps systems where core.filemode=false is set.\r
1183 +# Use it instead of plain 'chmod +x' to set or unset the executable bit\r
1184 +# of a file in the working directory and add it to the index.\r
1185 +\r
1186 +test_chmod () {\r
1187 +       chmod "$@" &&\r
1188 +       git update-index --add "--chmod=$@"\r
1189 +}\r
1190 +\r
1191 +# Use test_set_prereq to tell that a particular prerequisite is available.\r
1192 +# The prerequisite can later be checked for in two ways:\r
1193 +#\r
1194 +# - Explicitly using test_have_prereq.\r
1195 +#\r
1196 +# - Implicitly by specifying the prerequisite tag in the calls to\r
1197 +#   test_expect_{success,failure,code}.\r
1198 +#\r
1199 +# The single parameter is the prerequisite tag (a simple word, in all\r
1200 +# capital letters by convention).\r
1201 +\r
1202 +test_set_prereq () {\r
1203 +       satisfied="$satisfied$1 "\r
1204 +}\r
1205 +satisfied=" "\r
1206 +\r
1207 +test_have_prereq () {\r
1208 +       case $satisfied in\r
1209 +       *" $1 "*)\r
1210 +               : yes, have it ;;\r
1211 +       *)\r
1212 +               ! : nope ;;\r
1213 +       esac\r
1214 +}\r
1215 +\r
1216 +# You are not expected to call test_ok_ and test_failure_ directly, use\r
1217 +# the text_expect_* functions instead.\r
1218 +\r
1219 +test_ok_ () {\r
1220 +       test_success=$(($test_success + 1))\r
1221 +       say_color "" "  ok $test_count: $@"\r
1222 +}\r
1223 +\r
1224 +test_failure_ () {\r
1225 +       test_failure=$(($test_failure + 1))\r
1226 +       say_color error "FAIL $test_count: $1"\r
1227 +       shift\r
1228 +       echo "$@" | sed -e 's/^/        /'\r
1229 +       test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }\r
1230 +}\r
1231 +\r
1232 +test_known_broken_ok_ () {\r
1233 +       test_fixed=$(($test_fixed+1))\r
1234 +       say_color "" "  FIXED $test_count: $@"\r
1235 +}\r
1236 +\r
1237 +test_known_broken_failure_ () {\r
1238 +       test_broken=$(($test_broken+1))\r
1239 +       say_color skip "  still broken $test_count: $@"\r
1240 +}\r
1241 +\r
1242 +test_debug () {\r
1243 +       test "$debug" = "" || eval "$1"\r
1244 +}\r
1245 +\r
1246 +test_run_ () {\r
1247 +       test_cleanup=:\r
1248 +       eval >&3 2>&4 "$1"\r
1249 +       eval_ret=$?\r
1250 +       eval >&3 2>&4 "$test_cleanup"\r
1251 +       return 0\r
1252 +}\r
1253 +\r
1254 +test_skip () {\r
1255 +       test_count=$(($test_count+1))\r
1256 +       to_skip=\r
1257 +       for skp in $GIT_SKIP_TESTS\r
1258 +       do\r
1259 +               case $this_test.$test_count in\r
1260 +               $skp)\r
1261 +                       to_skip=t\r
1262 +               esac\r
1263 +       done\r
1264 +       if test -z "$to_skip" && test -n "$prereq" &&\r
1265 +          ! test_have_prereq "$prereq"\r
1266 +       then\r
1267 +               to_skip=t\r
1268 +       fi\r
1269 +       case "$to_skip" in\r
1270 +       t)\r
1271 +               say_color skip >&3 "skipping test: $@"\r
1272 +               say_color skip "skip $test_count: $1"\r
1273 +               : true\r
1274 +               ;;\r
1275 +       *)\r
1276 +               false\r
1277 +               ;;\r
1278 +       esac\r
1279 +}\r
1280 +\r
1281 +test_expect_failure () {\r
1282 +       test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
1283 +       test "$#" = 2 ||\r
1284 +       error "bug in the test script: not 2 or 3 parameters to test-expect-failure"\r
1285 +       if ! test_skip "$@"\r
1286 +       then\r
1287 +               say >&3 "checking known breakage: $2"\r
1288 +               test_run_ "$2"\r
1289 +               if [ "$?" = 0 -a "$eval_ret" = 0 ]\r
1290 +               then\r
1291 +                       test_known_broken_ok_ "$1"\r
1292 +               else\r
1293 +                       test_known_broken_failure_ "$1"\r
1294 +               fi\r
1295 +       fi\r
1296 +       echo >&3 ""\r
1297 +}\r
1298 +\r
1299 +test_expect_success () {\r
1300 +       test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
1301 +       test "$#" = 2 ||\r
1302 +       error "bug in the test script: not 2 or 3 parameters to test-expect-success"\r
1303 +       if ! test_skip "$@"\r
1304 +       then\r
1305 +               say >&3 "expecting success: $2"\r
1306 +               test_run_ "$2"\r
1307 +               if [ "$?" = 0 -a "$eval_ret" = 0 ]\r
1308 +               then\r
1309 +                       test_ok_ "$1"\r
1310 +               else\r
1311 +                       test_failure_ "$@"\r
1312 +               fi\r
1313 +       fi\r
1314 +       echo >&3 ""\r
1315 +}\r
1316 +\r
1317 +test_expect_code () {\r
1318 +       test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
1319 +       test "$#" = 3 ||\r
1320 +       error "bug in the test script: not 3 or 4 parameters to test-expect-code"\r
1321 +       if ! test_skip "$@"\r
1322 +       then\r
1323 +               say >&3 "expecting exit code $1: $3"\r
1324 +               test_run_ "$3"\r
1325 +               if [ "$?" = 0 -a "$eval_ret" = "$1" ]\r
1326 +               then\r
1327 +                       test_ok_ "$2"\r
1328 +               else\r
1329 +                       test_failure_ "$@"\r
1330 +               fi\r
1331 +       fi\r
1332 +       echo >&3 ""\r
1333 +}\r
1334 +\r
1335 +# test_external runs external test scripts that provide continuous\r
1336 +# test output about their progress, and succeeds/fails on\r
1337 +# zero/non-zero exit code.  It outputs the test output on stdout even\r
1338 +# in non-verbose mode, and announces the external script with "* run\r
1339 +# <n>: ..." before running it.  When providing relative paths, keep in\r
1340 +# mind that all scripts run in "trash directory".\r
1341 +# Usage: test_external description command arguments...\r
1342 +# Example: test_external 'Perl API' perl ../path/to/test.pl\r
1343 +test_external () {\r
1344 +       test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
1345 +       test "$#" = 3 ||\r
1346 +       error >&5 "bug in the test script: not 3 or 4 parameters to test_external"\r
1347 +       descr="$1"\r
1348 +       shift\r
1349 +       if ! test_skip "$descr" "$@"\r
1350 +       then\r
1351 +               # Announce the script to reduce confusion about the\r
1352 +               # test output that follows.\r
1353 +               say_color "" " run $test_count: $descr ($*)"\r
1354 +               # Run command; redirect its stderr to &4 as in\r
1355 +               # test_run_, but keep its stdout on our stdout even in\r
1356 +               # non-verbose mode.\r
1357 +               "$@" 2>&4\r
1358 +               if [ "$?" = 0 ]\r
1359 +               then\r
1360 +                       test_ok_ "$descr"\r
1361 +               else\r
1362 +                       test_failure_ "$descr" "$@"\r
1363 +               fi\r
1364 +       fi\r
1365 +}\r
1366 +\r
1367 +# Like test_external, but in addition tests that the command generated\r
1368 +# no output on stderr.\r
1369 +test_external_without_stderr () {\r
1370 +       # The temporary file has no (and must have no) security\r
1371 +       # implications.\r
1372 +       tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi\r
1373 +       stderr="$tmp/git-external-stderr.$$.tmp"\r
1374 +       test_external "$@" 4> "$stderr"\r
1375 +       [ -f "$stderr" ] || error "Internal error: $stderr disappeared."\r
1376 +       descr="no stderr: $1"\r
1377 +       shift\r
1378 +       say >&3 "expecting no stderr from previous command"\r
1379 +       if [ ! -s "$stderr" ]; then\r
1380 +               rm "$stderr"\r
1381 +               test_ok_ "$descr"\r
1382 +       else\r
1383 +               if [ "$verbose" = t ]; then\r
1384 +                       output=`echo; echo Stderr is:; cat "$stderr"`\r
1385 +               else\r
1386 +                       output=\r
1387 +               fi\r
1388 +               # rm first in case test_failure exits.\r
1389 +               rm "$stderr"\r
1390 +               test_failure_ "$descr" "$@" "$output"\r
1391 +       fi\r
1392 +}\r
1393 +\r
1394 +# This is not among top-level (test_expect_success | test_expect_failure)\r
1395 +# but is a prefix that can be used in the test script, like:\r
1396 +#\r
1397 +#      test_expect_success 'complain and die' '\r
1398 +#           do something &&\r
1399 +#           do something else &&\r
1400 +#          test_must_fail git checkout ../outerspace\r
1401 +#      '\r
1402 +#\r
1403 +# Writing this as "! git checkout ../outerspace" is wrong, because\r
1404 +# the failure could be due to a segv.  We want a controlled failure.\r
1405 +\r
1406 +test_must_fail () {\r
1407 +       "$@"\r
1408 +       test $? -gt 0 -a $? -le 129 -o $? -gt 192\r
1409 +}\r
1410 +\r
1411 +# test_cmp is a helper function to compare actual and expected output.\r
1412 +# You can use it like:\r
1413 +#\r
1414 +#      test_expect_success 'foo works' '\r
1415 +#              echo expected >expected &&\r
1416 +#              foo >actual &&\r
1417 +#              test_cmp expected actual\r
1418 +#      '\r
1419 +#\r
1420 +# This could be written as either "cmp" or "diff -u", but:\r
1421 +# - cmp's output is not nearly as easy to read as diff -u\r
1422 +# - not all diff versions understand "-u"\r
1423 +\r
1424 +test_cmp() {\r
1425 +       $GIT_TEST_CMP "$@"\r
1426 +}\r
1427 +\r
1428 +# This function can be used to schedule some commands to be run\r
1429 +# unconditionally at the end of the test to restore sanity:\r
1430 +#\r
1431 +#      test_expect_success 'test core.capslock' '\r
1432 +#              git config core.capslock true &&\r
1433 +#              test_when_finished "git config --unset core.capslock" &&\r
1434 +#              hello world\r
1435 +#      '\r
1436 +#\r
1437 +# That would be roughly equivalent to\r
1438 +#\r
1439 +#      test_expect_success 'test core.capslock' '\r
1440 +#              git config core.capslock true &&\r
1441 +#              hello world\r
1442 +#              git config --unset core.capslock\r
1443 +#      '\r
1444 +#\r
1445 +# except that the greeting and config --unset must both succeed for\r
1446 +# the test to pass.\r
1447 +\r
1448 +test_when_finished () {\r
1449 +       test_cleanup="{ $*\r
1450 +               } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"\r
1451 +}\r
1452 +\r
1453 +# Most tests can use the created repository, but some may need to create more.\r
1454 +# Usage: test_create_repo <directory>\r
1455 +test_create_repo () {\r
1456 +       test "$#" = 1 ||\r
1457 +       error "bug in the test script: not 1 parameter to test-create-repo"\r
1458 +       owd=`pwd`\r
1459 +       repo="$1"\r
1460 +       mkdir -p "$repo"\r
1461 +       cd "$repo" || error "Cannot setup test environment"\r
1462 +       "$GIT_EXEC_PATH/git-init" "--template=$TEST_DIRECTORY/../templates/blt/" >&3 2>&4 ||\r
1463 +       error "cannot run git init -- have you built things yet?"\r
1464 +       mv .git/hooks .git/hooks-disabled\r
1465 +       cd "$owd"\r
1466 +}\r
1467 +\r
1468 +test_done () {\r
1469 +       GIT_EXIT_OK=t\r
1470 +       test_results_dir="$TEST_DIRECTORY/test-results"\r
1471 +       mkdir -p "$test_results_dir"\r
1472 +       test_results_path="$test_results_dir/${0%.sh}-$$"\r
1473 +\r
1474 +       echo "total $test_count" >> $test_results_path\r
1475 +       echo "success $test_success" >> $test_results_path\r
1476 +       echo "fixed $test_fixed" >> $test_results_path\r
1477 +       echo "broken $test_broken" >> $test_results_path\r
1478 +       echo "failed $test_failure" >> $test_results_path\r
1479 +       echo "" >> $test_results_path\r
1480 +\r
1481 +       if test "$test_fixed" != 0\r
1482 +       then\r
1483 +               say_color pass "fixed $test_fixed known breakage(s)"\r
1484 +       fi\r
1485 +       if test "$test_broken" != 0\r
1486 +       then\r
1487 +               say_color error "still have $test_broken known breakage(s)"\r
1488 +               msg="remaining $(($test_count-$test_broken)) test(s)"\r
1489 +       else\r
1490 +               msg="$test_count test(s)"\r
1491 +       fi\r
1492 +       case "$test_failure" in\r
1493 +       0)\r
1494 +               say_color pass "passed all $msg"\r
1495 +\r
1496 +               test -d "$remove_trash" &&\r
1497 +               cd "$(dirname "$remove_trash")" &&\r
1498 +               rm -rf "$(basename "$remove_trash")"\r
1499 +\r
1500 +               exit 0 ;;\r
1501 +\r
1502 +       *)\r
1503 +               say_color error "failed $test_failure among $msg"\r
1504 +               exit 1 ;;\r
1505 +\r
1506 +       esac\r
1507 +}\r
1508 +\r
1509 +# Test the binaries we have just built.  The tests are kept in\r
1510 +# t/ subdirectory and are run in 'trash directory' subdirectory.\r
1511 +TEST_DIRECTORY=$(pwd)\r
1512 +if test -n "$valgrind"\r
1513 +then\r
1514 +       make_symlink () {\r
1515 +               test -h "$2" &&\r
1516 +               test "$1" = "$(readlink "$2")" || {\r
1517 +                       # be super paranoid\r
1518 +                       if mkdir "$2".lock\r
1519 +                       then\r
1520 +                               rm -f "$2" &&\r
1521 +                               ln -s "$1" "$2" &&\r
1522 +                               rm -r "$2".lock\r
1523 +                       else\r
1524 +                               while test -d "$2".lock\r
1525 +                               do\r
1526 +                                       say "Waiting for lock on $2."\r
1527 +                                       sleep 1\r
1528 +                               done\r
1529 +                       fi\r
1530 +               }\r
1531 +       }\r
1532 +\r
1533 +       make_valgrind_symlink () {\r
1534 +               # handle only executables\r
1535 +               test -x "$1" || return\r
1536 +\r
1537 +               base=$(basename "$1")\r
1538 +               symlink_target=$TEST_DIRECTORY/../$base\r
1539 +               # do not override scripts\r
1540 +               if test -x "$symlink_target" &&\r
1541 +                   test ! -d "$symlink_target" &&\r
1542 +                   test "#!" != "$(head -c 2 < "$symlink_target")"\r
1543 +               then\r
1544 +                       symlink_target=../valgrind.sh\r
1545 +               fi\r
1546 +               case "$base" in\r
1547 +               *.sh|*.perl)\r
1548 +                       symlink_target=../unprocessed-script\r
1549 +               esac\r
1550 +               # create the link, or replace it if it is out of date\r
1551 +               make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit\r
1552 +       }\r
1553 +\r
1554 +       # override all git executables in TEST_DIRECTORY/..\r
1555 +       GIT_VALGRIND=$TEST_DIRECTORY/valgrind\r
1556 +       mkdir -p "$GIT_VALGRIND"/bin\r
1557 +       for file in $TEST_DIRECTORY/../git* $TEST_DIRECTORY/../test-*\r
1558 +       do\r
1559 +               make_valgrind_symlink $file\r
1560 +       done\r
1561 +       OLDIFS=$IFS\r
1562 +       IFS=:\r
1563 +       for path in $PATH\r
1564 +       do\r
1565 +               ls "$path"/git-* 2> /dev/null |\r
1566 +               while read file\r
1567 +               do\r
1568 +                       make_valgrind_symlink "$file"\r
1569 +               done\r
1570 +       done\r
1571 +       IFS=$OLDIFS\r
1572 +       PATH=$GIT_VALGRIND/bin:$PATH\r
1573 +       GIT_EXEC_PATH=$GIT_VALGRIND/bin\r
1574 +       export GIT_VALGRIND\r
1575 +elif test -n "$GIT_TEST_INSTALLED" ; then\r
1576 +       GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||\r
1577 +       error "Cannot run git from $GIT_TEST_INSTALLED."\r
1578 +       PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH\r
1579 +       GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}\r
1580 +else # normal case, use ../bin-wrappers only unless $with_dashes:\r
1581 +       git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"\r
1582 +       if ! test -x "$git_bin_dir/git" ; then\r
1583 +               if test -z "$with_dashes" ; then\r
1584 +                       say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"\r
1585 +               fi\r
1586 +               with_dashes=t\r
1587 +       fi\r
1588 +       PATH="$git_bin_dir:$PATH"\r
1589 +       GIT_EXEC_PATH=$TEST_DIRECTORY/..\r
1590 +       if test -n "$with_dashes" ; then\r
1591 +               PATH="$TEST_DIRECTORY/..:$PATH"\r
1592 +       fi\r
1593 +fi\r
1594 +GIT_TEMPLATE_DIR=$(pwd)/../templates/blt\r
1595 +unset GIT_CONFIG\r
1596 +GIT_CONFIG_NOSYSTEM=1\r
1597 +GIT_CONFIG_NOGLOBAL=1\r
1598 +export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL\r
1599 +\r
1600 +. ../GIT-BUILD-OPTIONS\r
1601 +\r
1602 +GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git\r
1603 +export GITPERLLIB\r
1604 +test -d ../templates/blt || {\r
1605 +       error "You haven't built things yet, have you?"\r
1606 +}\r
1607 +\r
1608 +if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"\r
1609 +then\r
1610 +       GITPYTHONLIB="$(pwd)/../git_remote_helpers/build/lib"\r
1611 +       export GITPYTHONLIB\r
1612 +       test -d ../git_remote_helpers/build || {\r
1613 +               error "You haven't built git_remote_helpers yet, have you?"\r
1614 +       }\r
1615 +fi\r
1616 +\r
1617 +if ! test -x ../test-chmtime; then\r
1618 +       echo >&2 'You need to build test-chmtime:'\r
1619 +       echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'\r
1620 +       exit 1\r
1621 +fi\r
1622 +\r
1623 +# Test repository\r
1624 +test="trash directory.$(basename "$0" .sh)"\r
1625 +test -n "$root" && test="$root/$test"\r
1626 +case "$test" in\r
1627 +/*) TRASH_DIRECTORY="$test" ;;\r
1628 + *) TRASH_DIRECTORY="$TEST_DIRECTORY/$test" ;;\r
1629 +esac\r
1630 +test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY\r
1631 +rm -fr "$test" || {\r
1632 +       GIT_EXIT_OK=t\r
1633 +       echo >&5 "FATAL: Cannot prepare test area"\r
1634 +       exit 1\r
1635 +}\r
1636 +\r
1637 +test_create_repo "$test"\r
1638 +# Use -P to resolve symlinks in our working directory so that the cwd\r
1639 +# in subprocesses like git equals our $PWD (for pathname comparisons).\r
1640 +cd -P "$test" || exit 1\r
1641 +\r
1642 +this_test=${0##*/}\r
1643 +this_test=${this_test%%-*}\r
1644 +for skp in $GIT_SKIP_TESTS\r
1645 +do\r
1646 +       to_skip=\r
1647 +       for skp in $GIT_SKIP_TESTS\r
1648 +       do\r
1649 +               case "$this_test" in\r
1650 +               $skp)\r
1651 +                       to_skip=t\r
1652 +               esac\r
1653 +       done\r
1654 +       case "$to_skip" in\r
1655 +       t)\r
1656 +               say_color skip >&3 "skipping test $this_test altogether"\r
1657 +               say_color skip "skip all tests in $this_test"\r
1658 +               test_done\r
1659 +       esac\r
1660 +done\r
1661 +\r
1662 +# Provide an implementation of the 'yes' utility\r
1663 +yes () {\r
1664 +       if test $# = 0\r
1665 +       then\r
1666 +               y=y\r
1667 +       else\r
1668 +               y="$*"\r
1669 +       fi\r
1670 +\r
1671 +       while echo "$y"\r
1672 +       do\r
1673 +               :\r
1674 +       done\r
1675 +}\r
1676 +\r
1677 +# Fix some commands on Windows\r
1678 +case $(uname -s) in\r
1679 +*MINGW*)\r
1680 +       # Windows has its own (incompatible) sort and find\r
1681 +       sort () {\r
1682 +               /usr/bin/sort "$@"\r
1683 +       }\r
1684 +       find () {\r
1685 +               /usr/bin/find "$@"\r
1686 +       }\r
1687 +       sum () {\r
1688 +               md5sum "$@"\r
1689 +       }\r
1690 +       # git sees Windows-style pwd\r
1691 +       pwd () {\r
1692 +               builtin pwd -W\r
1693 +       }\r
1694 +       # no POSIX permissions\r
1695 +       # backslashes in pathspec are converted to '/'\r
1696 +       # exec does not inherit the PID\r
1697 +       ;;\r
1698 +*)\r
1699 +       test_set_prereq POSIXPERM\r
1700 +       test_set_prereq BSLASHPSPEC\r
1701 +       test_set_prereq EXECKEEPSPID\r
1702 +       ;;\r
1703 +esac\r
1704 +\r
1705 +test -z "$NO_PERL" && test_set_prereq PERL\r
1706 +test -z "$NO_PYTHON" && test_set_prereq PYTHON\r
1707 +\r
1708 +# test whether the filesystem supports symbolic links\r
1709 +ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\r
1710 +rm -f y\r
1711 -- \r
1712 1.7.1.3.g75e44\r
1713 \r