1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
56
test_description='git mailinfo and git mailsplit test'
78
. ./test-lib.sh
910
test_expect_success 'split sample box' \
11'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
12last=`cat last` &&
13echo total is $last &&
14test `cat last` = 13'
1516
for mail in `echo 00*`
17do
18test_expect_success "mailinfo $mail" '
19git mailinfo -u msg$mail patch$mail <$mail >info$mail &&
20echo msg &&
21test_cmp "$TEST_DIRECTORY"/t5100/msg$mail msg$mail &&
22echo patch &&
23test_cmp "$TEST_DIRECTORY"/t5100/patch$mail patch$mail &&
24echo info &&
25test_cmp "$TEST_DIRECTORY"/t5100/info$mail info$mail
26'
27done
2829
30
test_expect_success 'split box with rfc2047 samples' \
31'mkdir rfc2047 &&
32git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \
33>rfc2047/last &&
34last=`cat rfc2047/last` &&
35echo total is $last &&
36test `cat rfc2047/last` = 11'
3738
for mail in `echo rfc2047/00*`
39do
40test_expect_success "mailinfo $mail" '
41git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info &&
42echo msg &&
43test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg &&
44echo patch &&
45test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch &&
46echo info &&
47test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info
48'
49done
5051
test_expect_success 'respect NULs' '
5253
git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain &&
54test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
55(cat 001 | git mailinfo msg patch) &&
56test 4 = $(wc -l < patch)
5758
'
5960
test_expect_success 'Preserve NULs out of MIME encoded message' '
6162
git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in &&
63test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 &&
64git mailinfo msg patch <00001 &&
65test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch
6667
'
6869
test_expect_success 'mailinfo on from header without name works' '
7071
mkdir info-from &&
72git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in &&
73test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 &&
74git mailinfo info-from/msg info-from/patch \
75<info-from/0001 >info-from/out &&
76test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out
7778
'
7980
test_done