Tests redirect to err file when grepping stderr
[stgit.git] / t / t4400-encodings.sh
blob6875ec791834fdbbabe2fa7c8c5bef0ff01da556
1 #!/bin/sh
2 test_description='Test diffs with alternate encodings'
3 . ./test-lib.sh
5 test_expect_success 'Initialize empty repo' '
6 git config stgit.sender "A U Thor <author@example.com>" &&
7 touch glass.txt &&
8 git add glass.txt &&
9 git commit -m "Add glass.txt" &&
10 stg init
13 test_expect_success 'Add utf-8 encoded text' '
14 echo "Я могу есть стекло, это мне не вредит." >> glass.txt &&
15 stg new -m "I can eat glass, it does not harm me." UTF-8 &&
16 stg refresh
19 test_expect_success 'Add more encodings' '
20 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
21 iconv -f UTF-8 -t $e glass.txt > $e.txt &&
22 stg new -m "Add $e.txt" $e &&
23 stg add $e.txt &&
24 stg diff &&
25 stg refresh &&
26 stg show | grep -e "Add $e.txt" || return 1
27 done &&
28 stg pop -a &&
29 stg push -a &&
30 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
31 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
32 diff -q glass.txt glass-from-$e.txt || return 1
33 done
36 test_expect_success 'Test export and import' '
37 stg export --dir export-dir &&
38 stg delete .. &&
39 stg import -s export-dir/series &&
40 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
41 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
42 diff -q glass.txt glass-from-$e.txt || return 1
43 done
46 test_expect_success 'Squash' '
47 stg squash -n UTF -m "Squash UTF patches" -- UTF-16 UTF-32BE &&
48 stg show UTF | grep -e "Squash UTF patches" &&
49 for e in UTF-16 UTF-32BE; do
50 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
51 diff -q glass.txt glass-from-$e.txt || return 1
52 done
55 test_expect_success 'Test stg commit' '
56 stg commit UTF-8
59 desc='Test mail export and import'
60 body='
61 stg mail --all --mbox > export.mbox &&
62 stg delete .. &&
63 stg import --mbox export.mbox &&
64 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
65 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
66 diff -q glass.txt glass-from-$e.txt || return 1
67 done
69 if ! (python --version 2>&1 | grep -q -e 'Python 3\.3'); then
70 test_expect_success "$desc" "$body"
71 else
72 test_expect_failure "$desc" "$body"
76 test_done