]> asedeno.scripts.mit.edu Git - git.git/blob - t/t5100-mailinfo.sh
Merge branch 'maint-1.5.6' into maint-1.6.0
[git.git] / t / t5100-mailinfo.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='git mailinfo and git mailsplit test'
7
8 . ./test-lib.sh
9
10 test_expect_success 'split sample box' \
11         'git mailsplit -o. ../t5100/sample.mbox >last &&
12         last=`cat last` &&
13         echo total is $last &&
14         test `cat last` = 13'
15
16 for mail in `echo 00*`
17 do
18         test_expect_success "mailinfo $mail" \
19                 "git mailinfo -u msg$mail patch$mail <$mail >info$mail &&
20                 echo msg &&
21                 diff ../t5100/msg$mail msg$mail &&
22                 echo patch &&
23                 diff ../t5100/patch$mail patch$mail &&
24                 echo info &&
25                 diff ../t5100/info$mail info$mail"
26 done
27
28
29 test_expect_success 'split box with rfc2047 samples' \
30         'mkdir rfc2047 &&
31         git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \
32           >rfc2047/last &&
33         last=`cat rfc2047/last` &&
34         echo total is $last &&
35         test `cat rfc2047/last` = 11'
36
37 for mail in `echo rfc2047/00*`
38 do
39         test_expect_success "mailinfo $mail" '
40                 git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info &&
41                 echo msg &&
42                 test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg &&
43                 echo patch &&
44                 test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch &&
45                 echo info &&
46                 test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info
47         '
48 done
49
50 test_expect_success 'respect NULs' '
51
52         git mailsplit -d3 -o. ../t5100/nul-plain &&
53         cmp ../t5100/nul-plain 001 &&
54         (cat 001 | git mailinfo msg patch) &&
55         test 4 = $(wc -l < patch)
56
57 '
58
59 test_expect_success 'Preserve NULs out of MIME encoded message' '
60
61         git mailsplit -d5 -o. ../t5100/nul-b64.in &&
62         cmp ../t5100/nul-b64.in 00001 &&
63         git mailinfo msg patch <00001 &&
64         cmp ../t5100/nul-b64.expect patch
65
66 '
67
68 test_expect_success 'mailinfo on from header without name works' '
69
70         mkdir info-from &&
71         git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in &&
72         test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 &&
73         git mailinfo info-from/msg info-from/patch \
74           <info-from/0001 >info-from/out &&
75         test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out
76
77 '
78
79 test_done