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 0E6FE431FBF
\r
6 for <notmuch@notmuchmail.org>; Wed, 3 Feb 2010 05:43:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.28 tagged_above=-999 required=5 tests=[AWL=0.319,
\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 x9aat72N4Ru2 for <notmuch@notmuchmail.org>;
\r
16 Wed, 3 Feb 2010 05:43:44 -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 4098A431FC7
\r
19 for <notmuch@notmuchmail.org>; Wed, 3 Feb 2010 05:43:43 -0800 (PST)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 79A8219F35DC
\r
22 for <notmuch@notmuchmail.org>; Wed, 3 Feb 2010 14:43:11 +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 0WchR6auSm6S for <notmuch@notmuchmail.org>;
\r
27 Wed, 3 Feb 2010 14:43:02 +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 9FCB919F35D1
\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 81ABBFA004
\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:46 +0100
\r
38 Message-Id: <1265204568-24018-2-git-send-email-sojkam1@fel.cvut.cz>
\r
39 X-Mailer: git-send-email 1.6.6
\r
40 In-Reply-To: <1265204568-24018-1-git-send-email-sojkam1@fel.cvut.cz>
\r
41 References: <1265204568-24018-1-git-send-email-sojkam1@fel.cvut.cz>
\r
42 Subject: [notmuch] [PATCH 2/4] 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: Wed, 03 Feb 2010 13:43:46 -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 test script.
\r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\r
62 test/t0000-basic.sh | 332 +++------------------------------------------------
\r
63 test/test-lib.sh | 218 +++++++++++-----------------------
\r
64 2 files changed, 88 insertions(+), 462 deletions(-)
\r
66 diff --git a/test/t0000-basic.sh b/test/t0000-basic.sh
\r
67 index f4ca4fc..cc2ca21 100755
\r
68 --- a/test/t0000-basic.sh
\r
69 +++ b/test/t0000-basic.sh
\r
72 test_description='Test the very basics part #1.
\r
74 -The rest of the test suite does not check the basic operation of git
\r
75 -plumbing commands to work very carefully. Their job is to concentrate
\r
76 -on tricky features that caused bugs in the past to detect regression.
\r
78 -This test runs very basic features, like registering things in cache,
\r
81 -Note that this test *deliberately* hard-codes many expected object
\r
82 -IDs. When object ID computation changes, like in the previous case of
\r
83 -swapping compression and hashing order, the person who is making the
\r
84 -modification *should* take notice and update the test vectors here.
\r
85 +Tests the test framework itself.
\r
88 ################################################################
\r
89 # It appears that people try to run tests without building...
\r
93 +if ! test -x ../notmuch
\r
95 - echo >&2 'You do not seem to have built git yet.'
\r
96 + echo >&2 'You do not seem to have built notmuch yet.'
\r
102 ################################################################
\r
103 -# git init has been done in an empty repository.
\r
104 -# make sure it is empty.
\r
105 +# Test mail store prepared in test-lib.sh
\r
107 +test_expect_success \
\r
108 + 'test that mail store was created' \
\r
109 + 'test -d "${MAIL_DIR}"'
\r
112 -find .git/objects -type f -print >should-be-empty
\r
113 +find "${MAIL_DIR}" -type f -print >should-be-empty
\r
114 test_expect_success \
\r
115 - '.git/objects should be empty after git init in an empty repo.' \
\r
116 + 'mail store should be empty' \
\r
117 'cmp -s /dev/null should-be-empty'
\r
119 -# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
\r
120 -# 3 is counting "objects" itself
\r
121 -find .git/objects -type d -print >full-of-directories
\r
122 test_expect_success \
\r
123 - '.git/objects should have 3 subdirectories.' \
\r
124 - 'test $(wc -l < full-of-directories) = 3'
\r
125 + 'NOTMUCH_CONFIG is set and points to an existing file' \
\r
126 + 'test -f "${NOTMUCH_CONFIG}"'
\r
128 +test_expect_success \
\r
129 + 'PATH is set to this repository' \
\r
130 + 'test "`echo $PATH|cut -f1 -d:`" = "`dirname ${TEST_DIRECTORY}`"'
\r
132 ################################################################
\r
134 @@ -73,296 +66,5 @@ then
\r
138 -################################################################
\r
139 -# Basics of the basics
\r
141 -# updating a new file without --add should fail.
\r
142 -test_expect_success 'git update-index without --add should fail adding.' '
\r
143 - test_must_fail git update-index should-be-empty
\r
146 -# and with --add it should succeed, even if it is empty (it used to fail).
\r
147 -test_expect_success \
\r
148 - 'git update-index with --add should succeed.' \
\r
149 - 'git update-index --add should-be-empty'
\r
151 -test_expect_success \
\r
152 - 'writing tree out with git write-tree' \
\r
153 - 'tree=$(git write-tree)'
\r
155 -# we know the shape and contents of the tree and know the object ID for it.
\r
156 -test_expect_success \
\r
157 - 'validate object ID of a known tree.' \
\r
158 - 'test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a'
\r
161 -rm -f should-be-empty full-of-directories
\r
162 -test_expect_success 'git update-index without --remove should fail removing.' '
\r
163 - test_must_fail git update-index should-be-empty
\r
166 -test_expect_success \
\r
167 - 'git update-index with --remove should be able to remove.' \
\r
168 - 'git update-index --remove should-be-empty'
\r
170 -# Empty tree can be written with recent write-tree.
\r
171 -test_expect_success \
\r
172 - 'git write-tree should be able to write an empty tree.' \
\r
173 - 'tree=$(git write-tree)'
\r
175 -test_expect_success \
\r
176 - 'validate object ID of a known tree.' \
\r
177 - 'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'
\r
179 -# Various types of objects
\r
180 -# Some filesystems do not support symblic links; on such systems
\r
181 -# some expected values are different
\r
182 -mkdir path2 path3 path3/subp3
\r
183 -paths='path0 path2/file2 path3/file3 path3/subp3/file3'
\r
186 - echo "hello $p" >$p
\r
188 -if test_have_prereq SYMLINKS
\r
192 - ln -s "hello $p" ${p}sym
\r
195 - expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
\r
196 - expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
\r
197 - expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
\r
199 - expectfilter='grep -v sym'
\r
200 - expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
\r
201 - expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
\r
202 - expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
\r
205 -test_expect_success \
\r
206 - 'adding various types of objects with git update-index --add.' \
\r
207 - 'find path* ! -type d -print | xargs git update-index --add'
\r
209 -# Show them and see that matches what we expect.
\r
210 -test_expect_success \
\r
211 - 'showing stage with git ls-files --stage' \
\r
212 - 'git ls-files --stage >current'
\r
214 -$expectfilter >expected <<\EOF
\r
215 -100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
\r
216 -120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
\r
217 -100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
\r
218 -120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym
\r
219 -100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3
\r
220 -120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym
\r
221 -100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3
\r
222 -120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
\r
224 -test_expect_success \
\r
225 - 'validate git ls-files output for a known tree.' \
\r
226 - 'test_cmp expected current'
\r
228 -test_expect_success \
\r
229 - 'writing tree out with git write-tree.' \
\r
230 - 'tree=$(git write-tree)'
\r
231 -test_expect_success \
\r
232 - 'validate object ID for a known tree.' \
\r
233 - 'test "$tree" = "$expectedtree"'
\r
235 -test_expect_success \
\r
236 - 'showing tree with git ls-tree' \
\r
237 - 'git ls-tree $tree >current'
\r
238 -cat >expected <<\EOF
\r
239 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
\r
240 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
\r
241 -040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
\r
242 -040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
\r
244 -test_expect_success SYMLINKS \
\r
245 - 'git ls-tree output for a known tree.' \
\r
246 - 'test_cmp expected current'
\r
248 -# This changed in ls-tree pathspec change -- recursive does
\r
249 -# not show tree nodes anymore.
\r
250 -test_expect_success \
\r
251 - 'showing tree with git ls-tree -r' \
\r
252 - 'git ls-tree -r $tree >current'
\r
253 -$expectfilter >expected <<\EOF
\r
254 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
\r
255 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
\r
256 -100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
\r
257 -120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
\r
258 -100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
\r
259 -120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
\r
260 -100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
\r
261 -120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
\r
263 -test_expect_success \
\r
264 - 'git ls-tree -r output for a known tree.' \
\r
265 - 'test_cmp expected current'
\r
267 -# But with -r -t we can have both.
\r
268 -test_expect_success \
\r
269 - 'showing tree with git ls-tree -r -t' \
\r
270 - 'git ls-tree -r -t $tree >current'
\r
271 -cat >expected <<\EOF
\r
272 -100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
\r
273 -120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
\r
274 -040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
\r
275 -100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
\r
276 -120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
\r
277 -040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
\r
278 -100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
\r
279 -120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
\r
280 -040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 path3/subp3
\r
281 -100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
\r
282 -120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
\r
284 -test_expect_success SYMLINKS \
\r
285 - 'git ls-tree -r output for a known tree.' \
\r
286 - 'test_cmp expected current'
\r
288 -test_expect_success \
\r
289 - 'writing partial tree out with git write-tree --prefix.' \
\r
290 - 'ptree=$(git write-tree --prefix=path3)'
\r
291 -test_expect_success \
\r
292 - 'validate object ID for a known tree.' \
\r
293 - 'test "$ptree" = "$expectedptree1"'
\r
295 -test_expect_success \
\r
296 - 'writing partial tree out with git write-tree --prefix.' \
\r
297 - 'ptree=$(git write-tree --prefix=path3/subp3)'
\r
298 -test_expect_success \
\r
299 - 'validate object ID for a known tree.' \
\r
300 - 'test "$ptree" = "$expectedptree2"'
\r
302 -cat >badobjects <<EOF
\r
303 -100644 blob 1000000000000000000000000000000000000000 dir/file1
\r
304 -100644 blob 2000000000000000000000000000000000000000 dir/file2
\r
305 -100644 blob 3000000000000000000000000000000000000000 dir/file3
\r
306 -100644 blob 4000000000000000000000000000000000000000 dir/file4
\r
307 -100644 blob 5000000000000000000000000000000000000000 dir/file5
\r
311 -test_expect_success \
\r
312 - 'put invalid objects into the index.' \
\r
313 - 'git update-index --index-info < badobjects'
\r
315 -test_expect_success 'writing this tree without --missing-ok.' '
\r
316 - test_must_fail git write-tree
\r
319 -test_expect_success \
\r
320 - 'writing this tree with --missing-ok.' \
\r
321 - 'git write-tree --missing-ok'
\r
324 -################################################################
\r
326 -test_expect_success \
\r
327 - 'git read-tree followed by write-tree should be idempotent.' \
\r
328 - 'git read-tree $tree &&
\r
329 - test -f .git/index &&
\r
330 - newtree=$(git write-tree) &&
\r
331 - test "$newtree" = "$tree"'
\r
333 -$expectfilter >expected <<\EOF
\r
334 -:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M path0
\r
335 -:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M path0sym
\r
336 -:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M path2/file2
\r
337 -:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M path2/file2sym
\r
338 -:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M path3/file3
\r
339 -:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M path3/file3sym
\r
340 -:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M path3/subp3/file3
\r
341 -:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym
\r
343 -test_expect_success \
\r
344 - 'validate git diff-files output for a know cache/work tree state.' \
\r
345 - 'git diff-files >current && diff >/dev/null -b current expected'
\r
347 -test_expect_success \
\r
348 - 'git update-index --refresh should succeed.' \
\r
349 - 'git update-index --refresh'
\r
351 -test_expect_success \
\r
352 - 'no diff after checkout and git update-index --refresh.' \
\r
353 - 'git diff-files >current && cmp -s current /dev/null'
\r
355 -################################################################
\r
357 -test_expect_success \
\r
358 - 'git commit-tree records the correct tree in a commit.' \
\r
359 - 'commit0=$(echo NO | git commit-tree $P) &&
\r
360 - tree=$(git show --pretty=raw $commit0 |
\r
361 - sed -n -e "s/^tree //p" -e "/^author /q") &&
\r
362 - test "z$tree" = "z$P"'
\r
364 -test_expect_success \
\r
365 - 'git commit-tree records the correct parent in a commit.' \
\r
366 - 'commit1=$(echo NO | git commit-tree $P -p $commit0) &&
\r
367 - parent=$(git show --pretty=raw $commit1 |
\r
368 - sed -n -e "s/^parent //p" -e "/^author /q") &&
\r
369 - test "z$commit0" = "z$parent"'
\r
371 -test_expect_success \
\r
372 - 'git commit-tree omits duplicated parent in a commit.' \
\r
373 - 'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
\r
374 - parent=$(git show --pretty=raw $commit2 |
\r
375 - sed -n -e "s/^parent //p" -e "/^author /q" |
\r
377 - test "z$commit0" = "z$parent" &&
\r
378 - numparent=$(git show --pretty=raw $commit2 |
\r
379 - sed -n -e "s/^parent //p" -e "/^author /q" |
\r
381 - test $numparent = 1'
\r
383 -test_expect_success 'update-index D/F conflict' '
\r
385 - mv path2 path0 &&
\r
387 - git update-index --add --replace path2 path0/file2 &&
\r
388 - numpath0=$(git ls-files path0 | wc -l) &&
\r
389 - test $numpath0 = 1
\r
392 -test_expect_success SYMLINKS 'absolute path works as expected' '
\r
394 - ln -s ../.git first/.git &&
\r
396 - ln -s ../first second/other &&
\r
398 - dir="$(cd .git; pwd -P)" &&
\r
399 - dir2=third/../second/other/.git &&
\r
400 - test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&
\r
401 - file="$dir"/index &&
\r
402 - test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&
\r
404 - test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&
\r
405 - ln -s ../first/file .git/syml &&
\r
406 - sym="$(cd first; pwd -P)"/file &&
\r
407 - test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"
\r
410 -test_expect_success 'very long name in the index handled sanely' '
\r
413 - a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16
\r
414 - a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256
\r
415 - a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096
\r
419 - git update-index --add path4 &&
\r
421 - git ls-files -s path4 |
\r
422 - sed -e "s/ .*/ /" |
\r
425 - ) | git update-index --index-info &&
\r
426 - len=$(git ls-files "a*" | wc -c) &&
\r
431 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
432 index afd3053..b7c3515 100644
\r
433 --- a/test/test-lib.sh
\r
434 +++ b/test/test-lib.sh
\r
435 @@ -29,36 +29,6 @@ PAGER=cat
\r
438 export LANG LC_ALL PAGER TERM TZ
\r
443 -unset AUTHOR_EMAIL
\r
445 -unset COMMIT_AUTHOR_EMAIL
\r
446 -unset COMMIT_AUTHOR_NAME
\r
448 -unset GIT_ALTERNATE_OBJECT_DIRECTORIES
\r
449 -unset GIT_AUTHOR_DATE
\r
450 -GIT_AUTHOR_EMAIL=author@example.com
\r
451 -GIT_AUTHOR_NAME='A U Thor'
\r
452 -unset GIT_COMMITTER_DATE
\r
453 -GIT_COMMITTER_EMAIL=committer@example.com
\r
454 -GIT_COMMITTER_NAME='C O Mitter'
\r
455 -unset GIT_DIFF_OPTS
\r
457 -unset GIT_WORK_TREE
\r
458 -unset GIT_EXTERNAL_DIFF
\r
459 -unset GIT_INDEX_FILE
\r
460 -unset GIT_OBJECT_DIRECTORY
\r
461 -unset GIT_CEILING_DIRECTORIES
\r
462 -unset SHA1_FILE_DIRECTORIES
\r
463 -unset SHA1_FILE_DIRECTORY
\r
464 -GIT_MERGE_VERBOSITY=5
\r
465 -export GIT_MERGE_VERBOSITY
\r
466 -export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
\r
467 -export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
\r
469 GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
\r
471 # Protect ourselves from common misconfiguration to export
\r
472 @@ -203,22 +173,6 @@ die () {
\r
476 -# The semantics of the editor variables are that of invoking
\r
477 -# sh -c "$EDITOR \"$@\"" files ...
\r
479 -# If our trash directory contains shell metacharacters, they will be
\r
480 -# interpreted if we just set $EDITOR directly, so do a little dance with
\r
481 -# environment variables to work around this.
\r
483 -# In particular, quoting isn't enough, as the path may contain the same quote
\r
484 -# that we're using.
\r
485 -test_set_editor () {
\r
487 - export FAKE_EDITOR
\r
488 - EDITOR='"$FAKE_EDITOR"'
\r
492 test_decode_color () {
\r
493 sed -e 's/.\[1m/<WHITE>/g' \
\r
494 -e 's/.\[31m/<RED>/g' \
\r
495 @@ -246,50 +200,39 @@ remove_cr () {
\r
496 tr '\015' Q | sed -e 's/Q$//'
\r
500 - if test -z "${test_tick+set}"
\r
502 - test_tick=1112911993
\r
504 - test_tick=$(($test_tick + 60))
\r
506 - GIT_COMMITTER_DATE="$test_tick -0700"
\r
507 - GIT_AUTHOR_DATE="$test_tick -0700"
\r
508 - export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
\r
511 -# Call test_commit with the arguments "<message> [<file> [<contents>]]"
\r
513 -# This will commit a file with the given contents and the given commit
\r
514 -# message. It will also add a tag with <message> as name.
\r
515 +# Generate a new message in the mail directory, with
\r
516 +# a unique message ID and subject.
\r
518 -# Both <file> and <contents> default to <message>.
\r
521 - file=${2:-"$1.t"}
\r
522 - echo "${3-$1}" > "$file" &&
\r
523 - git add "$file" &&
\r
525 - git commit -m "$1" &&
\r
529 -# Call test_merge with the arguments "<message> <commit>", where <commit>
\r
530 -# can be a tag pointing to the commit-to-merge.
\r
534 - git merge -m "$1" "$2" &&
\r
538 -# This function helps systems where core.filemode=false is set.
\r
539 -# Use it instead of plain 'chmod +x' to set or unset the executable bit
\r
540 -# of a file in the working directory and add it to the index.
\r
544 - git update-index --add "--chmod=$@"
\r
545 +# The filename of the message generated is available as
\r
546 +# $gen_msg_filename
\r
548 +gen_msg_filename=""
\r
549 +generate_message ()
\r
551 + gen_msg_cnt=$((gen_msg_cnt + 1))
\r
552 + gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
554 + if [ "$#" = "0" ]; then
\r
555 + gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r
557 + gen_msg_filename="${MAIL_DIR}/$1/$gen_msg_name"
\r
558 + mkdir -p "$(dirname "$gen_msg_filename")"
\r
561 +cat <<EOF >$gen_msg_filename
\r
562 +From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
563 +To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
564 +Message-Id: <msg-${gen_msg_cnt}@notmuch-test-suite>
\r
565 +Subject: Test message ${gen_msg_filename}
\r
566 +Date: Tue, 05 Jan 2010 15:43:57 -0800
\r
568 +This is just a test message at ${gen_msg_filename}
\r
577 # Use test_set_prereq to tell that a particular prerequisite is available.
\r
578 @@ -527,21 +470,6 @@ test_cmp() {
\r
582 -# Most tests can use the created repository, but some may need to create more.
\r
583 -# Usage: test_create_repo <directory>
\r
584 -test_create_repo () {
\r
586 - error "bug in the test script: not 1 parameter to test-create-repo"
\r
590 - cd "$repo" || error "Cannot setup test environment"
\r
591 - "$GIT_EXEC_PATH/git-init" "--template=$TEST_DIRECTORY/../templates/blt/" >&3 2>&4 ||
\r
592 - error "cannot run git init -- have you built things yet?"
\r
593 - mv .git/hooks .git/hooks-disabled
\r
599 test_results_dir="$TEST_DIRECTORY/test-results"
\r
600 @@ -583,9 +511,27 @@ test_done () {
\r
604 +find_notmuch_path ()
\r
608 + while [ -n "$dir" ]; do
\r
610 + if [ -x $bin ]; then
\r
614 + dir=$(dirname $dir)
\r
615 + if [ "$dir" = "/" ]; then
\r
621 # Test the binaries we have just built. The tests are kept in
\r
622 # t/ subdirectory and are run in 'trash directory' subdirectory.
\r
623 TEST_DIRECTORY=$(pwd)
\r
624 +# FIXME: Only normal case bellow is updated to notmuch
\r
625 if test -n "$valgrind"
\r
628 @@ -654,48 +600,11 @@ elif test -n "$GIT_TEST_INSTALLED" ; then
\r
629 error "Cannot run git from $GIT_TEST_INSTALLED."
\r
630 PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
\r
631 GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
\r
632 -else # normal case, use ../bin-wrappers only unless $with_dashes:
\r
633 - git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"
\r
634 - if ! test -x "$git_bin_dir/git" ; then
\r
635 - if test -z "$with_dashes" ; then
\r
636 - say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
\r
640 - PATH="$git_bin_dir:$PATH"
\r
641 - GIT_EXEC_PATH=$TEST_DIRECTORY/..
\r
642 - if test -n "$with_dashes" ; then
\r
643 - PATH="$TEST_DIRECTORY/..:$PATH"
\r
646 -GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
\r
648 -GIT_CONFIG_NOSYSTEM=1
\r
649 -GIT_CONFIG_NOGLOBAL=1
\r
650 -export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
\r
652 -. ../GIT-BUILD-OPTIONS
\r
654 -GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
\r
656 -test -d ../templates/blt || {
\r
657 - error "You haven't built things yet, have you?"
\r
660 -if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
\r
662 - GITPYTHONLIB="$(pwd)/../git_remote_helpers/build/lib"
\r
663 - export GITPYTHONLIB
\r
664 - test -d ../git_remote_helpers/build || {
\r
665 - error "You haven't built git_remote_helpers yet, have you?"
\r
669 -if ! test -x ../test-chmtime; then
\r
670 - echo >&2 'You need to build test-chmtime:'
\r
671 - echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
\r
673 +else # normal case
\r
674 + notmuch_path=`find_notmuch_path $TEST_DIRECTORY`
\r
675 + test -n "$notmuch_path" && PATH="$notmuch_path:$PATH"
\r
680 test="trash directory.$(basename "$0" .sh)"
\r
681 @@ -711,10 +620,25 @@ rm -fr "$test" || {
\r
685 -test_create_repo "$test"
\r
686 +MAIL_DIR="${TRASH_DIRECTORY}/mail"
\r
687 +export NOTMUCH_CONFIG="${TRASH_DIRECTORY}/notmuch-config"
\r
689 +mkdir -p "${test}"
\r
692 +cat <<EOF > ${NOTMUCH_CONFIG}
\r
697 +name=Notmuch Test Suite
\r
698 +primary_email=test_suite@notmuchmail.org
\r
702 # Use -P to resolve symlinks in our working directory so that the cwd
\r
703 # in subprocesses like git equals our $PWD (for pathname comparisons).
\r
704 -cd -P "$test" || exit 1
\r
705 +cd -P "$test" || error "Cannot setup test environment"
\r
708 this_test=${this_test%%-*}
\r