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