Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5d / cfa28eb97441a698e1a362773f29c3239fd2c3
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 092D1431FD2\r
6         for <notmuch@notmuchmail.org>; Mon,  8 Feb 2010 07:16:36 -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.363\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.363 tagged_above=-999 required=5 tests=[AWL=0.236,\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 oPIf724X3SfL for <notmuch@notmuchmail.org>;\r
16         Mon,  8 Feb 2010 07:16:32 -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 C8155431FBF\r
19         for <notmuch@notmuchmail.org>; Mon,  8 Feb 2010 07:16:30 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 3330319F33A1;\r
22         Mon,  8 Feb 2010 16:16:28 +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 zXpL1OAV0+Yc; Mon,  8 Feb 2010 16:16:22 +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 4F20619F3395;\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 30A4B15C062;\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:08 +0100\r
38 Message-Id: <1265642169-15801-2-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 2/3] Update test framework for use with notmuch\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:36 -0000\r
56 \r
57 This removes Git specific things from the test-lib.sh and adds helper\r
58 functions for notmuch taken from Carl's notmuch-test script. README is\r
59 also slightly modified to reflect the current state.\r
60 \r
61 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
62 ---\r
63  test/Makefile       |    1 +\r
64  test/README         |   12 +-\r
65  test/t0000-basic.sh |  332 +++------------------------------------------------\r
66  test/test-lib.sh    |  320 +++++++++++++++++++++++++++----------------------\r
67  4 files changed, 204 insertions(+), 461 deletions(-)\r
68  mode change 100644 => 100755 test/test-lib.sh\r
69 \r
70 diff --git a/test/Makefile b/test/Makefile\r
71 index bd09390..e07c7fd 100644\r
72 --- a/test/Makefile\r
73 +++ b/test/Makefile\r
74 @@ -6,6 +6,7 @@\r
75  -include ../config.mak\r
76  \r
77  #GIT_TEST_OPTS=--verbose --debug\r
78 +SHELL=/bin/bash\r
79  SHELL_PATH ?= $(SHELL)\r
80  TAR ?= $(TAR)\r
81  RM ?= rm -f\r
82 diff --git a/test/README b/test/README\r
83 index dcd3ebb..0f5bddb 100644\r
84 --- a/test/README\r
85 +++ b/test/README\r
86 @@ -165,10 +165,10 @@ Writing Tests\r
87  -------------\r
88  \r
89  The test script is written as a shell script.  It should start\r
90 -with the standard "#!/bin/sh" with copyright notices, and an\r
91 +with the standard "#!/bin/bash" with copyright notices, and an\r
92  assignment to variable 'test_description', like this:\r
93  \r
94 -       #!/bin/sh\r
95 +       #!/bin/bash\r
96         #\r
97         # Copyright (c) 2005 Junio C Hamano\r
98         #\r
99 @@ -192,9 +192,11 @@ This test harness library does the following things:\r
100   - If the script is invoked with command line argument --help\r
101     (or -h), it shows the test_description and exits.\r
102  \r
103 - - Creates an empty test directory with an empty .git/objects\r
104 -   database and chdir(2) into it.  This directory is 't/trash directory'\r
105 -   if you must know, but I do not think you care.\r
106 + - Creates a test directory with default notmuch-config and empty mail\r
107 +   store. This directory is 't/trash directory.<test-basename>' (note\r
108 +   the space) if you must know, but I do not think you care. The path\r
109 +   to notmuch-config is exported in NOTMUCH_CONFIG environment\r
110 +   variable and mail store path is stored in MAIL_DIR variabl.\r
111  \r
112   - Defines standard test helper functions for your scripts to\r
113     use.  These functions are designed to make all scripts behave\r
114 diff --git a/test/t0000-basic.sh b/test/t0000-basic.sh\r
115 index f4ca4fc..cc2ca21 100755\r
116 --- a/test/t0000-basic.sh\r
117 +++ b/test/t0000-basic.sh\r
118 @@ -5,46 +5,39 @@\r
119  \r
120  test_description='Test the very basics part #1.\r
121  \r
122 -The rest of the test suite does not check the basic operation of git\r
123 -plumbing commands to work very carefully.  Their job is to concentrate\r
124 -on tricky features that caused bugs in the past to detect regression.\r
125 -\r
126 -This test runs very basic features, like registering things in cache,\r
127 -writing tree, etc.\r
128 -\r
129 -Note that this test *deliberately* hard-codes many expected object\r
130 -IDs.  When object ID computation changes, like in the previous case of\r
131 -swapping compression and hashing order, the person who is making the\r
132 -modification *should* take notice and update the test vectors here.\r
133 +Tests the test framework itself.\r
134  '\r
135 -\r
136  ################################################################\r
137  # It appears that people try to run tests without building...\r
138  \r
139 -../git >/dev/null\r
140 -if test $? != 1\r
141 +if ! test -x ../notmuch\r
142  then\r
143 -       echo >&2 'You do not seem to have built git yet.'\r
144 +       echo >&2 'You do not seem to have built notmuch yet.'\r
145         exit 1\r
146  fi\r
147  \r
148  . ./test-lib.sh\r
149  \r
150  ################################################################\r
151 -# git init has been done in an empty repository.\r
152 -# make sure it is empty.\r
153 +# Test mail store prepared in test-lib.sh\r
154 +\r
155 +test_expect_success \\r
156 +    'test that mail store was created' \\r
157 +    'test -d "${MAIL_DIR}"'\r
158 +\r
159  \r
160 -find .git/objects -type f -print >should-be-empty\r
161 +find "${MAIL_DIR}" -type f -print >should-be-empty\r
162  test_expect_success \\r
163 -    '.git/objects should be empty after git init in an empty repo.' \\r
164 +    'mail store should be empty' \\r
165      'cmp -s /dev/null should-be-empty'\r
166  \r
167 -# also it should have 2 subdirectories; no fan-out anymore, pack, and info.\r
168 -# 3 is counting "objects" itself\r
169 -find .git/objects -type d -print >full-of-directories\r
170  test_expect_success \\r
171 -    '.git/objects should have 3 subdirectories.' \\r
172 -    'test $(wc -l < full-of-directories) = 3'\r
173 +    'NOTMUCH_CONFIG is set and points to an existing file' \\r
174 +    'test -f "${NOTMUCH_CONFIG}"'\r
175 +\r
176 +test_expect_success \\r
177 +    'PATH is set to this repository' \\r
178 +    'test "`echo $PATH|cut -f1 -d:`" = "`dirname ${TEST_DIRECTORY}`"'\r
179  \r
180  ################################################################\r
181  # Test harness\r
182 @@ -73,296 +66,5 @@ then\r
183         exit 1\r
184  fi\r
185  \r
186 -################################################################\r
187 -# Basics of the basics\r
188 -\r
189 -# updating a new file without --add should fail.\r
190 -test_expect_success 'git update-index without --add should fail adding.' '\r
191 -    test_must_fail git update-index should-be-empty\r
192 -'\r
193 -\r
194 -# and with --add it should succeed, even if it is empty (it used to fail).\r
195 -test_expect_success \\r
196 -    'git update-index with --add should succeed.' \\r
197 -    'git update-index --add should-be-empty'\r
198 -\r
199 -test_expect_success \\r
200 -    'writing tree out with git write-tree' \\r
201 -    'tree=$(git write-tree)'\r
202 -\r
203 -# we know the shape and contents of the tree and know the object ID for it.\r
204 -test_expect_success \\r
205 -    'validate object ID of a known tree.' \\r
206 -    'test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a'\r
207 -\r
208 -# Removing paths.\r
209 -rm -f should-be-empty full-of-directories\r
210 -test_expect_success 'git update-index without --remove should fail removing.' '\r
211 -    test_must_fail git update-index should-be-empty\r
212 -'\r
213 -\r
214 -test_expect_success \\r
215 -    'git update-index with --remove should be able to remove.' \\r
216 -    'git update-index --remove should-be-empty'\r
217 -\r
218 -# Empty tree can be written with recent write-tree.\r
219 -test_expect_success \\r
220 -    'git write-tree should be able to write an empty tree.' \\r
221 -    'tree=$(git write-tree)'\r
222 -\r
223 -test_expect_success \\r
224 -    'validate object ID of a known tree.' \\r
225 -    'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'\r
226 -\r
227 -# Various types of objects\r
228 -# Some filesystems do not support symblic links; on such systems\r
229 -# some expected values are different\r
230 -mkdir path2 path3 path3/subp3\r
231 -paths='path0 path2/file2 path3/file3 path3/subp3/file3'\r
232 -for p in $paths\r
233 -do\r
234 -    echo "hello $p" >$p\r
235 -done\r
236 -if test_have_prereq SYMLINKS\r
237 -then\r
238 -       for p in $paths\r
239 -       do\r
240 -               ln -s "hello $p" ${p}sym\r
241 -       done\r
242 -       expectfilter=cat\r
243 -       expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b\r
244 -       expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3\r
245 -       expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2\r
246 -else\r
247 -       expectfilter='grep -v sym'\r
248 -       expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46\r
249 -       expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325\r
250 -       expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f\r
251 -fi\r
252 -\r
253 -test_expect_success \\r
254 -    'adding various types of objects with git update-index --add.' \\r
255 -    'find path* ! -type d -print | xargs git update-index --add'\r
256 -\r
257 -# Show them and see that matches what we expect.\r
258 -test_expect_success \\r
259 -    'showing stage with git ls-files --stage' \\r
260 -    'git ls-files --stage >current'\r
261 -\r
262 -$expectfilter >expected <<\EOF\r
263 -100644 f87290f8eb2cbbea7857214459a0739927eab154 0      path0\r
264 -120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0      path0sym\r
265 -100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0      path2/file2\r
266 -120000 d8ce161addc5173867a3c3c730924388daedbc38 0      path2/file2sym\r
267 -100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0      path3/file3\r
268 -120000 8599103969b43aff7e430efea79ca4636466794f 0      path3/file3sym\r
269 -100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0      path3/subp3/file3\r
270 -120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0      path3/subp3/file3sym\r
271 -EOF\r
272 -test_expect_success \\r
273 -    'validate git ls-files output for a known tree.' \\r
274 -    'test_cmp expected current'\r
275 -\r
276 -test_expect_success \\r
277 -    'writing tree out with git write-tree.' \\r
278 -    'tree=$(git write-tree)'\r
279 -test_expect_success \\r
280 -    'validate object ID for a known tree.' \\r
281 -    'test "$tree" = "$expectedtree"'\r
282 -\r
283 -test_expect_success \\r
284 -    'showing tree with git ls-tree' \\r
285 -    'git ls-tree $tree >current'\r
286 -cat >expected <<\EOF\r
287 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
288 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
289 -040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2\r
290 -040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3\r
291 -EOF\r
292 -test_expect_success SYMLINKS \\r
293 -    'git ls-tree output for a known tree.' \\r
294 -    'test_cmp expected current'\r
295 -\r
296 -# This changed in ls-tree pathspec change -- recursive does\r
297 -# not show tree nodes anymore.\r
298 -test_expect_success \\r
299 -    'showing tree with git ls-tree -r' \\r
300 -    'git ls-tree -r $tree >current'\r
301 -$expectfilter >expected <<\EOF\r
302 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
303 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
304 -100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7   path2/file2\r
305 -120000 blob d8ce161addc5173867a3c3c730924388daedbc38   path2/file2sym\r
306 -100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376   path3/file3\r
307 -120000 blob 8599103969b43aff7e430efea79ca4636466794f   path3/file3sym\r
308 -100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f   path3/subp3/file3\r
309 -120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c   path3/subp3/file3sym\r
310 -EOF\r
311 -test_expect_success \\r
312 -    'git ls-tree -r output for a known tree.' \\r
313 -    'test_cmp expected current'\r
314 -\r
315 -# But with -r -t we can have both.\r
316 -test_expect_success \\r
317 -    'showing tree with git ls-tree -r -t' \\r
318 -    'git ls-tree -r -t $tree >current'\r
319 -cat >expected <<\EOF\r
320 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0\r
321 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym\r
322 -040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2\r
323 -100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7   path2/file2\r
324 -120000 blob d8ce161addc5173867a3c3c730924388daedbc38   path2/file2sym\r
325 -040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3\r
326 -100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376   path3/file3\r
327 -120000 blob 8599103969b43aff7e430efea79ca4636466794f   path3/file3sym\r
328 -040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2   path3/subp3\r
329 -100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f   path3/subp3/file3\r
330 -120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c   path3/subp3/file3sym\r
331 -EOF\r
332 -test_expect_success SYMLINKS \\r
333 -    'git ls-tree -r output for a known tree.' \\r
334 -    'test_cmp expected current'\r
335 -\r
336 -test_expect_success \\r
337 -    'writing partial tree out with git write-tree --prefix.' \\r
338 -    'ptree=$(git write-tree --prefix=path3)'\r
339 -test_expect_success \\r
340 -    'validate object ID for a known tree.' \\r
341 -    'test "$ptree" = "$expectedptree1"'\r
342 -\r
343 -test_expect_success \\r
344 -    'writing partial tree out with git write-tree --prefix.' \\r
345 -    'ptree=$(git write-tree --prefix=path3/subp3)'\r
346 -test_expect_success \\r
347 -    'validate object ID for a known tree.' \\r
348 -    'test "$ptree" = "$expectedptree2"'\r
349 -\r
350 -cat >badobjects <<EOF\r
351 -100644 blob 1000000000000000000000000000000000000000   dir/file1\r
352 -100644 blob 2000000000000000000000000000000000000000   dir/file2\r
353 -100644 blob 3000000000000000000000000000000000000000   dir/file3\r
354 -100644 blob 4000000000000000000000000000000000000000   dir/file4\r
355 -100644 blob 5000000000000000000000000000000000000000   dir/file5\r
356 -EOF\r
357 -\r
358 -rm .git/index\r
359 -test_expect_success \\r
360 -    'put invalid objects into the index.' \\r
361 -    'git update-index --index-info < badobjects'\r
362 -\r
363 -test_expect_success 'writing this tree without --missing-ok.' '\r
364 -    test_must_fail git write-tree\r
365 -'\r
366 -\r
367 -test_expect_success \\r
368 -    'writing this tree with --missing-ok.' \\r
369 -    'git write-tree --missing-ok'\r
370 -\r
371 -\r
372 -################################################################\r
373 -rm .git/index\r
374 -test_expect_success \\r
375 -    'git read-tree followed by write-tree should be idempotent.' \\r
376 -    'git read-tree $tree &&\r
377 -     test -f .git/index &&\r
378 -     newtree=$(git write-tree) &&\r
379 -     test "$newtree" = "$tree"'\r
380 -\r
381 -$expectfilter >expected <<\EOF\r
382 -:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M     path0\r
383 -:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M     path0sym\r
384 -:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M     path2/file2\r
385 -:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M     path2/file2sym\r
386 -:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M     path3/file3\r
387 -:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M     path3/file3sym\r
388 -:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M     path3/subp3/file3\r
389 -:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M     path3/subp3/file3sym\r
390 -EOF\r
391 -test_expect_success \\r
392 -    'validate git diff-files output for a know cache/work tree state.' \\r
393 -    'git diff-files >current && diff >/dev/null -b current expected'\r
394 -\r
395 -test_expect_success \\r
396 -    'git update-index --refresh should succeed.' \\r
397 -    'git update-index --refresh'\r
398 -\r
399 -test_expect_success \\r
400 -    'no diff after checkout and git update-index --refresh.' \\r
401 -    'git diff-files >current && cmp -s current /dev/null'\r
402 -\r
403 -################################################################\r
404 -P=$expectedtree\r
405 -test_expect_success \\r
406 -    'git commit-tree records the correct tree in a commit.' \\r
407 -    'commit0=$(echo NO | git commit-tree $P) &&\r
408 -     tree=$(git show --pretty=raw $commit0 |\r
409 -        sed -n -e "s/^tree //p" -e "/^author /q") &&\r
410 -     test "z$tree" = "z$P"'\r
411 -\r
412 -test_expect_success \\r
413 -    'git commit-tree records the correct parent in a commit.' \\r
414 -    'commit1=$(echo NO | git commit-tree $P -p $commit0) &&\r
415 -     parent=$(git show --pretty=raw $commit1 |\r
416 -        sed -n -e "s/^parent //p" -e "/^author /q") &&\r
417 -     test "z$commit0" = "z$parent"'\r
418 -\r
419 -test_expect_success \\r
420 -    'git commit-tree omits duplicated parent in a commit.' \\r
421 -    'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&\r
422 -     parent=$(git show --pretty=raw $commit2 |\r
423 -        sed -n -e "s/^parent //p" -e "/^author /q" |\r
424 -        sort -u) &&\r
425 -     test "z$commit0" = "z$parent" &&\r
426 -     numparent=$(git show --pretty=raw $commit2 |\r
427 -        sed -n -e "s/^parent //p" -e "/^author /q" |\r
428 -        wc -l) &&\r
429 -     test $numparent = 1'\r
430 -\r
431 -test_expect_success 'update-index D/F conflict' '\r
432 -       mv path0 tmp &&\r
433 -       mv path2 path0 &&\r
434 -       mv tmp path2 &&\r
435 -       git update-index --add --replace path2 path0/file2 &&\r
436 -       numpath0=$(git ls-files path0 | wc -l) &&\r
437 -       test $numpath0 = 1\r
438 -'\r
439 -\r
440 -test_expect_success SYMLINKS 'absolute path works as expected' '\r
441 -       mkdir first &&\r
442 -       ln -s ../.git first/.git &&\r
443 -       mkdir second &&\r
444 -       ln -s ../first second/other &&\r
445 -       mkdir third &&\r
446 -       dir="$(cd .git; pwd -P)" &&\r
447 -       dir2=third/../second/other/.git &&\r
448 -       test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&\r
449 -       file="$dir"/index &&\r
450 -       test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&\r
451 -       basename=blub &&\r
452 -       test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&\r
453 -       ln -s ../first/file .git/syml &&\r
454 -       sym="$(cd first; pwd -P)"/file &&\r
455 -       test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"\r
456 -'\r
457 -\r
458 -test_expect_success 'very long name in the index handled sanely' '\r
459 -\r
460 -       a=a && # 1\r
461 -       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16\r
462 -       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256\r
463 -       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096\r
464 -       a=${a}q &&\r
465 -\r
466 -       >path4 &&\r
467 -       git update-index --add path4 &&\r
468 -       (\r
469 -               git ls-files -s path4 |\r
470 -               sed -e "s/      .*/     /" |\r
471 -               tr -d "\012"\r
472 -               echo "$a"\r
473 -       ) | git update-index --index-info &&\r
474 -       len=$(git ls-files "a*" | wc -c) &&\r
475 -       test $len = 4098\r
476 -'\r
477  \r
478  test_done\r
479 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
480 old mode 100644\r
481 new mode 100755\r
482 index afd3053..9a0f71b\r
483 --- a/test/test-lib.sh\r
484 +++ b/test/test-lib.sh\r
485 @@ -1,4 +1,4 @@\r
486 -#!/bin/sh\r
487 +#!/bin/bash\r
488  #\r
489  # Copyright (c) 2005 Junio C Hamano\r
490  #\r
491 @@ -29,36 +29,6 @@ PAGER=cat\r
492  TZ=UTC\r
493  TERM=dumb\r
494  export LANG LC_ALL PAGER TERM TZ\r
495 -EDITOR=:\r
496 -unset VISUAL\r
497 -unset GIT_EDITOR\r
498 -unset AUTHOR_DATE\r
499 -unset AUTHOR_EMAIL\r
500 -unset AUTHOR_NAME\r
501 -unset COMMIT_AUTHOR_EMAIL\r
502 -unset COMMIT_AUTHOR_NAME\r
503 -unset EMAIL\r
504 -unset GIT_ALTERNATE_OBJECT_DIRECTORIES\r
505 -unset GIT_AUTHOR_DATE\r
506 -GIT_AUTHOR_EMAIL=author@example.com\r
507 -GIT_AUTHOR_NAME='A U Thor'\r
508 -unset GIT_COMMITTER_DATE\r
509 -GIT_COMMITTER_EMAIL=committer@example.com\r
510 -GIT_COMMITTER_NAME='C O Mitter'\r
511 -unset GIT_DIFF_OPTS\r
512 -unset GIT_DIR\r
513 -unset GIT_WORK_TREE\r
514 -unset GIT_EXTERNAL_DIFF\r
515 -unset GIT_INDEX_FILE\r
516 -unset GIT_OBJECT_DIRECTORY\r
517 -unset GIT_CEILING_DIRECTORIES\r
518 -unset SHA1_FILE_DIRECTORIES\r
519 -unset SHA1_FILE_DIRECTORY\r
520 -GIT_MERGE_VERBOSITY=5\r
521 -export GIT_MERGE_VERBOSITY\r
522 -export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\r
523 -export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\r
524 -export EDITOR\r
525  GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\r
526  \r
527  # Protect ourselves from common misconfiguration to export\r
528 @@ -80,6 +50,9 @@ esac\r
529  _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\r
530  _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"\r
531  \r
532 +_x04='[0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\r
533 +_x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04"\r
534 +\r
535  # Each test should start with something like this, after copyright notices:\r
536  #\r
537  # test_description='Description of this test...\r
538 @@ -203,22 +176,6 @@ die () {\r
539  GIT_EXIT_OK=\r
540  trap 'die' EXIT\r
541  \r
542 -# The semantics of the editor variables are that of invoking\r
543 -# sh -c "$EDITOR \"$@\"" files ...\r
544 -#\r
545 -# If our trash directory contains shell metacharacters, they will be\r
546 -# interpreted if we just set $EDITOR directly, so do a little dance with\r
547 -# environment variables to work around this.\r
548 -#\r
549 -# In particular, quoting isn't enough, as the path may contain the same quote\r
550 -# that we're using.\r
551 -test_set_editor () {\r
552 -       FAKE_EDITOR="$1"\r
553 -       export FAKE_EDITOR\r
554 -       EDITOR='"$FAKE_EDITOR"'\r
555 -       export EDITOR\r
556 -}\r
557 -\r
558  test_decode_color () {\r
559         sed     -e 's/.\[1m/<WHITE>/g' \\r
560                 -e 's/.\[31m/<RED>/g' \\r
561 @@ -246,51 +203,150 @@ remove_cr () {\r
562         tr '\015' Q | sed -e 's/Q$//'\r
563  }\r
564  \r
565 -test_tick () {\r
566 -       if test -z "${test_tick+set}"\r
567 -       then\r
568 -               test_tick=1112911993\r
569 -       else\r
570 -               test_tick=$(($test_tick + 60))\r
571 -       fi\r
572 -       GIT_COMMITTER_DATE="$test_tick -0700"\r
573 -       GIT_AUTHOR_DATE="$test_tick -0700"\r
574 -       export GIT_COMMITTER_DATE GIT_AUTHOR_DATE\r
575 +increment_mtime_amount=0\r
576 +increment_mtime ()\r
577 +{\r
578 +    dir="$1"\r
579 +\r
580 +    increment_mtime_amount=$((increment_mtime_amount + 1))\r
581 +    touch -d "+${increment_mtime_amount} seconds" "$dir"\r
582  }\r
583  \r
584 -# Call test_commit with the arguments "<message> [<file> [<contents>]]"\r
585 +# Generate a new message in the mail directory, with a unique message\r
586 +# ID and subject. The message is not added to the index.\r
587 +#\r
588 +# After this function returns, the filename of the generated message\r
589 +# is available as $gen_msg_filename and the message ID is available as\r
590 +# $gen_msg_id .\r
591 +#\r
592 +# This function supports named parameters with the bash syntax for\r
593 +# assigning a value to an associative array ([name]=value). The\r
594 +# supported parameters are:\r
595  #\r
596 -# This will commit a file with the given contents and the given commit\r
597 -# message.  It will also add a tag with <message> as name.\r
598 +#  [dir]=directory/of/choice\r
599  #\r
600 -# Both <file> and <contents> default to <message>.\r
601 +#      Generate the message in directory 'directory/of/choice' within\r
602 +#      the mail store. The directory will be created if necessary.\r
603 +#\r
604 +#  [body]=text\r
605 +#\r
606 +#      Text to use as the body of the email message\r
607 +#\r
608 +#  '[from]="Some User <user@example.com>"'\r
609 +#  '[to]="Some User <user@example.com>"'\r
610 +#  '[subject]="Subject of email message"'\r
611 +#  '[date]="RFC 822 Date"'\r
612 +#\r
613 +#      Values for email headers. If not provided, default values will\r
614 +#      be generated instead.\r
615 +#\r
616 +#  '[cc]="Some User <user@example.com>"'\r
617 +#  [reply-to]=some-address\r
618 +#  [in-reply-to]=<message-id>\r
619 +#\r
620 +#      Additional values for email headers. If these are not provided\r
621 +#      then the relevant headers will simply not appear in the\r
622 +#      message.\r
623 +gen_msg_cnt=0\r
624 +gen_msg_filename=""\r
625 +gen_msg_id=""\r
626 +generate_message ()\r
627 +{\r
628 +    # This is our (bash-specific) magic for doing named parameters\r
629 +    local -A template="($@)"\r
630 +    local additional_headers\r
631 +\r
632 +    gen_msg_cnt=$((gen_msg_cnt + 1))\r
633 +    gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)\r
634 +    gen_msg_id="${gen_msg_name}@notmuch-test-suite"\r
635 +\r
636 +    if [ -z "${template[dir]}" ]; then\r
637 +       gen_msg_filename="${MAIL_DIR}/$gen_msg_name"\r
638 +    else\r
639 +       gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"\r
640 +       mkdir -p "$(dirname "$gen_msg_filename")"\r
641 +    fi\r
642 +\r
643 +    if [ -z "${template[body]}" ]; then\r
644 +       template[body]="This is just a test message at ${gen_msg_filename}"\r
645 +    fi\r
646 +\r
647 +    if [ -z "${template[from]}" ]; then\r
648 +       template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"\r
649 +    fi\r
650 +\r
651 +    if [ -z "${template[to]}" ]; then\r
652 +       template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"\r
653 +    fi\r
654 +\r
655 +    if [ -z "${template[subject]}" ]; then\r
656 +       template[subject]="Test message ${gen_msg_filename}"\r
657 +    fi\r
658 +\r
659 +    if [ -z "${template[date]}" ]; then\r
660 +       template[date]="Tue, 05 Jan 2010 15:43:57 -0800"\r
661 +    fi\r
662 +\r
663 +    additional_headers=""\r
664 +    if [ ! -z "${template[reply-to]}" ]; then\r
665 +       additional_headers="Reply-To: ${template[reply-to]}\r
666 +${additional_headers}"\r
667 +    fi\r
668 +\r
669 +    if [ ! -z "${template[in-reply-to]}" ]; then\r
670 +       additional_headers="In-Reply-To: ${template[in-reply-to]}\r
671 +${additional_headers}"\r
672 +    fi\r
673 +\r
674 +    if [ ! -z "${template[cc]}" ]; then\r
675 +       additional_headers="Cc: ${template[cc]}\r
676 +${additional_headers}"\r
677 +    fi\r
678 +\r
679 +cat <<EOF >"$gen_msg_filename" &&\r
680 +From: ${template[from]}\r
681 +To: ${template[to]}\r
682 +Message-Id: <${gen_msg_id}>\r
683 +Subject: ${template[subject]}\r
684 +Date: ${template[date]}\r
685 +${additional_headers}\r
686 +${template[body]}\r
687 +EOF\r
688 +\r
689 +    # Ensure that the mtime of the containing directory is updated\r
690 +    increment_mtime "$(dirname "${gen_msg_filename}")"\r
691 +}\r
692 +\r
693 +# Generate a new message and add it to the index.\r
694 +#\r
695 +# All of the arguments and return values supported by generate_message\r
696 +# are alos supported here, so see that function for details.\r
697 +add_message ()\r
698 +{\r
699 +    generate_message "$@" &&\r
700  \r
701 -test_commit () {\r
702 -       file=${2:-"$1.t"}\r
703 -       echo "${3-$1}" > "$file" &&\r
704 -       git add "$file" &&\r
705 -       test_tick &&\r
706 -       git commit -m "$1" &&\r
707 -       git tag "$1"\r
708 +    notmuch new > /dev/null\r
709  }\r
710  \r
711 -# Call test_merge with the arguments "<message> <commit>", where <commit>\r
712 -# can be a tag pointing to the commit-to-merge.\r
713 +NOTMUCH_IGNORED_OUTPUT_REGEXP='^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
714 +NOTMUCH_THREAD_ID_SQUELCH='s/thread:................................/thread:XXX/'\r
715 +execute_expecting ()\r
716 +{\r
717 +    args=$1\r
718 +    expected=$2\r
719  \r
720 -test_merge () {\r
721 -       test_tick &&\r
722 -       git merge -m "$1" "$2" &&\r
723 -       git tag "$1"\r
724 +    output=$(notmuch $args | grep -v -E -e "$NOTMUCH_IGNORED_OUTPUT_REGEXP" | sed -e "$NOTMUCH_THREAD_ID_SQUELCH" || true) &&\r
725 +    if [ "$output" = "$expected" ]; then\r
726 +       echo "  PASS"\r
727 +    else\r
728 +       echo "  FAIL"\r
729 +       echo "  Expected output: $expected"\r
730 +       echo "  Actual output:   $output"\r
731 +       false\r
732 +    fi\r
733  }\r
734  \r
735 -# This function helps systems where core.filemode=false is set.\r
736 -# Use it instead of plain 'chmod +x' to set or unset the executable bit\r
737 -# of a file in the working directory and add it to the index.\r
738  \r
739 -test_chmod () {\r
740 -       chmod "$@" &&\r
741 -       git update-index --add "--chmod=$@"\r
742 -}\r
743  \r
744  # Use test_set_prereq to tell that a particular prerequisite is available.\r
745  # The prerequisite can later be checked for in two ways:\r
746 @@ -527,21 +583,6 @@ test_cmp() {\r
747         $GIT_TEST_CMP "$@"\r
748  }\r
749  \r
750 -# Most tests can use the created repository, but some may need to create more.\r
751 -# Usage: test_create_repo <directory>\r
752 -test_create_repo () {\r
753 -       test "$#" = 1 ||\r
754 -       error "bug in the test script: not 1 parameter to test-create-repo"\r
755 -       owd=`pwd`\r
756 -       repo="$1"\r
757 -       mkdir -p "$repo"\r
758 -       cd "$repo" || error "Cannot setup test environment"\r
759 -       "$GIT_EXEC_PATH/git-init" "--template=$TEST_DIRECTORY/../templates/blt/" >&3 2>&4 ||\r
760 -       error "cannot run git init -- have you built things yet?"\r
761 -       mv .git/hooks .git/hooks-disabled\r
762 -       cd "$owd"\r
763 -}\r
764 -\r
765  test_done () {\r
766         GIT_EXIT_OK=t\r
767         test_results_dir="$TEST_DIRECTORY/test-results"\r
768 @@ -583,9 +624,27 @@ test_done () {\r
769         esac\r
770  }\r
771  \r
772 +find_notmuch_path ()\r
773 +{\r
774 +    dir="$1"\r
775 +\r
776 +    while [ -n "$dir" ]; do\r
777 +       bin="$dir/notmuch"\r
778 +       if [ -x "$bin" ]; then\r
779 +           echo "$dir"\r
780 +           return\r
781 +       fi\r
782 +       dir="$(dirname "$dir")"\r
783 +       if [ "$dir" = "/" ]; then\r
784 +           break\r
785 +       fi\r
786 +    done\r
787 +}\r
788 +\r
789  # Test the binaries we have just built.  The tests are kept in\r
790 -# t/ subdirectory and are run in 'trash directory' subdirectory.\r
791 +# test/ subdirectory and are run in 'trash directory' subdirectory.\r
792  TEST_DIRECTORY=$(pwd)\r
793 +# FIXME: Only the normal case bellow is updated to notmuch\r
794  if test -n "$valgrind"\r
795  then\r
796         make_symlink () {\r
797 @@ -654,48 +713,11 @@ elif test -n "$GIT_TEST_INSTALLED" ; then\r
798         error "Cannot run git from $GIT_TEST_INSTALLED."\r
799         PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH\r
800         GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}\r
801 -else # normal case, use ../bin-wrappers only unless $with_dashes:\r
802 -       git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"\r
803 -       if ! test -x "$git_bin_dir/git" ; then\r
804 -               if test -z "$with_dashes" ; then\r
805 -                       say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"\r
806 -               fi\r
807 -               with_dashes=t\r
808 -       fi\r
809 -       PATH="$git_bin_dir:$PATH"\r
810 -       GIT_EXEC_PATH=$TEST_DIRECTORY/..\r
811 -       if test -n "$with_dashes" ; then\r
812 -               PATH="$TEST_DIRECTORY/..:$PATH"\r
813 -       fi\r
814 -fi\r
815 -GIT_TEMPLATE_DIR=$(pwd)/../templates/blt\r
816 -unset GIT_CONFIG\r
817 -GIT_CONFIG_NOSYSTEM=1\r
818 -GIT_CONFIG_NOGLOBAL=1\r
819 -export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL\r
820 -\r
821 -. ../GIT-BUILD-OPTIONS\r
822 -\r
823 -GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git\r
824 -export GITPERLLIB\r
825 -test -d ../templates/blt || {\r
826 -       error "You haven't built things yet, have you?"\r
827 -}\r
828 -\r
829 -if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"\r
830 -then\r
831 -       GITPYTHONLIB="$(pwd)/../git_remote_helpers/build/lib"\r
832 -       export GITPYTHONLIB\r
833 -       test -d ../git_remote_helpers/build || {\r
834 -               error "You haven't built git_remote_helpers yet, have you?"\r
835 -       }\r
836 -fi\r
837 -\r
838 -if ! test -x ../test-chmtime; then\r
839 -       echo >&2 'You need to build test-chmtime:'\r
840 -       echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'\r
841 -       exit 1\r
842 +else # normal case\r
843 +       notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`\r
844 +       test -n "$notmuch_path" && PATH="$notmuch_path:$PATH"\r
845  fi\r
846 +export PATH\r
847  \r
848  # Test repository\r
849  test="trash directory.$(basename "$0" .sh)"\r
850 @@ -711,10 +733,26 @@ rm -fr "$test" || {\r
851         exit 1\r
852  }\r
853  \r
854 -test_create_repo "$test"\r
855 +MAIL_DIR="${TRASH_DIRECTORY}/mail"\r
856 +export NOTMUCH_CONFIG="${TRASH_DIRECTORY}/notmuch-config"\r
857 +\r
858 +mkdir -p "${test}"\r
859 +mkdir "$MAIL_DIR"\r
860 +\r
861 +cat <<EOF >"${NOTMUCH_CONFIG}"\r
862 +[database]\r
863 +path=${MAIL_DIR}\r
864 +\r
865 +[user]\r
866 +name=Notmuch Test Suite\r
867 +primary_email=test_suite@notmuchmail.org\r
868 +other_email=test_suite_other@notmuchmail.org\r
869 +EOF\r
870 +\r
871 +\r
872  # Use -P to resolve symlinks in our working directory so that the cwd\r
873  # in subprocesses like git equals our $PWD (for pathname comparisons).\r
874 -cd -P "$test" || exit 1\r
875 +cd -P "$test" || error "Cannot setup test environment"\r
876  \r
877  this_test=${0##*/}\r
878  this_test=${this_test%%-*}\r
879 -- \r
880 1.6.6\r
881 \r