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
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
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
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
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
61 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\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
70 diff --git a/test/Makefile b/test/Makefile
\r
71 index bd09390..e07c7fd 100644
\r
75 -include ../config.mak
\r
77 #GIT_TEST_OPTS=--verbose --debug
\r
79 SHELL_PATH ?= $(SHELL)
\r
82 diff --git a/test/README b/test/README
\r
83 index dcd3ebb..0f5bddb 100644
\r
86 @@ -165,10 +165,10 @@ Writing Tests
\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
97 # Copyright (c) 2005 Junio C Hamano
\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
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
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
120 test_description='Test the very basics part #1.
\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
126 -This test runs very basic features, like registering things in cache,
\r
127 -writing tree, etc.
\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
136 ################################################################
\r
137 # It appears that people try to run tests without building...
\r
141 +if ! test -x ../notmuch
\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
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
155 +test_expect_success \
\r
156 + 'test that mail store was created' \
\r
157 + 'test -d "${MAIL_DIR}"'
\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
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
176 +test_expect_success \
\r
177 + 'PATH is set to this repository' \
\r
178 + 'test "`echo $PATH|cut -f1 -d:`" = "`dirname ${TEST_DIRECTORY}`"'
\r
180 ################################################################
\r
182 @@ -73,296 +66,5 @@ then
\r
186 -################################################################
\r
187 -# Basics of the basics
\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
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
199 -test_expect_success \
\r
200 - 'writing tree out with git write-tree' \
\r
201 - 'tree=$(git write-tree)'
\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
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
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
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
223 -test_expect_success \
\r
224 - 'validate object ID of a known tree.' \
\r
225 - 'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'
\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
234 - echo "hello $p" >$p
\r
236 -if test_have_prereq SYMLINKS
\r
240 - ln -s "hello $p" ${p}sym
\r
243 - expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
\r
244 - expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
\r
245 - expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
\r
247 - expectfilter='grep -v sym'
\r
248 - expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
\r
249 - expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
\r
250 - expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
\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
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
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
272 -test_expect_success \
\r
273 - 'validate git ls-files output for a known tree.' \
\r
274 - 'test_cmp expected current'
\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
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
292 -test_expect_success SYMLINKS \
\r
293 - 'git ls-tree output for a known tree.' \
\r
294 - 'test_cmp expected current'
\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
311 -test_expect_success \
\r
312 - 'git ls-tree -r output for a known tree.' \
\r
313 - 'test_cmp expected current'
\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
332 -test_expect_success SYMLINKS \
\r
333 - 'git ls-tree -r output for a known tree.' \
\r
334 - 'test_cmp expected current'
\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
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
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
359 -test_expect_success \
\r
360 - 'put invalid objects into the index.' \
\r
361 - 'git update-index --index-info < badobjects'
\r
363 -test_expect_success 'writing this tree without --missing-ok.' '
\r
364 - test_must_fail git write-tree
\r
367 -test_expect_success \
\r
368 - 'writing this tree with --missing-ok.' \
\r
369 - 'git write-tree --missing-ok'
\r
372 -################################################################
\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
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
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
395 -test_expect_success \
\r
396 - 'git update-index --refresh should succeed.' \
\r
397 - 'git update-index --refresh'
\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
403 -################################################################
\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
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
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
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
429 - test $numparent = 1'
\r
431 -test_expect_success 'update-index D/F conflict' '
\r
433 - mv path2 path0 &&
\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
440 -test_expect_success SYMLINKS 'absolute path works as expected' '
\r
442 - ln -s ../.git first/.git &&
\r
444 - ln -s ../first second/other &&
\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
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
458 -test_expect_success 'very long name in the index handled sanely' '
\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
467 - git update-index --add path4 &&
\r
469 - git ls-files -s path4 |
\r
470 - sed -e "s/ .*/ /" |
\r
473 - ) | git update-index --index-info &&
\r
474 - len=$(git ls-files "a*" | wc -c) &&
\r
479 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
482 index afd3053..9a0f71b
\r
483 --- a/test/test-lib.sh
\r
484 +++ b/test/test-lib.sh
\r
489 # Copyright (c) 2005 Junio C Hamano
\r
491 @@ -29,36 +29,6 @@ PAGER=cat
\r
494 export LANG LC_ALL PAGER TERM TZ
\r
499 -unset AUTHOR_EMAIL
\r
501 -unset COMMIT_AUTHOR_EMAIL
\r
502 -unset COMMIT_AUTHOR_NAME
\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
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
525 GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
\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
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
535 # Each test should start with something like this, after copyright notices:
\r
537 # test_description='Description of this test...
\r
538 @@ -203,22 +176,6 @@ die () {
\r
542 -# The semantics of the editor variables are that of invoking
\r
543 -# sh -c "$EDITOR \"$@\"" files ...
\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
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
553 - export FAKE_EDITOR
\r
554 - EDITOR='"$FAKE_EDITOR"'
\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
566 - if test -z "${test_tick+set}"
\r
568 - test_tick=1112911993
\r
570 - test_tick=$(($test_tick + 60))
\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
580 + increment_mtime_amount=$((increment_mtime_amount + 1))
\r
581 + touch -d "+${increment_mtime_amount} seconds" "$dir"
\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
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
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
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
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
606 +# Text to use as the body of the email message
\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
613 +# Values for email headers. If not provided, default values will
\r
614 +# be generated instead.
\r
616 +# '[cc]="Some User <user@example.com>"'
\r
617 +# [reply-to]=some-address
\r
618 +# [in-reply-to]=<message-id>
\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
624 +gen_msg_filename=""
\r
626 +generate_message ()
\r
628 + # This is our (bash-specific) magic for doing named parameters
\r
629 + local -A template="($@)"
\r
630 + local additional_headers
\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
636 + if [ -z "${template[dir]}" ]; then
\r
637 + gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r
639 + gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
\r
640 + mkdir -p "$(dirname "$gen_msg_filename")"
\r
643 + if [ -z "${template[body]}" ]; then
\r
644 + template[body]="This is just a test message at ${gen_msg_filename}"
\r
647 + if [ -z "${template[from]}" ]; then
\r
648 + template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
\r
651 + if [ -z "${template[to]}" ]; then
\r
652 + template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
\r
655 + if [ -z "${template[subject]}" ]; then
\r
656 + template[subject]="Test message ${gen_msg_filename}"
\r
659 + if [ -z "${template[date]}" ]; then
\r
660 + template[date]="Tue, 05 Jan 2010 15:43:57 -0800"
\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
669 + if [ ! -z "${template[in-reply-to]}" ]; then
\r
670 + additional_headers="In-Reply-To: ${template[in-reply-to]}
\r
671 +${additional_headers}"
\r
674 + if [ ! -z "${template[cc]}" ]; then
\r
675 + additional_headers="Cc: ${template[cc]}
\r
676 +${additional_headers}"
\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
689 + # Ensure that the mtime of the containing directory is updated
\r
690 + increment_mtime "$(dirname "${gen_msg_filename}")"
\r
693 +# Generate a new message and add it to the index.
\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
699 + generate_message "$@" &&
\r
702 - file=${2:-"$1.t"}
\r
703 - echo "${3-$1}" > "$file" &&
\r
704 - git add "$file" &&
\r
706 - git commit -m "$1" &&
\r
708 + notmuch new > /dev/null
\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
722 - git merge -m "$1" "$2" &&
\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
729 + echo " Expected output: $expected"
\r
730 + echo " Actual output: $output"
\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
741 - git update-index --add "--chmod=$@"
\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
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
754 - error "bug in the test script: not 1 parameter to test-create-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
767 test_results_dir="$TEST_DIRECTORY/test-results"
\r
768 @@ -583,9 +624,27 @@ test_done () {
\r
772 +find_notmuch_path ()
\r
776 + while [ -n "$dir" ]; do
\r
777 + bin="$dir/notmuch"
\r
778 + if [ -x "$bin" ]; then
\r
782 + dir="$(dirname "$dir")"
\r
783 + if [ "$dir" = "/" ]; then
\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
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
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
815 -GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
\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
821 -. ../GIT-BUILD-OPTIONS
\r
823 -GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
\r
825 -test -d ../templates/blt || {
\r
826 - error "You haven't built things yet, have you?"
\r
829 -if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
\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
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
842 +else # normal case
\r
843 + notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
\r
844 + test -n "$notmuch_path" && PATH="$notmuch_path:$PATH"
\r
849 test="trash directory.$(basename "$0" .sh)"
\r
850 @@ -711,10 +733,26 @@ rm -fr "$test" || {
\r
854 -test_create_repo "$test"
\r
855 +MAIL_DIR="${TRASH_DIRECTORY}/mail"
\r
856 +export NOTMUCH_CONFIG="${TRASH_DIRECTORY}/notmuch-config"
\r
858 +mkdir -p "${test}"
\r
861 +cat <<EOF >"${NOTMUCH_CONFIG}"
\r
866 +name=Notmuch Test Suite
\r
867 +primary_email=test_suite@notmuchmail.org
\r
868 +other_email=test_suite_other@notmuchmail.org
\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
878 this_test=${this_test%%-*}
\r