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